:root {
  --primary: #2463d4;
  --primary-dark: #1d4fb0;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 24px;
  background: #1d4fb0;
  color: white;
  font-size: 12px;
}

.ribbon code {
  color: rgba(255, 255, 255, 0.92);
}

.navwrap,
.container {
  width: min(1536px, calc(100% - 32px));
  margin: 0 auto;
}

.navwrap {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #111827;
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  border-radius: 6px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav a {
  padding: 9px 12px;
  border-radius: 7px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.nav a:hover,
.nav a.active {
  background: var(--primary);
  color: #ffffff;
}

.nav a.toolbox {
  border: 1px solid #bfdbfe;
  color: #1d4fb0;
  background: #eff6ff;
}

.menu-button {
  display: none;
}

.main {
  flex: 1;
  padding: 24px 0 40px;
}

.page-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 28px;
}

.muted {
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button,
button.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--primary-dark);
}

.button.secondary {
  background: #ffffff;
  color: #374151;
  border-color: var(--border);
}

.button.success {
  background: var(--success);
}

.button.warning {
  background: var(--warning);
  color: #111827;
}

.button.danger {
  background: var(--danger);
}

.grid-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat,
.panel,
.door,
.label-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.stat {
  padding: 14px 16px;
}

.stat strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.panel {
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-header,
.door-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}

.panel-body,
.door-body {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.field {
  grid-column: span 2;
}

.field.wide {
  grid-column: span 3;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #374151;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(36, 99, 212, 0.15);
  border-color: var(--primary);
}

.door {
  margin-bottom: 14px;
}

.line-table {
  width: 100%;
  border-collapse: collapse;
}

.line-table th,
.line-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
}

.line-table th {
  background: #f9fafb;
  color: #6b7280;
  font-size: 12px;
  text-transform: uppercase;
}

.line-table input[type="number"] {
  min-width: 90px;
}

.check-cell {
  text-align: center;
}

.valid-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.valid-pill.ok {
  background: var(--success);
}

.valid-pill.no {
  background: var(--danger);
}

.kbn-viewer {
  overflow: auto;
  max-height: 62vh;
  border-radius: 12px;
  background: #020617;
  color: #d1d5db;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 12px;
}

.kbn-line {
  display: grid;
  grid-template-columns: 54px 1fr;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kbn-line span:first-child {
  padding: 8px;
  color: #64748b;
  text-align: right;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.kbn-line code {
  padding: 8px 12px;
  white-space: pre;
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.label-card {
  padding: 14px;
  min-height: 150px;
}

.label-card.chute {
  border-color: #f59e0b;
  background: #fffbeb;
}

.label-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.barcode {
  margin: 12px 0;
  padding: 8px;
  border: 1px dashed #9ca3af;
  text-align: center;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 18px;
  letter-spacing: 2px;
}

.codes-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.codes-table th,
.codes-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.codes-table th {
  background: #f9fafb;
  color: #6b7280;
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

.notice {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  margin-bottom: 16px;
}

.footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 12px;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
}

@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .main {
    padding: 0;
  }

  .container {
    width: 100%;
  }

  .label-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 4mm;
    padding: 8mm;
  }

  .label-card {
    break-inside: avoid;
    box-shadow: none;
    border-color: #000;
  }
}

@media (max-width: 860px) {
  .ribbon span {
    display: none;
  }

  .menu-button {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    padding: 9px 12px;
    font: inherit;
    font-weight: 700;
  }

  .nav {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    top: 86px;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(16, 24, 40, 0.18);
  }

  .nav.open {
    display: flex;
  }

  .page-title {
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field,
  .field.wide {
    grid-column: 1;
  }

  .line-table {
    min-width: 940px;
  }
}
