:root {
    --ink: #2b2d42;
    --paper: #edf2f4;
    --accent: #ef233c;
    --muted: #8d99ae;
    --line: rgba(43, 45, 66, 0.16);
    --surface: #ffffff;
    --soft: #f7f9fb;
    --green: #1b998b;
    --yellow: #ffb703;
    --shadow: 0 24px 70px rgba(43, 45, 66, 0.13);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(43, 45, 66, 0.05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(43, 45, 66, 0.05) 1px, transparent 1px),
        var(--paper);
    background-size: 32px 32px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.side-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 20px;
    color: var(--paper);
    background: var(--ink);
    border-right: 4px solid var(--accent);
}

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

.brand img {
    width: 48px;
    height: 48px;
}

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

.brand strong {
    font-size: 18px;
    line-height: 1.1;
}

.brand small {
    color: rgba(237, 242, 244, 0.68);
}

.mono,
.eyebrow,
.search-box span,
.tab span {
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 12px 10px;
    color: rgba(237, 242, 244, 0.76);
    background: transparent;
    border: 1px solid rgba(237, 242, 244, 0.14);
    border-radius: 8px;
    text-align: left;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
    color: var(--paper);
    background: rgba(237, 242, 244, 0.12);
    transform: translateX(2px);
}

.tab span {
    color: var(--accent);
}

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

.rail-block + .rail-block {
    margin-top: 0;
}

.rail-block strong {
    display: block;
    margin-top: 8px;
    overflow-wrap: anywhere;
}

.horizon-mini {
    display: grid;
    gap: 4px;
}

.horizon-mini i {
    display: block;
    height: 5px;
    background: var(--paper);
}

.horizon-mini i:nth-child(2) {
    width: 74%;
    background: var(--muted);
}

.horizon-mini i:nth-child(3) {
    width: 92%;
    background: var(--accent);
}

.horizon-mini i:nth-child(4) {
    width: 50%;
    background: rgba(237, 242, 244, 0.68);
}

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

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 0 18px;
}

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

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

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 5vw, 64px);
    line-height: 0.95;
}

h2 {
    margin-bottom: 6px;
    font-size: 22px;
    line-height: 1.1;
}

h3 {
    margin-bottom: 6px;
    font-size: 15px;
}

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

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

.search-box {
    display: grid;
    gap: 5px;
}

.search-box input,
textarea {
    width: min(280px, 100%);
    min-height: 42px;
    padding: 10px 12px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
}

.search-box input:focus,
textarea:focus {
    border-color: var(--accent);
}

.icon-button,
.primary-button,
.filter-chip {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.icon-button {
    width: 42px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
}

.primary-button {
    padding: 0 16px;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 12px 30px rgba(239, 35, 60, 0.22);
}

.icon-button:hover,
.primary-button:hover,
.filter-chip:hover {
    transform: translateY(-1px);
}

.alert-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.alert-strip div {
    min-width: 0;
    padding: 16px;
    border-right: 1px solid rgba(237, 242, 244, 0.12);
}

.alert-strip div:last-child {
    background: var(--accent);
    border-right: 0;
}

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

.app-notice {
    margin: -6px 0 18px;
    padding: 10px 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.82);
    border-left: 4px solid var(--green);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(43, 45, 66, 0.07);
}

.app-notice.is-error {
    color: #8d1322;
    border-left-color: var(--accent);
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
    animation: rise 220ms ease both;
}

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

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

.canvas-head p,
.section-head p {
    margin-bottom: 0;
}

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

.filter-chip {
    padding: 0 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.filter-chip.is-active {
    color: #fff;
    background: var(--ink);
}

.service-map {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.lane {
    min-height: 270px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

.lane-meter,
.dial-track,
.line-track,
.capacity {
    display: block;
    width: 100%;
    height: 8px;
    overflow: hidden;
    background: rgba(141, 153, 174, 0.22);
    border-radius: 999px;
}

.lane-meter i,
.dial-track i,
.line-track i,
.capacity i {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 280ms ease;
}

.lane-items {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.map-node {
    display: grid;
    gap: 7px;
    width: 100%;
    padding: 10px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--muted);
    border-radius: 8px;
    text-align: left;
    box-shadow: 0 10px 25px rgba(43, 45, 66, 0.07);
}

.map-node strong,
.map-node span {
    overflow-wrap: anywhere;
}

.map-node:hover {
    transform: translateY(-2px);
}

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

.priority-watch {
    border-left-color: var(--yellow);
}

.priority-clear {
    border-left-color: var(--green);
}

.operations-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 14px;
    align-items: start;
}

.task-board,
.inspector,
.retention-panel,
.import-panel,
.status-layout > div,
.timeline {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(43, 45, 66, 0.08);
}

.task-board,
.inspector,
.retention-panel,
.import-panel,
.status-layout > div,
.timeline {
    padding: 16px;
}

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

.task-row {
    display: grid;
    grid-template-columns: 74px minmax(120px, 1fr) minmax(170px, 1.4fr) minmax(110px, 0.8fr) 90px;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 11px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: left;
}

.task-row:hover,
.task-row.is-selected {
    border-color: var(--accent);
    box-shadow: 0 12px 28px rgba(43, 45, 66, 0.1);
}

.task-row small {
    margin-top: 3px;
    color: rgba(43, 45, 66, 0.64);
}

.row-priority {
    min-width: 0;
    padding: 5px 7px;
    color: var(--ink);
    border-radius: 6px;
    background: rgba(141, 153, 174, 0.18);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

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

.row-priority.priority-watch {
    background: rgba(255, 183, 3, 0.35);
}

.row-priority.priority-clear {
    background: rgba(27, 153, 139, 0.18);
}

.inspector {
    position: sticky;
    top: 18px;
}

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

.inspector dt {
    color: var(--muted);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-transform: uppercase;
}

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

.analytics-layout,
.status-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
    gap: 14px;
}

.retention-panel strong {
    display: block;
    margin: 18px 0 12px;
    font-size: clamp(54px, 12vw, 132px);
    line-height: 0.9;
}

.lane-analytics {
    display: grid;
    gap: 10px;
}

.analytics-line {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) minmax(140px, 1fr) 36px;
    gap: 12px;
    align-items: center;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

.analytics-line small {
    margin-top: 3px;
    color: var(--muted);
}

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

pre {
    min-height: 130px;
    max-width: 100%;
    padding: 14px;
    overflow: auto;
    color: var(--paper);
    background: var(--ink);
    border-radius: 8px;
    white-space: pre-wrap;
}

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

.timeline-item {
    padding-left: 12px;
    border-left: 4px solid var(--accent);
}

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

.timeline-item small {
    color: var(--muted);
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 8px;
}

dialog {
    width: min(520px, calc(100% - 28px));
    border: 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

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

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

.dialog-form textarea {
    width: 100%;
    resize: vertical;
}

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

.dialog-actions button:not(.primary-button) {
    min-height: 42px;
    padding: 0 14px;
    color: var(--ink);
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

    .side-rail {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: 1fr;
        border-right: 0;
        border-bottom: 4px solid var(--accent);
    }

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

    .rail-block {
        margin-top: 0;
    }

    .topbar,
    .canvas-head,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

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

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

    .inspector {
        position: static;
    }
}

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

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

    .alert-strip {
        grid-template-columns: 1fr 1fr;
    }

    .service-map {
        grid-template-columns: minmax(230px, 1fr);
    }

    .task-row {
        grid-template-columns: 1fr;
    }

    .capacity {
        width: 100%;
    }

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