:root {
    --ink: #2b2d42;
    --paper: #edf2f4;
    --muted: #8d99ae;
    --alert: #ef233c;
    --panel: #ffffff;
    --line: rgba(43, 45, 66, 0.14);
    --soft: rgba(141, 153, 174, 0.22);
    --shadow: 0 24px 70px rgba(43, 45, 66, 0.14);
}

* {
    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(43, 45, 66, 0.06) 1px, transparent 1px),
        linear-gradient(0deg, rgba(43, 45, 66, 0.05) 1px, transparent 1px),
        var(--paper);
    background-size: 44px 44px;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

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

.brand small,
.mono,
.eyebrow {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    letter-spacing: 0;
    text-transform: uppercase;
}

.brand small {
    margin-top: 2px;
    color: rgba(237, 242, 244, 0.62);
    font-size: 11px;
}

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

.tab,
.filter-chip,
.icon-button,
.primary-button,
.task-row,
.map-node {
    border: 0;
}

.tab {
    width: 100%;
    min-height: 42px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 7px;
    color: rgba(237, 242, 244, 0.75);
    background: transparent;
    text-align: left;
}

.tab span {
    color: var(--muted);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
}

.tab.is-active,
.tab:hover {
    color: var(--paper);
    background: rgba(237, 242, 244, 0.1);
}

.rail-block {
    margin-top: auto;
    padding: 14px;
    border: 1px solid rgba(237, 242, 244, 0.12);
    border-radius: 8px;
}

.rail-block strong {
    display: block;
    margin-top: 8px;
    color: var(--paper);
    overflow-wrap: anywhere;
}

.mono {
    color: var(--muted);
    font-size: 11px;
}

.rail-map {
    position: relative;
    height: 92px;
    border-radius: 8px;
    background:
        linear-gradient(90deg, transparent 0 46%, rgba(237, 242, 244, 0.15) 46% 54%, transparent 54%),
        linear-gradient(0deg, transparent 0 47%, rgba(237, 242, 244, 0.13) 47% 53%, transparent 53%),
        rgba(237, 242, 244, 0.05);
    overflow: hidden;
}

.rail-map i {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--alert);
}

.rail-map i:nth-child(1) { left: 22px; top: 18px; }
.rail-map i:nth-child(2) { right: 34px; top: 28px; background: var(--paper); }
.rail-map i:nth-child(3) { left: 62px; bottom: 18px; background: var(--muted); }
.rail-map i:nth-child(4) { right: 20px; bottom: 24px; }

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

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

.eyebrow {
    margin: 0 0 6px;
    color: rgba(43, 45, 66, 0.58);
    font-size: 11px;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 50px);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 6px;
    font-size: 19px;
    letter-spacing: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search-box {
    width: min(300px, 100%);
    display: grid;
    gap: 5px;
    color: rgba(43, 45, 66, 0.66);
    font-size: 12px;
}

.search-box input,
.dialog-form textarea {
    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.78);
}

.icon-button,
.primary-button {
    min-height: 42px;
    border-radius: 7px;
    padding: 0 14px;
    color: var(--paper);
    background: var(--ink);
}

.icon-button {
    width: 42px;
    padding: 0;
    font-size: 20px;
}

.primary-button {
    background: var(--alert);
    font-weight: 750;
}

.alert-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.74);
}

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

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

.alert-strip strong {
    display: block;
    margin-top: 3px;
    font-size: 25px;
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
    animation: viewIn 190ms ease-out both;
}

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

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

.canvas-head p,
.retention-panel p,
.import-panel p,
.status-layout p,
.selectedText {
    color: rgba(43, 45, 66, 0.68);
}

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

.filter-chip {
    min-height: 34px;
    border-radius: 999px;
    padding: 0 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.8);
}

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

.route-canvas {
    position: relative;
    min-height: 380px;
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(43, 45, 66, 0.18);
    background:
        linear-gradient(135deg, rgba(239, 35, 60, 0.11), transparent 34%),
        linear-gradient(90deg, rgba(43, 45, 66, 0.09) 1px, transparent 1px),
        linear-gradient(0deg, rgba(43, 45, 66, 0.08) 1px, transparent 1px),
        rgba(255, 255, 255, 0.78);
    background-size: auto, 36px 36px, 36px 36px, auto;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.lane {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    padding: 12px;
    border-left: 3px solid var(--muted);
    background: rgba(237, 242, 244, 0.76);
}

.lane-2,
.lane-3 {
    border-left-color: var(--alert);
}

.lane-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.lane-meter,
.line-track,
.capacity {
    height: 8px;
    display: block;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(43, 45, 66, 0.11);
}

.lane-meter i,
.line-track i,
.capacity i,
.dial-track i,
.map-node i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--alert);
}

.lane-items {
    display: grid;
    align-content: start;
    gap: 10px;
}

