:root {
  --ink: #242423;
  --paper: #f7f7f2;
  --blue: #3a86ff;
  --amber: #ffbe0b;
  --muted: #74736d;
  --line: #d9d8cf;
  --soft: #ecebe4;
  --danger: #d44b3f;
  --ok: #1f9d72;
  --shadow: 0 18px 60px rgba(36, 36, 35, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(36, 36, 35, 0.03) 0 1px, transparent 1px 12px),
    linear-gradient(180deg, #fbfbf6 0%, var(--paper) 42%, #eeeeE8 100%);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 34px);
  color: var(--paper);
  background: var(--ink);
  border-bottom: 3px solid var(--amber);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 20px;
  line-height: 1;
}

.brand small {
  max-width: 230px;
  margin-top: 4px;
  color: rgba(247, 247, 242, 0.72);
  font-size: 12px;
  line-height: 1.25;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tab,
.icon-button,
.quick-actions button,
.primary-action {
  border: 0;
  color: var(--ink);
  background: var(--paper);
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(247, 247, 242, 0.24);
  color: rgba(247, 247, 242, 0.74);
  background: transparent;
  text-transform: uppercase;
  font-size: 12px;
}

.tab:hover,
.tab.is-active {
  color: var(--ink);
  background: var(--amber);
}

main {
  padding: clamp(14px, 3vw, 34px);
}

.scanner-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.scanner-strip > div {
  min-height: 92px;
  padding: 15px;
  color: var(--paper);
  background: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scanner-strip b {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 0.95;
}

.scanner-strip small {
  display: block;
  max-width: 230px;
  margin-top: 8px;
  color: rgba(247, 247, 242, 0.72);
  line-height: 1.3;
}

.barcode {
  display: block;
  color: var(--amber);
  font-family: "Courier New", monospace;
  font-size: 13px;
  white-space: nowrap;
}

.screen {
  display: none;
  animation: rise 220ms ease both;
}

.screen.is-active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dispatch-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.55fr) minmax(260px, 0.82fr);
  gap: 12px;
  align-items: start;
}

.queue-panel,
.record-panel,
.action-panel,
.analytics-layout,
.utility-layout,
.public-layout {
  min-width: 0;
  background: rgba(247, 247, 242, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.queue-panel,
.action-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.queue-panel,
.action-panel,
.record-panel {
  padding: 14px;
}

.panel-head,
.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head.compact {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

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

h1,
h2 {
  margin-bottom: 0;
  line-height: 1.04;
}

h1 {
  font-size: clamp(28px, 4.4vw, 54px);
  max-width: 520px;
}

h2 {
  font-size: clamp(24px, 3vw, 40px);
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
  line-height: 1.2;
  text-transform: uppercase;
}

.icon-button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
}

.icon-button:hover,
.quick-actions button:hover,
.primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(36, 36, 35, 0.16);
}

.filters {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #fff;
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.18);
}

.case-list {
  display: grid;
  gap: 8px;
}

.case-row {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.case-row:hover,
.case-row.is-selected {
  border-color: var(--ink);
  background: #fff6d5;
}

.case-row strong,
.case-row span,
.case-row small {
  display: block;
  min-width: 0;
}

.case-row strong {
  margin: 6px 0;
  line-height: 1.15;
}

.case-row span:not(.row-code) {
  color: var(--muted);
  line-height: 1.35;
}

.case-row small {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--ink);
}

.case-row em,
.case-row b,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  background: var(--soft);
  font-style: normal;
  font-size: 12px;
}

.row-code {
  color: var(--blue);
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 800;
}

.record-panel {
  min-height: 640px;
}

.record-empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  text-align: center;
}

.record-empty.error {
  color: var(--danger);
}

.status-chip {
  color: var(--paper);
  background: var(--blue);
  white-space: nowrap;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.record-meta span {
  padding: 7px 9px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
}

.workflow-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin: 16px 0;
}

.workflow-rail span {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  text-align: center;
  font-size: 13px;
}

.workflow-rail span.is-done {
  border-color: var(--ink);
  color: var(--ink);
}

.workflow-rail span.is-current {
  color: var(--ink);
  background: var(--amber);
}

.inspection-layout {
  display: grid;
  grid-template-columns: 1fr 0.75fr;
  gap: 12px;
}

