:root {
    --ink: #252422;
    --paper: #fffcf2;
    --line: #ded8c7;
    --accent: #eb5e28;
    --steel: #4f6d7a;
    --mint: #5f8f7b;
    --warn: #b33b1e;
    --soft: #f5f0e5;
    --white: #fffef8;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100%;
    margin: 0;
    font-size: 16px;
    line-height: 1.58;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(79, 109, 122, 0.09) 1px, transparent 1px),
        linear-gradient(180deg, rgba(37, 36, 34, 0.05) 1px, transparent 1px),
        var(--paper);
    background-size: 42px 42px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(160px, 220px);
    gap: 18px;
    align-items: center;
    padding: 14px 22px;
    border-bottom: 1px solid rgba(37, 36, 34, 0.14);
    background: rgba(255, 252, 242, 0.94);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    text-decoration: none;
}

.brand strong,
.brand small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.brand small,
.eyebrow {
    color: rgba(37, 36, 34, 0.64);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(37, 36, 34, 0.16);
    border-radius: 8px;
    background: var(--white);
}

.tab {
    min-height: 34px;
    padding: 6px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: rgba(37, 36, 34, 0.72);
}

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

.topbar-metric {
    justify-self: end;
    min-width: 0;
    text-align: right;
}

.topbar-metric span,
.topbar-metric strong {
    display: block;
}

.topbar-metric span {
    color: rgba(37, 36, 34, 0.62);
    font-size: 12px;
}

.topbar-metric strong {
    color: var(--accent);
    font-size: 22px;
    line-height: 1.1;
}

.workspace {
    padding: 22px;
}

.view {
    display: none;
}

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

.board-view.is-active {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(360px, 1.35fr) minmax(280px, 0.9fr);
    min-height: calc(100vh - 98px);
    gap: 18px;
}

.queue-panel,
.record-panel,
.action-panel,
.create-form,
.data-table,
.finance-totals span {
    border: 1px solid rgba(37, 36, 34, 0.15);
    border-radius: 8px;
    background: rgba(255, 254, 248, 0.9);
}

.queue-panel,
.record-panel,
.action-panel {
    min-width: 0;
    padding: 18px;
}

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

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

h1 {
    margin-bottom: 0;
    font-size: clamp(27px, 3vw, 40px);
    line-height: 1.03;
}

h2 {
    margin-bottom: 12px;
    font-size: 28px;
    line-height: 1.08;
}

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

.eyebrow {
    margin-bottom: 5px;
}

.icon-button,
.primary-button,
.secondary-button {
    min-height: 39px;
    border-radius: 8px;
    border: 1px solid rgba(37, 36, 34, 0.18);
    transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.icon-button {
    width: 40px;
    background: var(--soft);
    color: var(--ink);
    font-size: 20px;
}

.primary-button {
    padding: 9px 14px;
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
}

.secondary-button {
    padding: 9px 14px;
    background: var(--white);
    color: var(--ink);
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.case-row:hover {
    transform: translateY(-1px);
}

.filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    margin: 18px 0 13px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(37, 36, 34, 0.18);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    padding: 10px 11px;
    outline-color: var(--steel);
}

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

.summary-strip span {
    min-width: 0;
    padding: 8px;
    border-radius: 7px;
    background: rgba(79, 109, 122, 0.12);
    color: rgba(37, 36, 34, 0.72);
    font-size: 11px;
    line-height: 1.2;
}

.summary-strip strong {
    display: block;
    color: var(--ink);
    font-size: 18px;
}

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

.case-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 10px;
    width: 100%;
    padding: 13px;
    border: 1px solid rgba(37, 36, 34, 0.13);
    border-radius: 8px;
    background: rgba(255, 252, 242, 0.72);
    color: var(--ink);
    text-align: left;
}

.case-row.is-selected {
    border-color: rgba(235, 94, 40, 0.7);
    background: #fff7eb;
}

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

.row-main strong,
.row-main small,
.row-meta {
    display: block;
    overflow-wrap: anywhere;
}

.row-main small,
.row-meta,
.muted {
    color: rgba(37, 36, 34, 0.66);
}