.map-node {
    position: relative;
    width: 100%;
    min-height: 116px;
    display: grid;
    gap: 6px;
    padding: 12px;
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    text-align: left;
    box-shadow: 0 10px 26px rgba(43, 45, 66, 0.1);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.map-node:hover,
.map-node.is-selected {
    transform: translateY(-3px);
    box-shadow: 0 18px 38px rgba(43, 45, 66, 0.18);
}

.map-node span,
.map-node small,
.task-row small {
    color: rgba(43, 45, 66, 0.62);
    font-size: 12px;
}

.map-node strong,
.map-node small {
    display: block;
    overflow-wrap: anywhere;
}

.map-node i {
    height: 6px;
    margin-top: 2px;
    background: var(--muted);
}

.priority-alert {
    outline: 2px solid rgba(239, 35, 60, 0.35);
}

.priority-alert i,
.priority-alert.capacity,
.priority-alert + .capacity i {
    background: var(--alert);
}

.operations-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    margin-top: 18px;
}

.task-board,
.inspector,
.retention-panel,
.lane-analytics,
.import-panel,
.status-layout {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
}

.task-board,
.inspector {
    padding: 16px;
}

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

.task-row {
    width: 100%;
    min-height: 70px;
    display: grid;
    grid-template-columns: 76px minmax(130px, 1.1fr) minmax(160px, 1.35fr) minmax(130px, 1fr) 76px;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--ink);
    background: rgba(237, 242, 244, 0.64);
    text-align: left;
}

.task-row:hover,
.task-row.is-selected {
    background: #fff;
    box-shadow: 0 12px 32px rgba(43, 45, 66, 0.11);
}

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

.row-priority {
    justify-self: start;
    border-radius: 999px;
    padding: 6px 8px;
    color: var(--ink);
    background: rgba(141, 153, 174, 0.3);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-transform: uppercase;
}

.row-priority.priority-alert {
    color: #fff;
    background: var(--alert);
    outline: 0;
}

.row-priority.priority-watch {
    background: rgba(239, 35, 60, 0.16);
}

.inspector {
    position: sticky;
    top: 24px;
    align-self: start;
}

.inspector h2 {
    margin-top: 8px;
    font-size: 26px;
}

.inspector p {
    color: rgba(43, 45, 66, 0.72);
    line-height: 1.45;
}

.inspector dl {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 9px 12px;
    margin: 18px 0 0;
}

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

.inspector dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.analytics-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
}

.retention-panel,
.lane-analytics,
.import-panel,
.status-layout {
    padding: 22px;
}

.retention-panel strong {
    display: block;
    margin: 18px 0 8px;
    font-size: clamp(58px, 11vw, 120px);
    line-height: 0.88;
    letter-spacing: 0;
}

.dial-track {
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--soft);
}

.analytics-line {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(120px, 2fr) 42px;
    align-items: center;
    gap: 14px;
    min-height: 62px;
    border-bottom: 1px solid var(--line);
}

.analytics-line:last-child {
    border-bottom: 0;
}

.analytics-line strong,
.analytics-line small {
    display: block;
}

.analytics-line small {
    color: var(--muted);
}

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

.import-panel pre {
    min-height: 150px;
    margin: 18px 0 0;
    padding: 14px;
    overflow: auto;
    border-radius: 8px;
    color: var(--paper);
    background: var(--ink);
    white-space: pre-wrap;
}

.status-layout {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 22px;
}

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

.timeline-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
    border-bottom: 0;
}

.timeline-item h3 {
    margin-bottom: 4px;
}

.timeline-item p {
    margin-bottom: 6px;
    color: rgba(43, 45, 66, 0.7);
}

.empty-state {
    padding: 22px;
    color: var(--muted);
    background: rgba(237, 242, 244, 0.7);
}

dialog {
    width: min(520px, calc(100vw - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 30px 80px rgba(43, 45, 66, 0.3);
}

dialog::backdrop {
    background: rgba(43, 45, 66, 0.54);
}

.dialog-form {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: #fff;
}

.dialog-form label {
    display: grid;
    gap: 8px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-actions button {
    min-height: 40px;
    border: 0;
    border-radius: 7px;
    padding: 0 14px;
}

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

    .side-rail {
        position: relative;
        height: auto;
        display: grid;
        grid-template-columns: minmax(180px, 1fr);
    }

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

    .tab {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .rail-block,
    .rail-map {
        display: none;
    }

    .topbar,
    .canvas-head {
        display: grid;
    }

    .toolbar,
    .filter-row {
        justify-content: flex-start;
    }

    .route-canvas {
        grid-template-columns: repeat(4, 220px);
    }

    .operations-grid,
    .analytics-layout,
    .status-layout {
        grid-template-columns: 1fr;
    }

    .inspector {
        position: static;
    }

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

    .task-row .capacity {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .workspace,
    .side-rail {
        padding: 16px;
    }

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

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

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

    h1 {
        font-size: 34px;
    }

    .route-canvas {
        min-height: 320px;
        padding: 12px;
    }

    .analytics-line {
        grid-template-columns: 1fr 52px;
    }

    .analytics-line .line-track {
        grid-column: 1 / -1;
    }
}

