:root {
    --ink: #202c39;
    --paper: #f4f1de;
    --blue: #3d5a80;
    --coral: #e07a5f;
    --mint: #8ab17d;
    --line: rgba(32, 44, 57, 0.16);
    --muted: rgba(32, 44, 57, 0.62);
    --white: #fffdf6;
    --shadow: 0 18px 44px rgba(32, 44, 57, 0.13);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(61, 90, 128, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(32, 44, 57, 0.06) 1px, transparent 1px),
        var(--paper);
    background-size: 44px 44px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 25px;
    line-height: 1;
}

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

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

.nav__item {
    border: 0;
    border-radius: 8px;
    color: rgba(244, 241, 222, 0.78);
    background: transparent;
    padding: 12px 13px;
    text-align: left;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav__item:hover,
.nav__item.is-active {
    color: var(--paper);
    background: rgba(244, 241, 222, 0.12);
    transform: translateX(2px);
}

.rail__footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 9px;
    color: rgba(244, 241, 222, 0.76);
    font-size: 13px;
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 6px rgba(138, 177, 125, 0.18);
}

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

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 800;
}

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

h1 {
    margin-bottom: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(31px, 4vw, 54px);
    line-height: 0.98;
    letter-spacing: 0;
}

.topbar__tools {
    display: flex;
    gap: 10px;
    align-items: end;
}

.search {
    display: grid;
    gap: 6px;
    min-width: 260px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.search input,
.topbar select {
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.78);
    color: var(--ink);
    padding: 0 12px;
    outline: none;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.64);
    overflow: hidden;
    margin-bottom: 18px;
}

.metric {
    padding: 16px 18px;
    border-right: 1px solid var(--line);
    display: grid;
    gap: 4px;
}

.metric:last-child {
    border-right: 0;
}

.metric span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 34px;
    line-height: 1;
}

.metric--accent {
    background: var(--coral);
    color: var(--white);
}

.metric--accent span {
    color: rgba(255, 253, 246, 0.78);
}

.view {
    display: none;
}

.view--active {
    display: block;
    animation: lift 240ms ease both;
}

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

.dispatch-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(340px, 1.12fr) minmax(250px, 0.72fr);
    gap: 16px;
    align-items: start;
}

.queue-panel,
.route-panel,
.field-panel,
.wide-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.72);
    box-shadow: var(--shadow);
}

.queue-panel,
.route-panel,
.field-panel {
    min-height: 640px;
}

.section-heading {
    padding: 17px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.section-heading h2 {
    margin-bottom: 0;
    font-size: 18px;
}

.section-heading span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stage-strip {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    overflow-x: auto;
}

.stage-chip {
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    color: var(--ink);
    padding: 8px 10px;
    font-size: 12px;
}

.request-list {
    display: grid;
    gap: 10px;
    padding: 0 14px 16px;
}

.request {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.86);
    color: var(--ink);
    padding: 13px;
    display: grid;
    gap: 8px;
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.request:hover,
.request.is-selected {
    transform: translateY(-1px);
    border-color: rgba(224, 122, 95, 0.75);
    box-shadow: 0 10px 24px rgba(32, 44, 57, 0.12);
}

.request__top,
.request__meta,
.request__assignee {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

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

.request__meta,
.request__assignee {
    color: var(--muted);
    font-size: 12px;
}

.priority {
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-style: normal;
    background: rgba(61, 90, 128, 0.12);
}

.priority--critical {
    background: var(--coral);
    color: var(--white);
}

.priority--high {
    background: rgba(224, 122, 95, 0.22);
}

.compact-map {
    position: relative;
    height: 245px;
    margin: 18px;
    border: 1px solid rgba(61, 90, 128, 0.28);
    border-radius: 8px;
    overflow: hidden;
    background:
        radial-gradient(circle at 24% 34%, rgba(224, 122, 95, 0.18), transparent 18%),
        radial-gradient(circle at 74% 56%, rgba(138, 177, 125, 0.18), transparent 20%),
        linear-gradient(135deg, rgba(61, 90, 128, 0.16), rgba(255, 253, 246, 0.65)),
        repeating-linear-gradient(45deg, rgba(32, 44, 57, 0.08) 0 1px, transparent 1px 18px);
}

.map-node {
    position: absolute;
    z-index: 2;
    width: 18px;
    height: 18px;
    border: 4px solid var(--white);
    border-radius: 50%;
    background: var(--coral);
    box-shadow: 0 8px 18px rgba(32, 44, 57, 0.18);
    transition: transform 260ms ease;
}

.map-node--one {
    left: 22%;
    top: 34%;
}

.map-node--two {
    left: 48%;
    top: 58%;
    background: var(--blue);
}

.map-node--three {
    left: 72%;
    top: 38%;
    background: var(--mint);
}

.map-line {
    position: absolute;
    left: 25%;
    top: 45%;
    width: 54%;
    height: 3px;
    background: var(--ink);
    transform: rotate(7deg);
    opacity: 0.42;
}

.map-label {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(32, 44, 57, 0.86);
    color: var(--paper);
    font-size: 13px;
}

.timeline {
    padding: 0 20px 16px;
}

.timeline__stop {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 12px;
    position: relative;
    padding: 0 0 18px;
}

.timeline__stop::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 16px;
    bottom: 0;
    width: 2px;
    background: var(--line);
}

.timeline__stop:last-child::before {
    display: none;
}

.timeline__stop > span {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--white);
}

