:root {
    --ink: #202c39;
    --paper: #f4f1de;
    --blue: #3d5a80;
    --coral: #e07a5f;
    --green: #59745a;
    --line: rgba(32, 44, 57, 0.18);
    --muted: rgba(32, 44, 57, 0.68);
    --surface: #fffaf0;
}

* {
    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 {
    font: inherit;
}

button {
    cursor: pointer;
}

.shell {
    min-height: 100svh;
    background:
        linear-gradient(90deg, rgba(32, 44, 57, 0.08) 1px, transparent 1px),
        linear-gradient(180deg, rgba(32, 44, 57, 0.08) 1px, transparent 1px),
        var(--paper);
    background-size: 42px 42px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(16px, 3vw, 34px);
    border-bottom: 1px solid var(--line);
    background: rgba(244, 241, 222, 0.92);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 230px;
    color: var(--ink);
    text-decoration: none;
}

.brand img {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
}

.brand strong {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
    line-height: 1;
    letter-spacing: 0;
}

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

.view-tabs {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 240, 0.72);
}

.tab,
.segmented button {
    min-height: 36px;
    border: 0;
    color: var(--ink);
    background: transparent;
    padding: 0 13px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.segmented button:hover {
    transform: translateY(-1px);
}

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

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
    min-height: calc(100svh - 80px);
}

.dispatch {
    padding: clamp(18px, 3vw, 36px);
    border-right: 1px solid var(--line);
}

.dispatch-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--coral);
    font-weight: 800;
    font-size: 0.76rem;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    max-width: 760px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 4vw, 4.2rem);
    line-height: 0.98;
    font-weight: 700;
    letter-spacing: 0;
}

.metric-pill {
    min-width: 168px;
    padding: 12px 14px;
    color: var(--paper);
    background: var(--blue);
}

.metric-pill span,
.summary-strip span,
.item-meta,
.history-row span,
.workflow-step em,
.team-member span,
.mobile-task em {
    color: currentColor;
    opacity: 0.68;
    font-size: 0.78rem;
}

.metric-pill strong {
    display: block;
    margin-top: 4px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
    line-height: 1;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 28px 0 18px;
    border-top: 2px solid var(--ink);
    border-bottom: 1px solid var(--line);
}

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

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

.summary-strip span,
.summary-strip strong {
    display: block;
}

.summary-strip strong {
    margin-top: 4px;
    font-size: 1.7rem;
    line-height: 1;
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
    gap: 14px;
    margin: 0 0 18px;
}

.search {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.search input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 13px;
    color: var(--ink);
    background: rgba(255, 250, 240, 0.86);
    outline: none;
}

.search input:focus {
    border-color: var(--blue);
}

.segmented {
    display: flex;
    align-self: end;
    justify-content: flex-end;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line);
    overflow-x: auto;
}

.panel {
    display: none;
}

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

.route-board {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 18px;
}

.timeline {
    position: sticky;
    top: 104px;
    align-self: start;
    display: grid;
    gap: 8px;
}

.stop {
    position: relative;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 8px 10px;
    min-height: 68px;
    padding: 10px;
    border-left: 4px solid var(--blue);
    background: rgba(255, 250, 240, 0.68);
}

.stop-index {
    grid-row: span 2;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: var(--paper);
    background: var(--ink);
    font-weight: 800;
}

.stop strong {
    align-self: end;
    line-height: 1.1;
}

.stop em {
    color: var(--muted);
    font-size: 0.78rem;
    font-style: normal;
}

.stop-care {
    border-color: var(--green);
}

.stop-delivery {
    border-color: var(--coral);
}

.queue-list,
.history-list,
.workflow-grid,
.team-grid {
    display: grid;
    gap: 10px;
}

.queue-item {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(260px, 1fr) auto;
    gap: 14px;
    align-items: center;
    min-height: 92px;
    padding: 15px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 240, 0.82);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.queue-item:hover {
    transform: translateX(3px);
    border-color: rgba(61, 90, 128, 0.42);
    background: #fffaf0;
}

.item-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.stage-dot {
    width: 14px;
    height: 58px;
    flex: 0 0 14px;
    background: var(--blue);
}

.stage-care .stage-dot {
    background: var(--green);
}

.stage-delivery .stage-dot {
    background: var(--coral);
}

.stage-closed .stage-dot {
    background: var(--ink);
}

.item-title {
    font-weight: 800;
    line-height: 1.2;
}

.item-meta {
    margin-top: 5px;
}

.item-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.item-stats span {
    padding: 5px 7px;
    border: 1px solid var(--line);
    background: rgba(244, 241, 222, 0.65);
    font-size: 0.78rem;
    white-space: nowrap;
}

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

