:root {
    --ink: #252422;
    --paper: #fffcf2;
    --accent: #eb5e28;
    --steel: #4f6d7a;
    --green: #386641;
    --line: rgba(37, 36, 34, 0.14);
    --muted: #746f66;
    --white: #ffffff;
    --warn: #b85c38;
    --danger: #9d2d25;
    --shadow: 0 18px 46px rgba(37, 36, 34, 0.12);
}

* {
    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;
}

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

button {
    cursor: pointer;
}

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

.rail {
    display: flex;
    flex-direction: column;
    gap: 26px;
    min-height: 100vh;
    padding: 22px 17px;
    color: var(--paper);
    background:
        linear-gradient(180deg, rgba(79, 109, 122, 0.34), rgba(235, 94, 40, 0.16) 54%, rgba(37, 36, 34, 0)),
        var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    font-weight: 900;
    line-height: 0.94;
}

.brand img {
    flex: 0 0 auto;
}

.rail-nav {
    display: grid;
    gap: 8px;
}

.nav-button {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(255, 252, 242, 0.14);
    border-radius: 7px;
    padding: 10px 12px;
    text-align: left;
    color: rgba(255, 252, 242, 0.72);
    background: transparent;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-button:hover,
.nav-button.is-active {
    color: var(--paper);
    background: rgba(79, 109, 122, 0.42);
    transform: translateX(3px);
}

.rail-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 252, 242, 0.18);
    color: rgba(255, 252, 242, 0.64);
    font-size: 12px;
}

.rail-foot strong {
    color: #f5b48a;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.workspace {
    min-width: 0;
    padding: 24px;
    background:
        linear-gradient(90deg, rgba(79, 109, 122, 0.09), transparent 38%),
        repeating-linear-gradient(0deg, rgba(37, 36, 34, 0.025) 0 1px, transparent 1px 38px),
        var(--paper);
}

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

.eyebrow,
.sheet-kicker,
.section-head span {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    max-width: 760px;
    font-size: clamp(30px, 4vw, 56px);
    line-height: 0.99;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 14px;
    font-size: 25px;
    line-height: 1.08;
    letter-spacing: 0;
}

.control-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: min(100%, 520px);
}

.control-strip input,
.note-form input,
.note-form textarea,
.intake-board input,
.intake-board select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
}

.note-form textarea {
    min-height: 104px;
    resize: vertical;
    line-height: 1.45;
}

.accent-button,
.ghost-button {
    min-height: 42px;
    border-radius: 7px;
    padding: 10px 14px;
    white-space: nowrap;
}

.accent-button {
    border: 0;
    color: var(--paper);
    background: var(--accent);
    font-weight: 900;
}

.ghost-button {
    border: 1px solid var(--line);
    color: var(--ink);
    background: rgba(255, 255, 255, 0.62);
}

.metric-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.metric {
    min-height: 94px;
    border-left: 4px solid var(--steel);
    border-radius: 7px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 30px rgba(37, 36, 34, 0.06);
}

.metric span {
    display: block;
    min-height: 30px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

.metric strong {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 34px;
    line-height: 1;
}

.metric small {
    color: var(--muted);
    font-size: 13px;
}

.metric-alert {
    border-left-color: var(--accent);
}

.metric-good {
    border-left-color: var(--green);
}

.screen {
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.12fr) 330px;
    gap: 16px;
    align-items: stretch;
}

.is-hidden {
    display: none !important;
}

.queue-panel,
.record-panel,
.action-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: var(--shadow);
}

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

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

.section-head strong {
    color: var(--steel);
    font-size: 12px;
    text-align: right;
}

.workflow-map,
.case-stack,
.compact-list,
.deadline-board,
.finance-board,
.signal-list,
.timeline,
.report-grid,
.check-list,
.decision-box {
    display: grid;
    gap: 9px;
}

