:root {
    --ink: #252422;
    --paper: #fffcf2;
    --line: #ded8c8;
    --accent: #eb5e28;
    --blue: #4f6d7a;
    --mint: #dfeadc;
    --warn: #f5c16c;
    --white: #fffefa;
    --muted: #756f65;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: "Arial Narrow", "Roboto Condensed", "Inter Tight", Arial, sans-serif;
    letter-spacing: 0;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 72px;
    padding: 14px clamp(14px, 3vw, 34px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 252, 242, 0.94);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}

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

.brand img {
    flex: 0 0 auto;
}

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

.brand small,
.module-label,
.pane-head,
.queue-code,
.metric-strip span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.screen-tabs {
    display: flex;
    gap: 6px;
    align-items: center;
    overflow-x: auto;
}

.tab,
.icon-button,
.action,
.mini-action {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink);
    min-height: 38px;
    border-radius: 6px;
    padding: 9px 13px;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tab:hover,
.icon-button:hover,
.action:hover,
.mini-action:hover {
    border-color: var(--blue);
    transform: translateY(-1px);
}

.tab.is-active,
.action.primary {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid var(--line);
}

.metric-strip div {
    min-height: 86px;
    padding: 18px clamp(14px, 3vw, 34px);
    border-right: 1px solid var(--line);
}

.metric-strip div:last-child {
    border-right: 0;
}

.metric-strip strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(22px, 3vw, 36px);
    line-height: 1;
}

.screen {
    display: none;
    animation: enter 240ms ease both;
}

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

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

.workspace {
    display: grid;
    grid-template-columns: minmax(240px, 0.86fr) minmax(360px, 1.55fr) minmax(250px, 0.9fr);
    min-height: calc(100vh - 159px);
}

.queue-pane,
.record-pane,
.action-pane {
    min-width: 0;
    padding: 20px clamp(14px, 2vw, 24px);
}

.queue-pane,
.record-pane {
    border-right: 1px solid var(--line);
}

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

.icon-button {
    width: 38px;
    padding: 0;
}

.search-field {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.search-field input,
.case-form input,
.note-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink);
    padding: 11px 12px;
    min-height: 42px;
}

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

.queue-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: rgba(255, 254, 250, 0.72);
    border-radius: 8px;
    padding: 13px;
    display: grid;
    gap: 6px;
}

.queue-item strong {
    font-size: 16px;
    line-height: 1.2;
}

.queue-item span:not(.queue-code):not(.status-chip),
.queue-item small {
    color: var(--muted);
    line-height: 1.35;
}

.queue-item.is-active {
    border-color: var(--accent);
    box-shadow: inset 4px 0 0 var(--accent);
}

.record-head {
    max-width: 780px;
    margin-bottom: 22px;
}

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

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

h1 {
    font-size: clamp(30px, 5vw, 58px);
    line-height: 0.96;
    margin-bottom: 14px;
    max-width: 780px;
}

h2 {
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.06;
    margin-bottom: 14px;
}

.record-head p:last-child,
.next-action,
.module-surface p,
.form-panel p {
    color: var(--muted);
    line-height: 1.65;
}

.route-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 22px;
}

.route-step {
    min-height: 128px;
    padding: 16px;
    border-right: 1px solid var(--line);
    background: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.route-step:last-child {
    border-right: 0;
}

.route-step span,
.route-step small,
.document-item span,
.money-row span,
.budget-line small {
    color: var(--muted);
}

.route-step strong {
    font-size: 18px;
    line-height: 1.15;
}

.route-active {
    background: var(--mint);
    box-shadow: inset 0 -4px 0 var(--blue);
}

.route-done {
    background: #f4efe2;
}

.route-blocked {
    background: #fbe1d2;
}

.detail-grid,
.finance-layout,
.create-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.detail-block,
.module-surface,
.form-panel,
.route-preview {
    border-top: 2px solid var(--ink);
    padding-top: 16px;
}

.line-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.line-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    border-bottom: 1px solid var(--line);
}

.line-list strong {
    white-space: nowrap;
}

.status-chip {
    display: inline-flex;
    width: max-content;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #efe7d4;
    color: var(--ink);
    font-size: 12px;
    line-height: 1;
}

.status-in_review,
.status-ready,
.status-accepted {
    background: #dfeadc;
}

.status-blocked,
.status-missing {
    background: #fbe1d2;
}

.status-approved,
.status-reported {
    background: #dce6ef;
}

.action-stack,
.note-form {
    display: grid;
    gap: 10px;
}

.action {
    width: 100%;
}

.note-form {
    margin: 18px 0;
}

.note-form label,
.case-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    line-height: 1.35;
}

.notes {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.note {
    margin: 0 0 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

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

.note p {
    margin: 5px 0 0;
    line-height: 1.5;
}

.create-layout,
.finance-layout,
.module-surface {
    padding: clamp(20px, 3vw, 34px);
}

.case-form {
    max-width: 620px;
    display: grid;
    gap: 14px;
}

pre {
    white-space: pre-wrap;
    background: var(--ink);
    color: var(--paper);
    padding: 14px;
    border-radius: 8px;
    overflow: auto;
}

.route-preview ol {
    list-style: none;
    counter-reset: route;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.route-preview li {
    counter-increment: route;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.route-preview li::before {
    content: counter(route);
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: var(--paper);
    font-weight: 700;
}

.route-preview span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    line-height: 1.45;
}

.document-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.document-item {
    min-height: 154px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    padding: 16px;
    display: grid;
    gap: 12px;
    align-content: space-between;
}

.document-item strong {
    display: block;
    margin-top: 5px;
    line-height: 1.2;
}

.mini-action:disabled {
    cursor: default;
    opacity: 0.55;
    transform: none;
}

.money-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.money-row div {
    min-height: 98px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    padding: 16px;
}

.money-row strong {
    display: block;
    margin-top: 12px;
    font-size: clamp(24px, 4vw, 42px);
    line-height: 1;
}

.budget-lines {
    display: grid;
    gap: 10px;
}

.budget-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.budget-line small {
    grid-column: 1 / -1;
    line-height: 1.45;
}

.bars {
    display: grid;
    gap: 13px;
}

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

.bar-row i {
    display: block;
    height: 12px;
    border-radius: 999px;
    background: var(--blue);
}

@media (max-width: 1080px) {
    .workspace {
        grid-template-columns: minmax(220px, 0.9fr) minmax(360px, 1.4fr);
    }

    .action-pane {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
    }

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

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

    .screen-tabs,
    .tab {
        width: 100%;
    }

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

    .metric-strip,
    .workspace,
    .detail-grid,
    .finance-layout,
    .create-layout,
    .route-steps,
    .document-grid,
    .money-row {
        grid-template-columns: 1fr;
    }

    .metric-strip div,
    .queue-pane,
    .record-pane {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .workspace {
        min-height: auto;
    }

    .route-step {
        min-height: 96px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    h1 {
        font-size: 34px;
    }
}

