:root {
    --ink: #2b2d42;
    --paper: #edf2f4;
    --accent: #ef233c;
    --muted: #8d99ae;
    --line: rgba(43, 45, 66, 0.16);
    --surface: #ffffff;
    --rail: #191b2a;
    --ok: #2f9e73;
    --warn: #f2a541;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(43, 45, 66, 0.95), rgba(43, 45, 66, 0.72) 24%, rgba(237, 242, 244, 0.98) 24%),
        var(--paper);
    font-family: Inter, Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    width: 60px;
    min-height: 92px;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 8px;
    color: var(--paper);
    text-decoration: none;
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    line-height: 1.05;
    text-transform: uppercase;
}

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

.rail-button {
    width: 52px;
    height: 52px;
    border: 1px solid rgba(237, 242, 244, 0.2);
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.rail-button:hover,
.rail-button.is-active {
    color: var(--paper);
    border-color: var(--accent);
    background: rgba(239, 35, 60, 0.14);
    transform: translateY(-1px);
}

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

.topbar {
    min-height: 76px;
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.mono {
    margin: 0 0 7px;
    color: var(--muted);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(24px, 3vw, 42px);
    line-height: 1.02;
    max-width: 760px;
}

h2 {
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.08;
}

.sync-state {
    flex: 0 0 auto;
    padding: 9px 11px;
    border-radius: 8px;
    color: var(--paper);
    background: var(--ink);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    white-space: nowrap;
}

.sync-state[data-mode="ok"] {
    background: var(--ok);
}

.sync-state[data-mode="error"] {
    background: var(--accent);
}

.alert-strip {
    min-height: 48px;
    display: flex;
    align-items: stretch;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 0;
}

.alert-item,
.alert-ok,
.alert-error {
    min-width: min(360px, 80vw);
    border: 0;
    border-left: 4px solid var(--accent);
    background: var(--ink);
    color: var(--paper);
    border-radius: 8px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    text-align: left;
}

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

.alert-error {
    border-left-color: var(--warn);
}

.alert-item span,
.alert-item em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alert-item strong {
    color: var(--accent);
    text-transform: uppercase;
}

.alert-item em {
    color: var(--muted);
    font-style: normal;
}

.screen {
    display: none;
}

.screen.is-active {
    display: block;
    animation: rise 180ms ease both;
}

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

.canvas-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 18px;
    align-items: start;
}

.lane-map,
.inspector,
.import-panel,
.public-status,
.analytics-layout > section {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.lane-map {
    min-width: 0;
    overflow: hidden;
}

.map-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.filters {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filters input,
.filters select {
    height: 38px;
    max-width: 260px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    padding: 0 11px;
}

.route-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(164px, 1fr));
    gap: 1px;
    min-height: 570px;
    overflow-x: auto;
    background:
        linear-gradient(rgba(43, 45, 66, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(43, 45, 66, 0.06) 1px, transparent 1px);
    background-size: 26px 26px;
}

.route-column {
    min-width: 164px;
    padding: 10px;
    border-right: 1px solid var(--line);
}

.route-column header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 9px;
    padding: 8px;
    border-radius: 8px;
    color: var(--paper);
    background: var(--ink);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.route-column header b {
    color: var(--accent);
}

.task {
    width: 100%;
    min-height: 132px;
    margin: 0 0 9px;
    padding: 11px;
    border: 1px solid rgba(43, 45, 66, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--ink);
    display: grid;
    gap: 7px;
    text-align: left;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

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

.task strong {
    line-height: 1.18;
}

.task span,
.task i {
    min-width: 0;
    color: #5e6678;
    font-size: 13px;
    font-style: normal;
}

.task-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-transform: uppercase;
}

.task-top b {
    color: var(--accent);
}

.task-top em {
    color: var(--muted);
    font-style: normal;
}

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

.inspector-body {
    margin-top: 16px;
}

.inspector-body p {
    color: #555d6f;
    line-height: 1.5;
}

.facts {
    display: grid;
    gap: 8px;
    margin: 0;
}

.facts div {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

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

.facts dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.stepper {
    display: grid;
    gap: 7px;
    margin: 18px 0;
}

.stepper span {
    position: relative;
    min-height: 30px;
    padding: 7px 8px 7px 28px;
    border-radius: 8px;
    background: #e2e7eb;
    color: #596174;
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.stepper span::before {
    position: absolute;
    left: 9px;
    top: 50%;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--muted);
    transform: translateY(-50%);
    content: "";
}

.stepper .is-done {
    color: var(--paper);
    background: var(--ink);
}

.stepper .is-done::before {
    background: var(--accent);
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.actions button,
.danger-action {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    color: var(--paper);
    background: var(--ink);
    padding: 10px 12px;
}

.actions button:hover,
.danger-action:hover {
    background: var(--accent);
}

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

.analytics-layout > section,
.import-panel,
.public-status {
    padding: 16px;
}

.analytics-layout > section:first-child {
    grid-column: 1 / -1;
}

.metric-wall {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.metric {
    min-height: 136px;
    padding: 14px;
    border-left: 4px solid var(--accent);
    background: var(--ink);
    color: var(--paper);
    border-radius: 8px;
    display: grid;
    align-content: space-between;
}

.metric span,
.metric em {
    color: var(--muted);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    font-style: normal;
    text-transform: uppercase;
}

.metric strong {
    font-size: clamp(28px, 4vw, 52px);
    line-height: 1;
}

.zone-list,
.event-list,
.public-list {
    display: grid;
    gap: 9px;
    margin-top: 16px;
}

.zone-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) minmax(90px, 150px) 48px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.zone-row div:first-child {
    display: grid;
    gap: 3px;
}

.zone-row span,
.event-row span {
    color: var(--muted);
    font-size: 13px;
}

.bar {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #d9e0e6;
}

.bar i {
    display: block;
    height: 100%;
    background: var(--accent);
}

.event-row,
.public-row {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
}

.event-row time,
.public-row span {
    color: var(--accent);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.event-row div,
.public-row {
    min-width: 0;
}

.event-row strong,
.public-row strong {
    display: block;
    overflow-wrap: anywhere;
}

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

.import-panel p {
    max-width: 620px;
    color: #555d6f;
    line-height: 1.5;
}

.import-panel pre {
    min-height: 170px;
    margin: 18px 0 0;
    padding: 14px;
    overflow: auto;
    border-radius: 8px;
    color: var(--paper);
    background: var(--ink);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
}

.public-status {
    max-width: 920px;
}

.public-row {
    grid-template-columns: 160px minmax(0, 1fr) minmax(140px, 0.4fr);
}

.public-row em {
    color: var(--muted);
    font-style: normal;
    overflow-wrap: anywhere;
}

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

@media (max-width: 1050px) {
    body {
        background: var(--paper);
    }

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

    .inspector {
        position: static;
    }

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

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

    .rail {
        position: sticky;
        z-index: 5;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        padding: 10px;
        overflow-x: auto;
    }

    .brand {
        width: auto;
        min-height: 52px;
        grid-template-columns: 38px auto;
        align-items: center;
        justify-items: start;
    }

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

    .workspace {
        padding: 14px;
    }

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

    .sync-state {
        justify-self: start;
    }

    .filters {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .filters input,
    .filters select {
        max-width: none;
        width: 100%;
    }

    .route-board {
        grid-template-columns: repeat(5, minmax(220px, 1fr));
        min-height: 460px;
    }

    .metric-wall {
        grid-template-columns: 1fr;
    }

    .actions,
    .facts div,
    .zone-row,
    .event-row,
    .public-row {
        grid-template-columns: 1fr;
    }
}