.timeline__stop.is-done > span {
    background: var(--blue);
    border-color: var(--blue);
}

.timeline__stop strong {
    display: block;
    margin-bottom: 3px;
}

.timeline__stop p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.38;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 18px 18px;
}

.primary,
.secondary {
    min-height: 44px;
    border-radius: 8px;
    padding: 0 14px;
    font-weight: 800;
}

.primary {
    border: 0;
    background: var(--ink);
    color: var(--paper);
}

.secondary {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink);
}

.field-panel {
    display: grid;
    place-items: center;
    padding: 20px;
    background: var(--blue);
}

.phone-shell {
    width: min(100%, 285px);
    min-height: 520px;
    border: 9px solid #16212c;
    border-radius: 30px;
    background: var(--paper);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.phone-top,
.phone-checks {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.phone-top strong {
    color: var(--coral);
}

.phone-route {
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.phone-route span {
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.phone-route h3 {
    margin: 9px 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 28px;
    line-height: 1.03;
}

.phone-route p {
    color: var(--muted);
    line-height: 1.42;
}

.phone-checks {
    margin-top: auto;
    display: grid;
}

.wide-panel {
    min-height: 520px;
}

.history-list,
.workflow-grid,
.team-grid {
    padding: 18px;
}

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

.history-row {
    display: grid;
    grid-template-columns: 170px 180px minmax(0, 1fr);
    gap: 14px;
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
    align-items: baseline;
}

.history-row time,
.history-row span {
    color: var(--muted);
}

.workflow-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.workflow-step {
    border-left: 4px solid var(--coral);
    background: rgba(255, 253, 246, 0.72);
    padding: 15px;
}

.workflow-step span {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--paper);
    font-weight: 900;
}

.workflow-step h3 {
    margin: 14px 0 7px;
}

.workflow-step p {
    color: var(--muted);
    line-height: 1.42;
}

.workflow-step strong {
    color: var(--blue);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.team-person {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--white);
}

.team-person div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.team-person span,
.team-person p {
    color: var(--muted);
}

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

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

.empty--error {
    color: #a33a22;
}

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

    .field-panel {
        grid-column: 1 / -1;
        min-height: auto;
    }

    .phone-shell {
        min-height: 330px;
    }

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

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

    .rail {
        position: static;
        height: auto;
        padding: 14px;
        gap: 14px;
    }

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

    .nav__item {
        text-align: center;
        padding: 10px 6px;
        font-size: 13px;
    }

    .rail__footer {
        display: none;
    }

    .workspace {
        padding: 16px;
    }

    .topbar,
    .topbar__tools {
        display: grid;
        align-items: stretch;
    }

    .search {
        min-width: 0;
    }

    .metrics,
    .dispatch-grid,
    .workflow-grid,
    .team-grid {
        grid-template-columns: 1fr;
    }

    .metric {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .metric:last-child {
        border-bottom: 0;
    }

    .queue-panel,
    .route-panel,
    .field-panel {
        min-height: auto;
    }

    .history-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }

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

@media (max-width: 480px) {
    .brand {
        font-size: 21px;
    }

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

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

    h1 {
        font-size: 32px;
    }

    .section-heading,
    .request__top,
    .request__meta,
    .request__assignee,
    .team-person div {
        display: grid;
    }
}