.workflow-step,
.case-card,
.finance-line {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 12px;
    text-align: left;
    color: var(--ink);
    background: rgba(255, 252, 242, 0.78);
    transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.workflow-step:hover,
.case-card:hover,
.finance-line:hover,
.workflow-step.is-active,
.case-card.is-selected {
    border-color: rgba(235, 94, 40, 0.55);
    background: #fff7ed;
    transform: translateY(-1px);
}

.workflow-step span,
.case-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 24px;
    margin-bottom: 7px;
    border-radius: 999px;
    color: var(--paper);
    background: var(--steel);
    font-size: 11px;
    font-weight: 900;
}

.workflow-step strong,
.case-card strong,
.finance-line strong,
.timeline-item strong,
.deadline-item strong,
.signal-item strong,
.report-tile strong {
    display: block;
    overflow-wrap: anywhere;
}

.workflow-step small,
.case-meta,
.case-foot,
.timeline-item small,
.deadline-item small,
.signal-item small,
.report-tile small,
.list-row small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.case-card {
    margin-top: 9px;
}

.case-card.high .case-code {
    background: var(--accent);
}

.case-card.watch .case-code {
    background: var(--warn);
}

.case-card.calm .case-code {
    background: var(--green);
}

.progress-line {
    display: block;
    width: 100%;
    height: 8px;
    margin: 12px 0 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(37, 36, 34, 0.1);
}

.progress-line i,
.risk-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--steel), var(--accent));
}

.case-foot,
.finance-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.case-foot em,
.finance-line em {
    color: var(--accent);
    font-style: normal;
    font-weight: 900;
}

dl {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 8px 12px;
    margin: 0 0 16px;
}

dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.38;
}

.risk-meter {
    position: relative;
    height: 42px;
    overflow: hidden;
    border-radius: 7px;
    background: rgba(37, 36, 34, 0.09);
}

.risk-meter strong {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    color: var(--ink);
    font-size: 20px;
}

.mitigation-box {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.mitigation-box span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.mitigation-box p {
    margin: 7px 0 0;
    line-height: 1.55;
}

.note-form {
    display: grid;
    gap: 12px;
    margin-bottom: 15px;
}

.note-form label,
.intake-board label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.timeline-item,
.deadline-item,
.signal-item,
.report-tile,
.list-row,
.route-output,
.decision-row {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 12px;
    background: rgba(255, 252, 242, 0.7);
}

.timeline-item span,
.deadline-item span,
.signal-item span,
.report-tile span,
.route-output span,
.decision-row span {
    display: block;
    margin-bottom: 5px;
    color: var(--steel);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.list-row,
.finance-line,
.decision-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.list-row span,
.finance-line span {
    min-width: 0;
}

.list-row b,
.finance-line b {
    display: block;
}

.list-row small,
.finance-line small {
    display: block;
    margin-top: 3px;
}

.chip {
    border-radius: 999px;
    padding: 6px 9px;
    color: var(--paper);
    background: var(--steel);
    font-size: 11px;
}

.deadline-item.risk {
    border-color: rgba(235, 94, 40, 0.44);
}

.deadline-item.ready {
    border-color: rgba(56, 102, 65, 0.38);
}

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

.check-list label {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    line-height: 1.35;
}

.route-output strong {
    display: block;
    margin: 4px 0;
    color: var(--accent);
    font-size: 44px;
    line-height: 1;
}

.finance-line {
    background: rgba(255, 255, 255, 0.7);
}

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

.report-tile strong {
    margin: 4px 0;
    font-size: 28px;
}

.muted {
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(420px, calc(100vw - 36px));
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--paper);
    background: var(--ink);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

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

    .screen {
        display: grid;
    }

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

    .topbar {
        display: grid;
        align-items: stretch;
    }
}

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

    .rail {
        min-height: auto;
        padding: 14px;
    }

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

    .workspace {
        padding: 16px;
    }

    .control-strip,
    .case-foot,
    .finance-line,
    .list-row,
    .decision-row {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-row,
    .report-grid,
    .intake-board {
        grid-template-columns: 1fr;
    }

    dl {
        grid-template-columns: 1fr;
    }
}