.row-meta {
    grid-column: 1 / -1;
    font-size: 13px;
}

.route-line {
    grid-column: 1 / -1;
    overflow: hidden;
    height: 6px;
    border-radius: 999px;
    background: rgba(79, 109, 122, 0.15);
}

.route-line i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--steel);
    transition: width 240ms ease;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
}

.status-queue {
    background: rgba(235, 94, 40, 0.13);
    color: var(--warn);
}

.status-planned {
    background: rgba(79, 109, 122, 0.15);
    color: #315363;
}

.status-training {
    background: rgba(95, 143, 123, 0.17);
    color: #285c47;
}

.status-progress {
    background: rgba(37, 36, 34, 0.1);
    color: var(--ink);
}

.status-complete {
    background: rgba(95, 143, 123, 0.25);
    color: #214f3d;
}

.goal-box {
    margin: 18px 0;
    padding: 16px;
    border-left: 4px solid var(--accent);
    background: var(--soft);
}

.goal-box span,
.route-grid span,
.mini-row span {
    color: rgba(37, 36, 34, 0.64);
}

.goal-box p {
    margin-bottom: 0;
    font-size: 19px;
    line-height: 1.48;
}

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

.route-grid div {
    min-width: 0;
    padding: 13px;
    border: 1px solid rgba(37, 36, 34, 0.12);
    border-radius: 8px;
    background: rgba(255, 252, 242, 0.68);
}

.route-grid span,
.route-grid strong {
    display: block;
    overflow-wrap: anywhere;
}

.lane {
    padding-top: 15px;
    border-top: 1px solid rgba(37, 36, 34, 0.12);
}

.lane + .lane {
    margin-top: 16px;
}

.mini-row {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(37, 36, 34, 0.08);
}

.mini-row b {
    text-align: right;
}

.next-action {
    min-height: 155px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(37, 36, 34, 0.12);
}

.action-stack {
    display: grid;
    gap: 9px;
    margin: 16px 0;
}

.notes p {
    margin: 0 0 10px;
}

.empty-state {
    padding: 18px;
    border-radius: 8px;
    background: rgba(79, 109, 122, 0.1);
    color: rgba(37, 36, 34, 0.72);
}

.empty-state.error {
    background: rgba(235, 94, 40, 0.12);
    color: var(--warn);
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.75fr) minmax(360px, 1fr);
    gap: 28px;
    max-width: 1080px;
}

.create-form {
    display: grid;
    gap: 14px;
    padding: 20px;
}

label {
    display: grid;
    gap: 6px;
    color: rgba(37, 36, 34, 0.72);
}

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

.form-status {
    min-height: 24px;
    margin-bottom: 0;
    color: var(--steel);
}

.table-view {
    max-width: 1180px;
}

.section-head {
    margin-bottom: 18px;
}

.data-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid rgba(37, 36, 34, 0.1);
    text-align: left;
    vertical-align: top;
}

th {
    color: rgba(37, 36, 34, 0.62);
    font-size: 12px;
    text-transform: uppercase;
}

.finance-totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 190px));
    gap: 10px;
    margin-bottom: 14px;
}

.finance-totals span {
    padding: 13px;
}

.finance-totals small,
.finance-totals strong {
    display: block;
}

.finance-totals strong {
    font-size: 22px;
}

.doc-missing,
.pay-overdue {
    color: var(--warn);
}

.doc-needs_review,
.pay-pending {
    color: #315363;
}

.doc-signed,
.pay-paid {
    color: #285c47;
}

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

    .topbar-metric {
        justify-self: start;
        text-align: left;
    }

    .board-view.is-active {
        grid-template-columns: 1fr;
    }

    .queue-panel,
    .record-panel,
    .action-panel {
        min-height: auto;
    }
}

@media (max-width: 680px) {
    .topbar,
    .workspace {
        padding: 12px;
    }

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

    .tab {
        width: 100%;
    }

    .summary-strip,
    .route-grid,
    .form-layout,
    .form-grid,
    .finance-totals {
        grid-template-columns: 1fr;
    }

    .record-head,
    .section-head {
        display: grid;
    }

    .mini-row {
        display: grid;
    }
}