.scan-list,
.route-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.scan-list li,
.route-list li,
.deadline-table div,
.notes-feed article,
.deadline-stack article {
  border-top: 1px solid var(--line);
}

.scan-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  line-height: 1.35;
}

.scan-list b {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
}

.route-list {
  counter-reset: route;
}

.route-list li {
  counter-increment: route;
  position: relative;
  padding: 11px 0 11px 32px;
  line-height: 1.35;
}

.route-list li::before {
  content: counter(route);
  position: absolute;
  left: 0;
  top: 9px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  font-size: 11px;
}

.deadline-table,
.notes-feed {
  margin-top: 18px;
}

.deadline-table div {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 150px 120px;
  gap: 10px;
  padding: 10px 0;
  align-items: center;
  line-height: 1.35;
}

.deadline-table time,
.deadline-stack time {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.deadline-table b {
  font-size: 12px;
}

.notes-feed article {
  padding: 11px 0;
}

.notes-feed span {
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
}

.notes-feed p {
  margin: 4px 0 0;
  line-height: 1.55;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 18px;
}

.quick-actions button,
.primary-action {
  min-height: 42px;
  padding: 0 10px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}

.quick-actions button:nth-child(2),
.quick-actions button:nth-child(5),
.primary-action {
  background: var(--blue);
  border-color: var(--blue);
}

.quick-actions button:nth-child(6) {
  color: var(--ink);
  background: var(--amber);
  border-color: var(--amber);
}

.deadline-stack h3 {
  margin-top: 0;
}

.deadline-stack article {
  display: grid;
  gap: 5px;
  padding: 10px 0;
  line-height: 1.35;
}

.deadline-stack b {
  color: var(--blue);
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.analytics-layout,
.utility-layout,
.public-layout {
  padding: clamp(18px, 4vw, 44px);
}

.analytics-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 24px;
}

.stage-bars {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.stage-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 40px;
  gap: 12px;
  align-items: center;
}

.stage-row div {
  height: 24px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.stage-row i {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--blue) 0 9px, var(--ink) 9px 12px);
}

.signal-board {
  display: grid;
  gap: 8px;
}

.signal-board div {
  min-height: 100px;
  padding: 14px;
  color: var(--paper);
  background: var(--ink);
}

.signal-board span,
.signal-board strong {
  display: block;
}

.signal-board span {
  color: rgba(247, 247, 242, 0.72);
}

.signal-board strong {
  margin-top: 12px;
  font-size: 32px;
  line-height: 1;
}

.utility-layout p {
  max-width: 640px;
  color: var(--muted);
  line-height: 1.65;
}

.log-output {
  max-width: 760px;
  min-height: 150px;
  margin-top: 16px;
  padding: 14px;
  overflow: auto;
  color: var(--paper);
  background: var(--ink);
  white-space: pre-wrap;
}

.public-ticket {
  max-width: 760px;
  margin-top: 18px;
  padding: 18px;
  border: 2px solid var(--ink);
  background: #fff;
}

.public-ticket h3 {
  margin-top: 10px;
  font-size: clamp(24px, 3vw, 38px);
  text-transform: none;
}

.public-ticket p {
  line-height: 1.55;
}

.public-ticket dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.public-ticket dl div {
  padding: 10px;
  background: var(--soft);
}

.public-ticket dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.public-ticket dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.public-ticket small {
  color: var(--blue);
  font-family: "Courier New", monospace;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  text-align: center;
}

.is-loading .scanner-strip {
  filter: saturate(0.7);
}

@media (max-width: 1120px) {
  .dispatch-grid {
    grid-template-columns: 1fr;
  }

  .queue-panel,
  .action-panel {
    position: static;
    max-height: none;
  }

  .case-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    justify-content: stretch;
  }

  .tab {
    flex: 1 1 44%;
  }

  main {
    padding: 12px;
  }

  .scanner-strip,
  .case-list,
  .inspection-layout,
  .public-ticket dl {
    grid-template-columns: 1fr;
  }

  .record-head {
    display: grid;
  }

  .workflow-rail {
    grid-template-columns: 1fr 1fr;
  }

  .deadline-table div {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .stage-row {
    grid-template-columns: 88px minmax(0, 1fr) 28px;
  }
}
