:root {
    --ink: #17202a;
    --paper: #f7f3e8;
    --green: #2f8f83;
    --amber: #f2b544;
    --line: rgba(23, 32, 42, 0.16);
    --muted: rgba(23, 32, 42, 0.62);
    --panel: #fffaf0;
    --blue: #3d6fb6;
    --violet: #8b5cf6;
    --danger: #b93f35;
}

* {
    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: 100%;
    margin: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(23, 32, 42, 0.055) 1px, transparent 1px),
        linear-gradient(180deg, rgba(23, 32, 42, 0.045) 1px, transparent 1px),
        var(--paper);
    background-size: 48px 48px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(210px, 1fr) auto minmax(160px, 1fr);
    align-items: center;
    gap: 18px;
    padding: 14px 22px;
    background: rgba(247, 243, 232, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

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

.brand strong {
    display: block;
    font-size: 18px;
    line-height: 1.05;
}

.brand small,
.sync-status,
.eyebrow,
.metric small,
.lane-meta small,
.inspector p,
.stop-row p,
.public-route p,
.public-route span,
.activity-feed small {
    color: var(--muted);
}

.brand small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    white-space: nowrap;
}

.tabs {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 240, 0.72);
    border-radius: 8px;
}

.tab {
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
}

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

.sync-status {
    justify-self: end;
    font-size: 13px;
}

.sync-status.is-ok {
    color: var(--green);
}

.sync-status.is-error {
    color: var(--danger);
}

main {
    padding: 22px;
}

.workspace {
    display: none;
}

.workspace.is-active {
    display: block;
    animation: rise 260ms ease-out both;
}

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

.planner-head,
.screen-title,
.import-panel,
.public-status > div:first-child {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin: 4px 0 18px;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(29px, 4vw, 54px);
    line-height: 0.95;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 14px;
    font-size: 18px;
}

.search-box {
    display: grid;
    gap: 6px;
    min-width: min(320px, 100%);
    color: var(--muted);
    font-size: 12px;
}

.search-box input,
.field-label select {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 240, 0.88);
    color: var(--ink);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
}

.metric {
    min-width: 0;
    padding: 16px;
    background: rgba(255, 250, 240, 0.88);
}

.metric span,
.metric small {
    display: block;
    font-size: 12px;
}

.metric strong {
    display: block;
    margin: 8px 0 5px;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1;
}

.planner-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
    gap: 18px;
    margin-top: 18px;
    align-items: start;
}

.calendar-board,
.inspector,
.chart-panel,
.feed-panel,
.import-panel,
.import-log,
.public-board {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 240, 0.8);
}

.calendar-board {
    overflow: hidden;
}

.time-ruler {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    padding: 12px 16px 10px 140px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.route-lanes {
    display: grid;
}

.route-lane {
    position: relative;
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    min-height: 86px;
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: inherit;
    text-align: left;
}

.route-lane:hover,
.route-lane.is-selected {
    background: rgba(47, 143, 131, 0.08);
}

.lane-meta {
    display: grid;
    align-content: center;
    gap: 4px;
    min-width: 0;
    padding-right: 12px;
}

.lane-track {
    position: relative;
    min-width: 0;
}

.lane-meta b,
.route-title,
.stop-top strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-block {
    position: absolute;
    top: 14px;
    bottom: 14px;
    display: grid;
    align-content: center;
    min-width: 132px;
    padding: 9px 12px;
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
    box-shadow: 0 10px 28px rgba(23, 32, 42, 0.16);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.route-lane:hover .route-block {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(23, 32, 42, 0.22);
}

.route-code,
.route-foot {
    font-size: 12px;
    opacity: 0.82;
}

.route-title {
    display: block;
    margin: 3px 0;
    font-weight: 760;
}

.inspector {
    position: sticky;
    top: 86px;
    max-height: calc(100vh - 110px);
    overflow: auto;
    padding: 16px;
}

.inspector-head {
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}

.inspector-head h2 {
    margin: 8px 0 4px;
    font-size: 31px;
    line-height: 1;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(47, 143, 131, 0.14);
    color: var(--green);
    font-size: 12px;
    font-weight: 760;
}

.progress-track {
    height: 8px;
    margin: 14px 0;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(23, 32, 42, 0.11);
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--amber));
}

.field-label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.secondary-action,
.primary-action,
.stop-top button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
    font-weight: 760;
}

.secondary-action {
    width: 100%;
    margin: 10px 0 16px;
}

.primary-action {
    padding: 0 18px;
    background: var(--green);
}

.stop-list {
    display: grid;
    gap: 10px;
}

.stop-row {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(247, 243, 232, 0.72);
}

.stop-top {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.stop-top span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--amber);
    font-weight: 800;
}

.stop-top button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 12px;
}

.stop-row p {
    margin: 8px 0;
    font-size: 13px;
}

.stop-row ul {
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.stop-row li {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
    font-size: 12px;
}

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

.chart-panel,
.feed-panel,
.public-board {
    padding: 18px;
}

.status-bars {
    display: grid;
    gap: 14px;
}

.bar-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) 36px;
    gap: 12px;
    align-items: center;
}

.bar-row div {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(23, 32, 42, 0.1);
}

.bar-row i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--green);
}

.activity-feed {
    display: grid;
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.activity-feed article {
    display: grid;
    gap: 4px;
    padding: 12px;
    background: rgba(247, 243, 232, 0.74);
}

.activity-feed span {
    color: var(--green);
    font-size: 12px;
    font-weight: 760;
}

.import-panel {
    padding: 22px;
}

.import-panel p {
    max-width: 680px;
    margin-bottom: 0;
    color: var(--muted);
}

.import-log {
    min-height: 130px;
    margin: 16px 0 0;
    padding: 16px;
    white-space: pre-wrap;
}

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

.public-route {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(247, 243, 232, 0.82);
}

.public-route strong,
.public-route span {
    display: block;
}

.public-route p {
    margin: 0;
    font-size: 13px;
}

.empty-state {
    padding: 18px;
    color: var(--muted);
}

@media (max-width: 980px) {
    .topbar,
    .planner-grid,
    .analytics-layout {
        grid-template-columns: 1fr;
    }

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

    .planner-head,
    .screen-title,
    .import-panel,
    .public-status > div:first-child {
        align-items: stretch;
        flex-direction: column;
    }

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

    .inspector {
        position: static;
        max-height: none;
    }
}

@media (max-width: 620px) {
    main,
    .topbar {
        padding: 14px;
    }

    .tabs {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: row;
    }

    .metrics,
    .public-board {
        grid-template-columns: 1fr;
    }

    .time-ruler {
        display: none;
    }

    .route-lane {
        grid-template-columns: 1fr;
        min-height: 148px;
    }

    .route-block {
        position: relative;
        left: 0 !important;
        top: auto;
        bottom: auto;
        width: 100% !important;
        margin-top: 10px;
    }

    .stop-top {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .stop-top button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .bar-row {
        grid-template-columns: 92px minmax(0, 1fr) 28px;
        font-size: 13px;
    }
}
