:root {
  --ink: #242423;
  --paper: #f7f7f2;
  --blue: #3a86ff;
  --yellow: #ffbe0b;
  --line: rgba(36, 36, 35, 0.14);
  --muted: rgba(36, 36, 35, 0.62);
  --panel: #ffffff;
  --danger: #dc3030;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(90deg, rgba(36, 36, 35, 0.04) 0 2px, transparent 2px 18px),
    var(--paper);
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.scanner-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  background: var(--ink);
  color: var(--paper);
  border-right: 6px solid var(--yellow);
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

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

.brand small,
.source-box strong,
.eyebrow,
.barcode {
  letter-spacing: 0;
}

.brand small {
  color: rgba(247, 247, 242, 0.7);
  font-size: 12px;
}

.tabs {
  display: grid;
  gap: 10px;
}

.tab,
.icon-button,
.primary-button,
.quick-actions button,
.stage-card {
  border: 1px solid var(--line);
  border-radius: 7px;
}

.tab {
  min-height: 42px;
  padding: 10px 12px;
  background: rgba(247, 247, 242, 0.08);
  color: var(--paper);
  text-align: left;
  text-transform: uppercase;
}

.tab.is-active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.source-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(247, 247, 242, 0.2);
  border-radius: 7px;
}

.source-box strong {
  display: block;
  margin-top: 5px;
  color: var(--yellow);
}

.barcode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.barcode::before {
  content: "";
  width: 34px;
  height: 14px;
  background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 5px, currentColor 5px 7px, transparent 7px 10px);
  opacity: 0.75;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.12;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.search {
  display: grid;
  gap: 4px;
  min-width: min(280px, 100%);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search input,
.dialog-form input,
.dialog-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.icon-button,
.primary-button {
  min-height: 42px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.primary-button {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metrics article,
.stage-card,
.queue-panel,
.active-panel,
.action-panel,
.analytics-card,
.note-row,
.public-row,
.import-band,
.import-result article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metrics article {
  padding: 14px;
  border-top: 5px solid var(--ink);
}

.metrics article.blue {
  border-top-color: var(--blue);
}

.metrics article.yellow {
  border-top-color: var(--yellow);
}

.metrics strong {
  display: block;
  margin: 4px 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.metrics small,
.case-row small,
.public-row small,
.analytics-card small {
  color: var(--muted);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stage-card {
  display: grid;
  gap: 8px;
  min-height: 146px;
  padding: 14px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(58, 134, 255, 0.08), transparent 48%),
    #fff;
}

.stage-card strong {
  font-size: 22px;
}

.stage-card em {
  min-height: 44px;
  color: var(--muted);
  font-style: normal;
}

.meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: rgba(36, 36, 35, 0.12);
  border-radius: 99px;
}

.meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--yellow));
  border-radius: inherit;
}

.inbox-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.92fr) minmax(320px, 1.25fr) minmax(230px, 0.83fr);
  gap: 14px;
  align-items: start;
}

.queue-panel,
.active-panel,
.action-panel {
  min-width: 0;
  padding: 14px;
}

.panel-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.case-row {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid transparent;
  border-radius: 7px;
}

.case-row.is-selected {
  border-left-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.case-code {
  display: inline-block;
  width: max-content;
  max-width: 100%;
  padding: 2px 7px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
}

.row-meta em {
  font-style: normal;
}

.risk {
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(36, 36, 35, 0.08);
}

.risk-hot {
  background: var(--yellow);
}

.risk-watch {
  background: rgba(58, 134, 255, 0.16);
}

.active-record {
  position: relative;
  overflow: hidden;
  padding: 18px;
  min-height: 352px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 7px;
}

.active-record p {
  color: rgba(247, 247, 242, 0.76);
}

.scanline {
  height: 56px;
  margin: -18px -18px 18px;
  background:
    linear-gradient(90deg, transparent 0 16%, rgba(255, 190, 11, 0.95) 16% 18%, transparent 18% 28%, rgba(247, 247, 242, 0.8) 28% 29%, transparent 29% 100%),
    repeating-linear-gradient(90deg, rgba(247, 247, 242, 0.22) 0 3px, transparent 3px 12px);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.facts div {
  padding: 10px;
  background: rgba(247, 247, 242, 0.08);
  border-radius: 7px;
}

.facts dt {
  color: rgba(247, 247, 242, 0.58);
  font-size: 11px;
  text-transform: uppercase;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.forecast-block {
  display: grid;
  gap: 8px;
}

.forecast-block strong {
  color: var(--yellow);
  font-size: 38px;
  line-height: 1;
}

.next-action {
  min-height: 186px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 190, 11, 0.16), #fff 56%);
  border: 1px dashed rgba(36, 36, 35, 0.32);
  border-radius: 7px;
}

.quick-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quick-actions button {
  padding: 10px 12px;
  background: #fff;
  text-align: left;
  font-weight: 800;
}

.analytics-grid,
.public-list,
.timeline,
.import-result {
  display: grid;
  gap: 10px;
}

.analytics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.analytics-card,
.note-row,
.public-row,
.import-result article {
  padding: 14px;
}

.analytics-card .big-number {
  margin: 10px 0;
  color: var(--blue);
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
}

.note-row {
  border-left: 5px solid var(--blue);
}

.note-row p {
  margin-bottom: 0;
}

.import-band {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  margin-bottom: 14px;
}

.import-band p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
}

.import-result article {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

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

.public-row strong,
.public-row small {
  display: block;
}

.public-row b {
  color: var(--blue);
  font-size: 26px;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(36, 36, 35, 0.26);
}

dialog::backdrop {
  background: rgba(36, 36, 35, 0.56);
}

.dialog-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-form label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.dialog-actions button {
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

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

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

  .rail {
    position: static;
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(0, 2fr) auto;
    align-items: center;
    border-right: 0;
    border-bottom: 6px solid var(--yellow);
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .source-box {
    margin-top: 0;
  }

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

@media (max-width: 760px) {
  .rail,
  .topbar,
  .import-band {
    display: grid;
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 14px;
  }

  .tabs,
  .metrics,
  .stage-strip,
  .analytics-grid,
  .facts {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar > *,
  .icon-button,
  .primary-button {
    width: 100%;
  }

  .public-row {
    grid-template-columns: 1fr;
  }
}
