:root {
    --ink: #14213d;
    --paper: #ffffff;
    --line: #d9dee8;
    --muted: #647084;
    --soft: #f4f6f8;
    --action: #fca311;
    --control: #2a9d8f;
    --danger: #c2413b;
    --shadow: 0 18px 50px rgba(20, 33, 61, 0.12);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(20, 33, 61, 0.035) 1px, transparent 1px),
        linear-gradient(0deg, rgba(20, 33, 61, 0.035) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.rail {
    min-height: 100vh;
    padding: 24px;
    color: var(--paper);
    background: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
}

.brand {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
    align-items: center;
}

.brand strong {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 20px;
    line-height: 1.05;
    font-weight: 700;
}

.brand span,
.rail-note span,
.eyebrow,
.metric-label {
    color: rgba(255, 255, 255, 0.66);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

.nav-tab {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: var(--paper);
    text-align: left;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-tab:hover,
.nav-tab.is-active {
    background: var(--paper);
    color: var(--ink);
    transform: translateX(2px);
}

.rail-note {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.rail-note strong {
    display: block;
    margin-top: 8px;
    line-height: 1.35;
    color: var(--action);
}

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

.topbar,
.calendar-head,
.report-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
}

h1,
h2,
h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(34px, 5vw, 62px);
    line-height: 0.95;
}

h2 {
    font-size: 30px;
}

h3 {
    font-size: 21px;
}

p {
    line-height: 1.55;
}

.searchbar {
    display: grid;
    grid-template-columns: minmax(220px, 330px) 150px;
    gap: 10px;
}

.searchbar input,
.searchbar select,
.action-form input,
.action-form select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--ink);
    background: var(--paper);
}

.metrics-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--ink);
    background: var(--paper);
    margin-bottom: 22px;
}

.metrics-strip div {
    min-width: 0;
    padding: 16px;
    border-right: 1px solid var(--ink);
}

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

.metrics-strip span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.metrics-strip strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1;
}

.view {
    display: none;
    animation: rise 220ms ease both;
}

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

.dispatch-grid {
    display: grid;
    grid-template-columns: minmax(250px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

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

.case-row {
    display: grid;
    gap: 8px;
    width: 100%;
    min-height: 96px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--ink);
    background: rgba(255, 255, 255, 0.92);
    padding: 13px;
    text-align: left;
    border-radius: 6px;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.case-row:hover,
.case-row.is-active {
    border-color: var(--ink);
    border-left-color: var(--action);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.case-row strong,
.case-board-title strong {
    overflow-wrap: anywhere;
}

.case-row-meta,
.status-line,
.mini-grid,
.test-row,
.event-row,
.certificate-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--ink);
    font-size: 12px;
    white-space: nowrap;
}

.badge.action {
    background: var(--action);
}

.badge.control {
    background: var(--control);
    color: var(--paper);
}

.badge.danger {
    background: var(--danger);
    color: var(--paper);
}

.case-board {
    min-height: 560px;
    border: 1px solid var(--ink);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.case-board-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    padding: 24px;
    border-bottom: 1px solid var(--ink);
}

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

.case-board-title h2 {
    font-size: clamp(28px, 4.4vw, 54px);
    line-height: 0.98;
}

.risk-dial {
    width: 142px;
    aspect-ratio: 1;
    border: 1px solid var(--ink);
    border-radius: 50%;
    display: grid;
    place-items: center;
    background:
        conic-gradient(var(--action) var(--risk-angle), #eef1f5 0),
        var(--paper);
}

.risk-dial-inner {
    width: 98px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--paper);
    border: 1px solid var(--ink);
    display: grid;
    place-items: center;
    text-align: center;
}

.risk-dial-inner strong {
    font-size: 34px;
    line-height: 1;
}

.case-board-body {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr);
}

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

.lane-step {
    min-height: 124px;
    padding: 18px;
    border-right: 1px solid var(--line);
    display: grid;
    align-content: space-between;
    gap: 12px;
}

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

