:root {
    --ink: #14213d;
    --paper: #ffffff;
    --line: rgba(20, 33, 61, 0.14);
    --muted: #697386;
    --action: #fca311;
    --fresh: #2a9d8f;
    --soft: #f5f6f8;
    --shadow: 0 18px 42px rgba(20, 33, 61, 0.12);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(90deg, rgba(20, 33, 61, 0.045) 1px, transparent 1px),
        linear-gradient(0deg, rgba(20, 33, 61, 0.045) 1px, transparent 1px),
        #ffffff;
    background-size: 28px 28px;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100svh;
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
}

.mobile-route {
    background: var(--ink);
    color: var(--paper);
    padding: 22px;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100svh;
    overflow: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand img {
    flex: 0 0 auto;
}

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

.brand span {
    display: block;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
    margin-top: 3px;
}

.nav-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.nav-tab {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 10px 9px;
    color: var(--paper);
    background: transparent;
    min-width: 0;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

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

.route-line {
    display: grid;
    gap: 14px;
    align-content: start;
    padding: 10px 0 4px;
}

.route-line span {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 12px;
    align-items: center;
    color: rgba(255, 255, 255, 0.56);
    text-transform: uppercase;
    font-size: 0.78rem;
}

.route-line span:before {
    content: "";
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.38);
    border-radius: 50%;
    background: var(--ink);
}

.route-line span.is-active {
    color: var(--paper);
}

.route-line span.is-active:before {
    border-color: var(--action);
    background: var(--action);
}

.field-card {
    align-self: end;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.08);
}

.field-card h2 {
    margin: 7px 0 16px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.35rem, 4vw, 2rem);
    line-height: 1.04;
}

.field-card dl {
    display: grid;
    gap: 10px;
    margin: 0 0 16px;
}

.field-card dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    padding-top: 10px;
}

.field-card dt {
    color: rgba(255, 255, 255, 0.62);
}

.field-card dd {
    margin: 0;
    text-align: right;
}

.dispatch-console {
    min-width: 0;
    padding: 24px;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 18px;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr minmax(280px, 480px);
    gap: 20px;
    align-items: end;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0;
    color: var(--fresh);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

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

h1 {
    max-width: 820px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 5vw, 4.9rem);
    line-height: 0.98;
}

h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.45rem, 2.6vw, 2.45rem);
    line-height: 1.05;
}

h3 {
    font-size: 0.95rem;
    text-transform: uppercase;
}

.searchbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 8px;
}

.searchbar input,
.searchbar select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: var(--paper);
    color: var(--ink);
    min-width: 0;
}

.metrics-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--ink);
    background: var(--paper);
}

.metrics-strip div {
    min-width: 0;
    padding: 15px;
    border-right: 1px solid var(--ink);
}

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

.metrics-strip span,
.metrics-strip em {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-style: normal;
}

.metrics-strip strong {
    display: block;
    margin: 5px 0 2px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
}

.view {
    display: none;
    min-width: 0;
}

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

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

.cabinet-grid {
    display: grid;
    grid-template-columns: minmax(250px, 380px) 1fr;
    gap: 18px;
    min-height: 0;
}

.order-list {
    display: grid;
    align-content: start;
    gap: 9px;
}

.order-row {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.84);
    padding: 13px;
    color: var(--ink);
    box-shadow: none;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.order-row:hover,
.order-row.is-active {
    transform: translateX(3px);
    border-color: var(--ink);
    box-shadow: var(--shadow);
}

.row-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.row-top strong,
.row-meta {
    min-width: 0;
}

.row-top strong {
    overflow-wrap: anywhere;
}

.row-top em,
.row-meta {
    color: var(--muted);
    font-size: 0.78rem;
    font-style: normal;
}

.row-meta {
    display: block;
    margin-top: 6px;
}

.row-progress {
    display: block;
    height: 5px;
    margin-top: 11px;
    background: var(--soft);
}

.row-progress i {
    display: block;
    height: 100%;
    background: var(--action);
}

.order-board,
.detail-block,
.timeline-item,
.report-table-wrap {
    border: 1px solid var(--ink);
    background: var(--paper);
}

.order-board {
    min-height: 520px;
    padding: clamp(18px, 3vw, 34px);
    box-shadow: var(--shadow);
}

.board-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.board-head h2 {
    margin-top: 7px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border-radius: 999px;
    padding: 7px 12px;
    white-space: nowrap;
    background: var(--soft);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 800;
}

