:root {
    --ink: #202c39;
    --paper: #f4f1de;
    --blue: #3d5a80;
    --clay: #e07a5f;
    --leaf: #64895f;
    --line: rgba(32, 44, 57, 0.16);
    --muted: rgba(32, 44, 57, 0.68);
    --white: #fffdf6;
    --shadow: 0 22px 50px rgba(32, 44, 57, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(90deg, rgba(32, 44, 57, 0.05) 1px, transparent 1px) 0 0 / 38px 38px,
        linear-gradient(0deg, rgba(32, 44, 57, 0.04) 1px, transparent 1px) 0 0 / 38px 38px,
        var(--paper);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.rail {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 28px 22px;
    color: var(--paper);
    background:
        linear-gradient(180deg, rgba(61, 90, 128, 0.2), rgba(32, 44, 57, 0)),
        var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--paper);
    text-decoration: none;
}

.brand span,
h1,
h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
}

.brand span {
    font-size: 24px;
    line-height: 1;
}

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

.tab,
.filter,
.route-stop,
.queue-item,
.primary-action,
.secondary-action {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab {
    padding: 12px 14px;
    text-align: left;
    color: rgba(244, 241, 222, 0.74);
    background: transparent;
}

.tab:hover,
.tab.is-active {
    color: var(--paper);
    background: rgba(244, 241, 222, 0.12);
}

.rail-note {
    margin-top: auto;
    padding-top: 22px;
    border-top: 1px solid rgba(244, 241, 222, 0.18);
}

.note-kicker,
.eyebrow,
.item-code {
    display: block;
    color: var(--clay);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.rail-note strong {
    display: block;
    margin-top: 8px;
    font-size: 15px;
    line-height: 1.45;
}

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

.topline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
    gap: 22px;
    align-items: end;
}

.eyebrow {
    margin: 0 0 8px;
}

h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(34px, 5vw, 64px);
    line-height: 0.96;
    letter-spacing: 0;
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.74);
    box-shadow: var(--shadow);
}

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

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

.metric-strip span {
    display: block;
    color: var(--blue);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
}

.metric-strip small,
.queue-item span,
.forecast span,
.timeline small,
.workflow-step small,
.person-row span,
.person-row small {
    color: var(--muted);
}

.route-board {
    padding: 10px 0 4px;
}

.route-line {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    position: relative;
}

.route-line::before {
    position: absolute;
    top: 24px;
    right: 2%;
    left: 2%;
    height: 2px;
    background: var(--blue);
    opacity: 0.32;
    content: "";
}

.route-stop {
    position: relative;
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 14px;
    text-align: left;
    color: var(--ink);
    border: 1px solid var(--line);
    background: var(--white);
}

.route-stop:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stop-index {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: var(--paper);
    border-radius: 50%;
    background: var(--blue);
    font-size: 12px;
    font-weight: 800;
}

.route-stop strong,
.route-stop small {
    overflow-wrap: anywhere;
}

.screen {
    display: none;
    animation: liftIn 220ms ease both;
}

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

.queue-tools {
    display: grid;
    grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
}

.search-box {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.search-box input {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    outline: none;
}

.search-box input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.16);
}

.stage-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.filter {
    padding: 0 14px;
    color: var(--ink);
    border: 1px solid var(--line);
    background: rgba(255, 253, 246, 0.68);
}

.filter.is-active,
.filter:hover {
    color: var(--paper);
    border-color: var(--blue);
    background: var(--blue);
}

.field-console {
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
    gap: 16px;
    align-items: start;
}

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

.queue-item {
    display: grid;
    gap: 8px;
    width: 100%;
    padding: 14px;
    text-align: left;
    color: var(--ink);
    border: 1px solid var(--line);
    background: rgba(255, 253, 246, 0.75);
}

.queue-item:hover,
.queue-item.is-selected {
    transform: translateX(3px);
    border-color: rgba(224, 122, 95, 0.6);
    background: var(--white);
    box-shadow: var(--shadow);
}

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

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.item-meta small {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(61, 90, 128, 0.1);
}

.inspector {
    position: sticky;
    top: 18px;
    min-height: 520px;
    padding: 22px;
    border: 1px solid rgba(32, 44, 57, 0.2);
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
    box-shadow: var(--shadow);
}