.lane-step span {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.lane-step strong {
    font-size: 18px;
    overflow-wrap: anywhere;
}

.forecast-panel,
.action-panel {
    padding: 22px;
}

.forecast-panel {
    border-right: 1px solid var(--line);
}

.forecast-bars {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.bar {
    display: grid;
    gap: 6px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.bar-track {
    height: 11px;
    background: var(--soft);
    border: 1px solid var(--line);
}

.bar-fill {
    height: 100%;
    width: var(--value);
    background: var(--ink);
}

.bar-fill.action {
    background: var(--action);
}

.bar-fill.control {
    background: var(--control);
}

.action-panel {
    display: grid;
    gap: 16px;
    align-content: start;
}

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

.accent-button,
.ghost-button {
    min-height: 42px;
    border-radius: 6px;
    padding: 9px 14px;
    border: 1px solid var(--ink);
}

.accent-button {
    background: var(--action);
    color: var(--ink);
    font-weight: 800;
}

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

.detail-layout,
.calendar-head,
.report-head {
    border-top: 2px solid var(--ink);
    padding-top: 20px;
}

.detail-layout > p,
.calendar-head p,
.report-head p,
.detail-layout > div > p {
    color: var(--muted);
    max-width: 740px;
}

.detail-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 22px;
}

.detail-block {
    border: 1px solid var(--line);
    background: var(--paper);
    padding: 18px;
    border-radius: 6px;
}

.detail-block h3 {
    margin-bottom: 14px;
}

.test-row,
.event-row,
.certificate-row {
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.test-row:first-of-type,
.event-row:first-of-type,
.certificate-row:first-of-type {
    border-top: 0;
}

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

.event-row {
    min-height: 72px;
    padding: 14px;
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 6px;
}

.event-row strong,
.event-row span {
    overflow-wrap: anywhere;
}

.report-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--ink);
    background: var(--paper);
}

.report-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
}

.report-table th,
.report-table td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.report-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
    background: var(--soft);
}

.empty-state {
    padding: 28px;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(380px, calc(100vw - 40px));
    padding: 12px 14px;
    color: var(--paper);
    background: var(--ink);
    border-left: 5px solid var(--action);
    box-shadow: var(--shadow);
    border-radius: 6px;
    animation: rise 180ms ease both;
    z-index: 20;
}

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

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

    .rail {
        min-height: auto;
        position: static;
        padding: 16px;
        gap: 16px;
    }

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

    .nav-tab {
        text-align: center;
        padding: 9px 8px;
    }

    .rail-note {
        display: none;
    }

    .workspace {
        padding: 18px;
    }

    .topbar,
    .calendar-head,
    .report-head {
        align-items: stretch;
        flex-direction: column;
    }

    .searchbar,
    .dispatch-grid,
    .case-board-body,
    .detail-columns {
        grid-template-columns: 1fr;
    }

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

    .metrics-strip div:nth-child(2) {
        border-right: 0;
    }

    .metrics-strip div:nth-child(-n + 2) {
        border-bottom: 1px solid var(--ink);
    }

    .case-board-head {
        grid-template-columns: 1fr;
    }

    .risk-dial {
        width: 118px;
    }

    .risk-dial-inner {
        width: 82px;
    }

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

    .lane-step:nth-child(2) {
        border-right: 0;
    }

    .lane-step:nth-child(-n + 2) {
        border-bottom: 1px solid var(--line);
    }

    .forecast-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 560px) {
    .nav-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metrics-strip,
    .workflow-lane {
        grid-template-columns: 1fr;
    }

    .metrics-strip div,
    .metrics-strip div:nth-child(2),
    .lane-step,
    .lane-step:nth-child(2) {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .metrics-strip div:last-child,
    .lane-step:last-child {
        border-bottom: 0;
    }

    .case-board-head,
    .forecast-panel,
    .action-panel {
        padding: 18px;
    }
}

