:root {
    --ink: #17202a;
    --paper: #f7f3e8;
    --jade: #2f8f83;
    --sun: #f2b544;
    --mist: #d9d0be;
    --line: rgba(23, 32, 42, 0.16);
    --muted: rgba(23, 32, 42, 0.64);
    --white: #fffdf7;
    --danger: #a55233;
    --blue: #456990;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(23, 32, 42, 0.035) 1px, transparent 1px) 0 0 / 64px 64px,
        linear-gradient(0deg, rgba(23, 32, 42, 0.03) 1px, transparent 1px) 0 0 / 64px 64px,
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.shell {
    min-height: 100vh;
    padding: 18px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: rgba(247, 243, 232, 0.86);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 12px;
    z-index: 10;
}

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

.brand img {
    flex: 0 0 auto;
}

.brand strong {
    display: block;
    font-size: 17px;
    line-height: 1;
    text-transform: uppercase;
}

.brand small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.tab,
.primary-action,
.secondary-action,
.stop-action {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink);
    min-height: 38px;
    border-radius: 6px;
}

.tab {
    padding: 8px 12px;
    color: var(--muted);
}

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

.primary-action {
    padding: 9px 14px;
    background: var(--jade);
    border-color: var(--jade);
    color: white;
}

.secondary-action {
    width: 100%;
    padding: 9px 14px;
}

.screen {
    display: none;
    animation: rise 220ms ease-out;
}

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

.workspace {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr) 350px;
    gap: 14px;
    align-items: start;
    margin-top: 14px;
}

.rail,
.planner,
.inspector,
.analysis-layout,
.import-panel,
.public-status {
    border: 1px solid var(--line);
    background: rgba(255, 253, 247, 0.82);
}

.rail,
.inspector {
    position: sticky;
    top: 94px;
}

.rail {
    padding: 14px;
}

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

.metric-block span,
.filters label,
.compact-label,
.route-meta,
.eyebrow,
.proof-item small,
.stop-item small {
    color: var(--muted);
    font-size: 12px;
}

.metric-block strong {
    display: block;
    margin-top: 4px;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 1;
}

.filters {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.filters label,
.compact-label {
    display: grid;
    gap: 6px;
}

input,
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: var(--white);
    padding: 8px 10px;
}

.planner {
    min-height: calc(100vh - 116px);
}

.planner-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.planner-head p,
.eyebrow {
    margin: 0 0 4px;
    text-transform: uppercase;
}

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

h1,
h2,
h3,
h4 {
    letter-spacing: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 3.2vw, 46px);
    line-height: 0.98;
}

h2 {
    font-size: clamp(28px, 3vw, 42px);
    line-height: 1;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
}