.inspector-head h2 {
    margin: 8px 0 8px;
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1;
    letter-spacing: 0;
}

.inspector-head p,
.notes {
    color: rgba(244, 241, 222, 0.76);
    line-height: 1.55;
}

.mini-map {
    position: relative;
    min-height: 150px;
    margin: 18px 0;
    overflow: hidden;
    border: 1px solid rgba(244, 241, 222, 0.22);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(244, 241, 222, 0.1) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(0deg, rgba(244, 241, 222, 0.08) 1px, transparent 1px) 0 0 / 28px 28px,
        rgba(61, 90, 128, 0.26);
}

.mini-map strong {
    position: absolute;
    right: 14px;
    bottom: 12px;
}

.plot {
    position: absolute;
    display: block;
    border: 2px solid rgba(244, 241, 222, 0.72);
    border-radius: 8px;
    background: rgba(100, 137, 95, 0.6);
}

.plot-a {
    top: 22px;
    left: 24px;
    width: 36%;
    height: 62px;
}

.plot-b {
    right: 28px;
    top: 34px;
    width: 28%;
    height: 82px;
    background: rgba(224, 122, 95, 0.62);
}

.plot-c {
    left: 42%;
    bottom: 20px;
    width: 24%;
    height: 42px;
}

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

.forecast div {
    padding: 14px;
    border-radius: 8px;
    background: rgba(244, 241, 222, 0.1);
}

.forecast strong,
.forecast span {
    display: block;
}

.forecast strong {
    margin-top: 6px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 24px;
}

.progress-track {
    height: 10px;
    margin: 18px 0;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(244, 241, 222, 0.14);
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--clay), #f2cc8f);
    transition: width 260ms ease;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.primary-action,
.secondary-action {
    padding: 0 14px;
}

.primary-action {
    color: var(--ink);
    background: var(--clay);
}

.secondary-action {
    color: var(--paper);
    border: 1px solid rgba(244, 241, 222, 0.24);
    background: rgba(244, 241, 222, 0.08);
}

.primary-action:hover,
.secondary-action:hover {
    transform: translateY(-1px);
}

.section-heading {
    display: grid;
    gap: 6px;
    margin: 8px 0 16px;
}

.section-heading h2 {
    margin: 0;
    font-size: 36px;
    line-height: 1;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
}

.timeline,
.workflow-grid,
.team-grid {
    display: grid;
    gap: 10px;
}

.timeline-row,
.workflow-step,
.person-row {
    display: grid;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 246, 0.5);
}

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

.timeline-row time {
    color: var(--blue);
    font-weight: 800;
}

.timeline-row p,
.workflow-step p {
    margin: 6px 0;
    color: var(--muted);
    line-height: 1.45;
}

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

.workflow-step {
    min-height: 210px;
    align-content: start;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.workflow-step span {
    color: var(--clay);
    font-size: 12px;
    font-weight: 800;
}

.workflow-step h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 28px;
}

.person-row {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 240px) 90px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.person-row strong,
.person-row span {
    display: block;
}

meter {
    width: 100%;
    height: 12px;
}

.empty-state {
    padding: 20px;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.7);
}

.inspector .empty-state {
    color: rgba(244, 241, 222, 0.76);
    border-color: rgba(244, 241, 222, 0.22);
    background: rgba(244, 241, 222, 0.08);
}

.error-state {
    color: #9c2f20;
}

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

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

    .rail {
        position: sticky;
        top: 0;
        z-index: 5;
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 14px;
    }

    .tabs,
    .stage-filter {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tab,
    .filter {
        white-space: nowrap;
    }

    .rail-note {
        display: none;
    }

    .workspace {
        padding: 18px 14px 28px;
    }

    .topline,
    .queue-tools,
    .field-console {
        grid-template-columns: 1fr;
    }

    .stage-filter {
        justify-content: flex-start;
    }

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

    .inspector {
        position: static;
        min-height: 0;
    }
}

@media (max-width: 620px) {
    h1 {
        font-size: 40px;
    }

    .metric-strip,
    .route-line,
    .forecast,
    .workflow-grid,
    .timeline-row,
    .person-row {
        grid-template-columns: 1fr;
    }

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

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

    .route-line::before {
        display: none;
    }

    .section-heading h2 {
        font-size: 30px;
    }
}