.item-actions button {
    min-height: 34px;
    border: 1px solid var(--ink);
    color: var(--ink);
    background: transparent;
    padding: 0 10px;
}

.item-actions button:hover {
    color: var(--paper);
    background: var(--ink);
}

.history-row,
.workflow-step,
.team-member {
    padding: 16px;
    border-left: 4px solid var(--blue);
    background: rgba(255, 250, 240, 0.78);
}

.history-row {
    display: grid;
    grid-template-columns: 130px minmax(190px, 1fr) 140px minmax(180px, 1.4fr);
    gap: 14px;
    align-items: start;
}

.history-row time,
.history-row p,
.team-member p,
.workflow-step p {
    margin: 0;
    color: var(--muted);
}

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

.workflow-step {
    min-height: 190px;
    border-left-color: var(--step-color);
}

.workflow-step span {
    display: block;
    width: 36px;
    height: 8px;
    margin-bottom: 22px;
    background: var(--step-color);
}

.workflow-step strong,
.team-member strong {
    display: block;
    font-size: 1.05rem;
}

.workflow-step p {
    margin-top: 18px;
    line-height: 1.45;
}

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

.team-member {
    display: grid;
    gap: 12px;
}

.team-member em {
    color: var(--coral);
    font-style: normal;
    font-weight: 800;
}

.load {
    height: 8px;
    background: rgba(32, 44, 57, 0.13);
}

.load span {
    display: block;
    height: 100%;
    background: var(--blue);
}

.field-console {
    padding: clamp(18px, 3vw, 34px);
    background: var(--ink);
}

.device {
    position: sticky;
    top: 110px;
    min-height: 680px;
    padding: 14px;
    color: var(--paper);
    border: 1px solid rgba(244, 241, 222, 0.22);
    background:
        linear-gradient(180deg, rgba(224, 122, 95, 0.18), transparent 34%),
        #17222d;
}

.device-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(244, 241, 222, 0.2);
}

.device-bar span {
    color: rgba(244, 241, 222, 0.7);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.mini-map {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-height: 270px;
    margin: 16px 0;
    padding: 10px;
    border: 1px solid rgba(244, 241, 222, 0.18);
    background:
        linear-gradient(90deg, rgba(244, 241, 222, 0.08) 1px, transparent 1px),
        linear-gradient(180deg, rgba(244, 241, 222, 0.08) 1px, transparent 1px);
    background-size: 28px 28px;
}

.zone {
    display: flex;
    min-height: 106px;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    border: 1px solid rgba(244, 241, 222, 0.2);
    background: rgba(61, 90, 128, 0.35);
}

.zone.is-urgent {
    background: rgba(224, 122, 95, 0.36);
}

.zone strong,
.zone span {
    position: relative;
    z-index: 1;
}

.mobile-feed {
    display: grid;
    gap: 9px;
}

.mobile-task {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 4px 10px;
    width: 100%;
    min-height: 66px;
    border: 1px solid rgba(244, 241, 222, 0.18);
    color: var(--paper);
    background: rgba(244, 241, 222, 0.06);
    padding: 10px;
    text-align: left;
}

.mobile-task strong {
    grid-row: span 2;
    color: var(--coral);
}

.mobile-task span {
    overflow-wrap: anywhere;
}

.empty {
    padding: 24px;
    border: 1px dashed var(--line);
    color: var(--muted);
    background: rgba(255, 250, 240, 0.64);
}

.empty.error {
    color: #9d2c14;
}

[hidden] {
    display: none !important;
}

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

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

    .dispatch {
        border-right: 0;
    }

    .field-console {
        padding-top: 0;
    }

    .device {
        min-height: 0;
        position: relative;
        top: auto;
    }

    .queue-item {
        grid-template-columns: 1fr;
    }

    .item-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 780px) {
    .topbar,
    .dispatch-head,
    .filters {
        display: grid;
    }

    .topbar {
        gap: 12px;
        position: relative;
    }

    .brand {
        min-width: 0;
    }

    .view-tabs,
    .segmented {
        justify-content: flex-start;
        width: 100%;
    }

    .workspace {
        min-height: auto;
    }

    .metric-pill {
        width: 100%;
    }

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

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

    .route-board {
        grid-template-columns: 1fr;
    }

    .timeline {
        position: relative;
        top: auto;
        grid-template-columns: repeat(5, minmax(126px, 1fr));
        overflow-x: auto;
    }

    .history-row,
    .workflow-grid,
    .team-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 460px) {
    .summary-strip {
        grid-template-columns: 1fr;
    }

    .summary-strip div {
        border-right: 0;
    }

    .tab,
    .segmented button {
        padding: 0 10px;
        font-size: 0.88rem;
    }

    h1 {
        font-size: 2rem;
    }
}