.status-pill.in_route {
    background: var(--action);
}

.status-pill.done {
    background: var(--fresh);
    color: var(--paper);
}

.workflow-lane {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 28px 0;
}

.workflow-lane span {
    min-height: 76px;
    padding: 12px;
    border: 1px solid var(--line);
    display: grid;
    align-content: space-between;
    color: var(--muted);
}

.workflow-lane i {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--soft);
    color: var(--ink);
    font-style: normal;
    font-weight: 800;
}

.workflow-lane .is-done,
.workflow-lane .is-current {
    border-color: var(--ink);
    color: var(--ink);
}

.workflow-lane .is-current i {
    background: var(--action);
}

.board-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    background: var(--ink);
    border: 1px solid var(--ink);
}

.board-columns section {
    min-width: 0;
    padding: 18px;
    background: var(--paper);
}

.board-columns span,
.next-action span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.board-columns strong {
    display: block;
    margin: 8px 0 5px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.8rem;
    overflow-wrap: anywhere;
}

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

.next-action {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    margin: 28px 0 16px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.next-action strong {
    display: block;
    max-width: 700px;
    margin-top: 6px;
    font-size: 1.2rem;
    overflow-wrap: anywhere;
}

.accent-button,
.ghost-button {
    border: 1px solid var(--ink);
    border-radius: 8px;
    padding: 11px 14px;
    min-height: 42px;
    font-weight: 800;
}

.accent-button {
    background: var(--action);
    color: var(--ink);
}

.ghost-button {
    background: var(--paper);
    color: var(--ink);
}

.action-stack {
    display: grid;
    gap: 8px;
}

.action-stack div {
    display: grid;
    grid-template-columns: 120px 1fr 150px;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--line);
}

.action-stack span,
.action-stack em {
    color: var(--muted);
    font-size: 0.82rem;
    font-style: normal;
}

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

.section-head p {
    max-width: 620px;
    margin: 8px 0 0;
    color: var(--muted);
}

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

.detail-block {
    min-width: 0;
    padding: 16px;
}

.detail-block h3 {
    margin-bottom: 12px;
}

.detail-row {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}

.detail-row span,
.detail-row em {
    display: inline-block;
    color: var(--muted);
    font-size: 0.78rem;
    font-style: normal;
}

.detail-row em {
    margin-left: 8px;
    color: var(--fresh);
}

.detail-row em.warning,
.detail-row em.review {
    color: var(--action);
}

.detail-row em.blocked,
.detail-row em.missing {
    color: #c43c35;
}

.detail-row strong {
    display: block;
    margin: 6px 0;
}

.detail-row p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

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

.timeline-item {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 15px;
}

.timeline-item time {
    font-weight: 800;
}

.timeline-item span,
.timeline-item em {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-style: normal;
}

.timeline-item strong {
    display: block;
    margin: 4px 0;
}

.timeline-item b {
    border-radius: 999px;
    padding: 7px 10px;
    background: var(--soft);
    font-size: 0.78rem;
}

.timeline-item b.scheduled {
    background: var(--action);
}

.timeline-item b.done {
    background: var(--fresh);
    color: var(--paper);
}

.report-table-wrap {
    overflow: auto;
}

.report-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

.report-table th,
.report-table td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.report-table th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
}

.report-table td span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

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

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

    .mobile-route {
        position: relative;
        height: auto;
        min-height: auto;
    }

    .dispatch-console {
        padding: 16px;
    }

    .topbar,
    .cabinet-grid,
    .detail-columns {
        grid-template-columns: 1fr;
    }

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

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

    .metrics-strip div:nth-child(-n + 2) {
        border-bottom: 1px solid var(--ink);
    }
}

@media (max-width: 640px) {
    .mobile-route {
        padding: 16px;
    }

    .searchbar,
    .board-columns,
    .workflow-lane,
    .next-action,
    .action-stack div,
    .timeline-item {
        grid-template-columns: 1fr;
    }

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

    .metrics-strip div {
        border-right: 0;
        border-bottom: 1px solid var(--ink);
    }

    .metrics-strip div:last-child {
        border-bottom: 0;
    }

    .board-head,
    .section-head {
        display: grid;
    }

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

    .order-board {
        min-height: auto;
    }

    h1 {
        font-size: clamp(2rem, 13vw, 3.2rem);
    }
}

