:root {
    --ink: #242423;
    --paper: #f7f7f2;
    --blue: #3a86ff;
    --yellow: #ffbe0b;
    --line: rgba(36, 36, 35, 0.16);
    --muted: rgba(36, 36, 35, 0.62);
    --panel: #ffffff;
    --risk: #d93a2f;
    --ok: #1f9d63;
    --shadow: 0 18px 45px rgba(36, 36, 35, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", Arial, sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.scanner-frame {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(36, 36, 35, 0.04) 1px, transparent 1px) 0 0 / 19px 100%,
        linear-gradient(180deg, rgba(58, 134, 255, 0.07), transparent 38%);
}

.app-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.queue-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
    padding: 22px 18px;
    color: var(--paper);
    background: var(--ink);
    border-right: 6px solid var(--yellow);
}

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

.brand img {
    flex: 0 0 auto;
}

.brand strong {
    display: block;
    font-size: 23px;
    line-height: 1;
    letter-spacing: 0;
}

.brand small,
.mono,
.eyebrow,
.metric small,
.case-row small,
.record-facts dt,
.notes-feed small {
    font-size: 11px;
    line-height: 1.25;
    letter-spacing: 0;
    text-transform: uppercase;
}

.brand small {
    color: rgba(247, 247, 242, 0.7);
}

.screen-tabs {
    display: grid;
    gap: 8px;
}

.tab {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: rgba(247, 247, 242, 0.82);
    text-align: left;
    background: transparent;
    border: 1px solid rgba(247, 247, 242, 0.18);
    border-radius: 6px;
    transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
    color: var(--paper);
    border-color: var(--yellow);
    transform: translateX(3px);
}

.search-box {
    display: grid;
    gap: 8px;
}

.search-box label,
.source-panel .mono {
    color: rgba(247, 247, 242, 0.58);
}

.search-box input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--paper);
    background: rgba(247, 247, 242, 0.08);
    border: 1px solid rgba(247, 247, 242, 0.22);
    border-radius: 6px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--blue);
}

.source-panel {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(247, 247, 242, 0.16);
}

.source-panel strong {
    display: block;
    margin-top: 6px;
    color: var(--yellow);
    overflow-wrap: anywhere;
}

.workspace {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    padding: 22px;
}

.topline,
.metric-strip,
.section-head,
.record-header {
    border-bottom: 1px solid var(--line);
}

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--blue);
    font-weight: 700;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 54px);
    line-height: 0.95;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 8px;
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 7px;
    font-size: 18px;
    line-height: 1.15;
    letter-spacing: 0;
}

p {
    line-height: 1.55;
}

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

.icon-button,
.primary-button,
.stage-filter button {
    min-height: 40px;
    border-radius: 6px;
    border: 1px solid var(--ink);
}

.icon-button {
    width: 42px;
    color: var(--ink);
    background: var(--paper);
    font-weight: 800;
}

.primary-button {
    padding: 10px 14px;
    color: var(--ink);
    background: var(--yellow);
    border-color: var(--ink);
    font-weight: 800;
}

.primary-button.full {
    width: 100%;
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    padding-bottom: 18px;
}

.metric {
    min-height: 96px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.62);
    border-left: 5px solid var(--ink);
}

.metric strong {
    display: block;
    margin: 7px 0 4px;
    font-size: 28px;
    line-height: 1;
}

.metric small,
.muted {
    color: var(--muted);
}

.metric-blue {
    border-color: var(--blue);
}

.metric-yellow {
    border-color: var(--yellow);
}

.metric-risk {
    border-color: var(--risk);
}

.view {
    display: none;
}

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

.three-column {
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1.35fr) minmax(240px, 0.85fr);
    gap: 18px;
    align-items: stretch;
}