.route-tile {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    min-height: 188px;
    background: rgba(255, 253, 247, 0.96);
    transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.route-tile:hover,
.route-tile.is-selected {
    transform: translateY(-2px);
    background: #fffaf0;
    box-shadow: inset 4px 0 0 var(--accent);
}

.route-time {
    padding: 16px 10px;
    color: var(--muted);
    border-right: 1px solid var(--line);
    font-weight: 700;
}

.route-main {
    display: grid;
    align-content: space-between;
    gap: 12px;
    min-width: 0;
    padding: 16px;
}

.route-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.route-title-row h3 {
    margin: 0;
    min-width: 0;
    font-size: 18px;
    line-height: 1.12;
}

.route-main p {
    margin: 6px 0 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.status {
    flex: 0 0 auto;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(47, 143, 131, 0.13);
    color: var(--jade);
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
}

.status-blocked {
    background: rgba(165, 82, 51, 0.14);
    color: var(--danger);
}

.status-done {
    background: rgba(69, 105, 144, 0.14);
    color: var(--blue);
}

.status-queued {
    background: rgba(242, 181, 68, 0.18);
    color: #7b5412;
}

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

.workflow-line span {
    min-height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.workflow-line span.is-active {
    color: var(--ink);
    background: rgba(242, 181, 68, 0.3);
    border-color: rgba(242, 181, 68, 0.7);
}

.route-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.route-meta span {
    padding-right: 8px;
    border-right: 1px solid var(--line);
}

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

.progress,
.inspector-progress {
    height: 8px;
    background: rgba(23, 32, 42, 0.09);
    overflow: hidden;
}

.progress span,
.inspector-progress span {
    display: block;
    height: 100%;
    background: var(--accent, var(--jade));
    transition: width 220ms ease;
}

.inspector {
    min-height: calc(100vh - 116px);
    padding: 16px;
}

.empty-state {
    display: grid;
    place-items: start;
    gap: 8px;
    min-height: 280px;
    align-content: center;
}

.empty-state p {
    color: var(--muted);
    line-height: 1.45;
}

.empty-state.error {
    color: var(--danger);
}

.cube-mark {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, var(--jade), var(--sun));
    clip-path: polygon(0 0, 78% 0, 100% 22%, 100% 100%, 0 100%);
}

.inspector-head {
    border-left: 5px solid var(--accent);
    padding-left: 12px;
}

.inspector-head span {
    color: var(--muted);
    font-weight: 700;
}

.inspector-head strong {
    display: block;
    margin-top: 8px;
    font-size: 21px;
    line-height: 1.1;
}

.inspector-head p {
    margin: 8px 0 0;
    color: var(--muted);
}

.inspector-progress {
    position: relative;
    margin: 16px 0;
}

.inspector-progress b {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 12px;
}

.inspector h4 {
    margin: 18px 0 8px;
    text-transform: uppercase;
    font-size: 12px;
}

.stop-list,
.proof-list {
    display: grid;
    gap: 8px;
}

.stop-item {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border: 1px solid var(--line);
    background: rgba(247, 243, 232, 0.55);
}

.stop-seq {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    background: var(--ink);
    color: var(--paper);
    font-size: 12px;
    border-radius: 50%;
}

.stop-item strong,
.stop-item small {
    display: block;
    overflow-wrap: anywhere;
}

.stop-done {
    opacity: 0.62;
}

.stop-blocked {
    border-color: rgba(165, 82, 51, 0.45);
}

.stop-action {
    width: 34px;
    height: 34px;
    padding: 0;
}

.stop-action:disabled {
    color: var(--jade);
    opacity: 0.7;
}

.proof-item {
    padding: 9px;
    border: 1px solid var(--line);
}

.proof-item span {
    color: var(--jade);
    font-size: 11px;
    text-transform: uppercase;
}

.proof-item p {
    margin: 4px 0;
    line-height: 1.35;
}

.proof-form {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.proof-form .primary-action {
    grid-column: 1 / -1;
}

.analysis-layout,
.import-panel,
.public-status {
    margin-top: 14px;
    padding: 22px;
}

.analysis-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 24px;
}

.lane-chart {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.chart-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 96px;
    gap: 10px;
    align-items: center;
}

.chart-row div {
    height: 28px;
    background: rgba(23, 32, 42, 0.08);
}

.chart-row b {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--jade), var(--sun));
}

.driver-row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    column-gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.driver-row span {
    width: 12px;
    height: 12px;
    margin-top: 4px;
    background: var(--accent);
}

.driver-row strong,
.driver-row small,
.driver-row em {
    grid-column: 2;
}

.driver-row small,
.driver-row em {
    color: var(--muted);
}

.driver-row em {
    font-style: normal;
}

.import-panel {
    max-width: 760px;
}

.import-panel p {
    color: var(--muted);
    line-height: 1.5;
}

pre {
    margin-top: 16px;
    padding: 14px;
    background: var(--ink);
    color: var(--paper);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.public-status {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
}

.public-status p {
    color: var(--muted);
    line-height: 1.5;
}

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

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

.public-route strong,
.public-route span {
    overflow-wrap: anywhere;
}

.public-route span {
    color: var(--muted);
}

.public-fields {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.public-fields small {
    padding: 5px 7px;
    background: rgba(47, 143, 131, 0.11);
}

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

.empty-list {
    min-height: 260px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: var(--white);
}

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

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .inspector {
        grid-column: 1 / -1;
        position: static;
        min-height: auto;
    }
}

@media (max-width: 820px) {
    .shell {
        padding: 10px;
    }

    .topbar,
    .workspace,
    .analysis-layout,
    .public-status {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
        position: static;
    }

    .tabs {
        justify-content: flex-start;
    }

    .rail {
        position: static;
    }

    .calendar-grid {
        grid-template-columns: 1fr;
    }

    .route-tile {
        grid-template-columns: 58px minmax(0, 1fr);
        min-height: 176px;
    }

    .planner-head {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 520px) {
    .brand {
        min-width: 0;
    }

    .tab {
        flex: 1 1 calc(50% - 6px);
        padding-inline: 8px;
    }

    .route-title-row,
    .public-route {
        display: grid;
    }

    .status {
        width: max-content;
    }

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

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

    .chart-row strong {
        grid-column: 2;
    }
}