.queue-column,
.record-column,
.action-column,
.import-console {
    min-width: 0;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.queue-column,
.action-column,
.import-console {
    padding: 16px;
}

.record-column {
    padding: 18px;
    border-top: 7px solid var(--blue);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.mono {
    color: var(--muted);
    font-weight: 800;
}

.stage-filter {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.stage-filter button {
    padding: 7px 10px;
    color: var(--ink);
    background: transparent;
}

.stage-filter button.is-active {
    color: var(--paper);
    background: var(--ink);
}

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

.case-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 82px;
    padding: 10px;
    color: var(--ink);
    text-align: left;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.case-row:hover,
.case-row.is-active {
    transform: translateY(-1px);
    border-color: var(--blue);
    background: #ffffff;
}

.barcode {
    width: 18px;
    height: 54px;
    background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 5px, var(--ink) 5px 7px, transparent 7px 10px);
    opacity: 0.82;
}

.case-main {
    min-width: 0;
}

.case-main strong,
.case-main em,
.case-main small {
    display: block;
    overflow-wrap: anywhere;
}

.case-main em {
    margin-top: 4px;
    color: var(--muted);
    font-style: normal;
}

.case-status {
    align-self: start;
    padding: 4px 7px;
    color: var(--paper);
    background: var(--ink);
    border-radius: 5px;
    font-size: 12px;
    white-space: nowrap;
}

.status-hot .case-status,
.status-hot.status-dot {
    background: var(--blue);
}

.status-watch .case-status,
.status-watch.status-dot {
    background: var(--yellow);
    color: var(--ink);
}

.status-risk .case-status,
.status-risk.status-dot {
    background: var(--risk);
}

.record-header {
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.record-header h2 {
    font-size: clamp(25px, 4vw, 43px);
    line-height: 1;
    overflow-wrap: anywhere;
}

.record-header p {
    margin-bottom: 0;
    color: var(--muted);
}

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

.workflow-track span {
    min-height: 58px;
    padding: 10px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-weight: 800;
}

.workflow-track span.is-active {
    color: var(--paper);
    background: var(--blue);
    border-color: var(--blue);
}

.workflow-track small {
    display: block;
    margin-top: 5px;
    opacity: 0.75;
}

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

.record-facts div {
    min-height: 70px;
    padding: 12px;
    background: var(--paper);
    border-left: 4px solid var(--ink);
}

.record-facts dt {
    color: var(--muted);
}

.record-facts dd {
    margin: 7px 0 0;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.sample-panel {
    padding: 14px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 6px;
}

.sample-meter {
    height: 14px;
    margin: 12px 0;
    background: rgba(247, 247, 242, 0.18);
    overflow: hidden;
}

.sample-meter span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--blue), var(--yellow));
    transition: width 240ms ease;
}

.sample-panel strong {
    font-size: 28px;
}

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 5px rgba(31, 157, 99, 0.13);
}

.action-column p {
    min-height: 92px;
    padding: 14px;
    background: var(--paper);
    border-left: 5px solid var(--yellow);
    font-size: 19px;
    font-weight: 800;
    line-height: 1.35;
}

.notes-feed {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.notes-feed article {
    padding: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.notes-feed p {
    margin: 7px 0;
}

.analytics-grid,
.public-board {
    display: grid;
    gap: 12px;
}

.analytics-row,
.public-item {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(140px, 1.4fr) auto minmax(130px, 0.7fr);
    gap: 14px;
    align-items: center;
    padding: 14px;
    background: rgba(255, 255, 255, 0.76);
    border-left: 7px solid var(--ink);
    box-shadow: var(--shadow);
}

.scan-line {
    height: 18px;
    background: repeating-linear-gradient(90deg, rgba(36, 36, 35, 0.13) 0 3px, transparent 3px 8px);
    overflow: hidden;
}

.scan-line span {
    display: block;
    height: 100%;
    background: var(--blue);
}

.public-item {
    grid-template-columns: 100px minmax(180px, 1fr) minmax(260px, 1.4fr) auto;
}

.public-item strong {
    font-size: 24px;
}

.import-console {
    max-width: 760px;
    padding: 22px;
}

.import-console p {
    color: var(--muted);
}

pre {
    margin: 18px 0 0;
    padding: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--paper);
    background: var(--ink);
    border-radius: 6px;
}

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

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

.dialog-form {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: var(--paper);
}

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

.dialog-form textarea {
    width: 100%;
    resize: vertical;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

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

.dialog-actions button {
    min-height: 40px;
    padding: 9px 13px;
    border-radius: 6px;
    border: 1px solid var(--ink);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .three-column {
        grid-template-columns: 1fr;
    }

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

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

    .queue-panel {
        min-height: auto;
        border-right: 0;
        border-bottom: 6px solid var(--yellow);
    }

    .workspace {
        padding: 16px;
    }

    .topline,
    .section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar {
        justify-content: flex-start;
    }

    .metric-strip,
    .record-facts,
    .workflow-track,
    .analytics-row,
    .public-item {
        grid-template-columns: 1fr;
    }

    .case-row {
        grid-template-columns: 16px minmax(0, 1fr);
    }

    .case-status {
        grid-column: 2;
        justify-self: start;
    }
}
