:root {
    --page: #f3f5f4;
    --surface: #ffffff;
    --surface-soft: #f7f8f7;
    --ink: #171918;
    --muted: #626763;
    --quiet: #8a8f8b;
    --line: #dfe3e0;
    --line-strong: #cbd0cc;
    --focus: #315f4b;
    --success: #17643f;
    --success-bg: #e9f5ee;
    --active: #155f75;
    --active-bg: #e8f4f7;
    --warning: #7a4d00;
    --warning-bg: #fff4d8;
    --danger: #8a2d2d;
    --danger-bg: #fbecec;
    --planned: #575e59;
    --planned-bg: #ecefed;
    --radius: 8px;
    --mono: 'DM Mono', monospace;
    --sans: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--page);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.topbar {
    border-bottom: 1px solid var(--line);
    background: rgba(243, 245, 244, 0.94);
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(12px);
}

.topbar__inner {
    width: min(1560px, calc(100% - 48px));
    min-height: 54px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.brand__mark { font-size: 24px; font-weight: 700; line-height: 1; }
.brand__client { font-weight: 700; }

.topbar__tools {
    display: flex;
    align-items: center;
    gap: 18px;
}

.topbar__home {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.topbar__home:hover { border-color: var(--line-strong); }

.topbar__meta {
    display: flex;
    gap: 10px;
    color: var(--quiet);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
}

.page-shell {
    width: min(1560px, calc(100% - 48px));
    margin: 0 auto;
    padding: 28px 0 72px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 32px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--quiet);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 32px; line-height: 1.08; font-weight: 700; }
h2 { margin-bottom: 0; font-size: 24px; line-height: 1.15; }
h3 { margin-bottom: 10px; font-size: 12px; text-transform: uppercase; }

.page-heading__subtitle { margin-bottom: 0; color: var(--muted); font-size: 15px; }

.updated-at { min-width: 130px; text-align: right; }
.updated-at span { display: block; color: var(--quiet); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.updated-at strong { display: block; margin-top: 2px; font-family: var(--mono); font-size: 12px; }

.section-nav {
    display: flex;
    gap: 3px;
    margin-bottom: 16px;
    padding: 3px;
    width: fit-content;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.section-nav a {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 15px;
    border-radius: 5px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.section-nav a.is-active { background: var(--ink); color: white; }

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.summary-strip > div {
    min-height: 70px;
    padding: 13px 16px;
    border-right: 1px solid var(--line);
}
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { display: block; color: var(--muted); font-size: 12px; }
.summary-strip strong { display: block; margin-top: 3px; font-family: var(--mono); font-size: 22px; }

.content-section { min-width: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 13px; }

.icon-command {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}
.icon-command:hover { border-color: var(--ink); }
.icon-command svg { width: 17px; height: 17px; }

.filters {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(170px, 220px) minmax(150px, 190px) minmax(150px, 190px) auto;
    gap: 8px;
    margin-bottom: 10px;
}

.filters input, .filters select, .clear-filters {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
}

.filters input { padding: 0 14px 0 40px; }
.filters select { padding: 0 34px 0 12px; }
.filters input::placeholder { color: var(--quiet); }

.search-field { position: relative; }
.search-field svg { position: absolute; left: 13px; top: 12px; width: 18px; height: 18px; color: var(--quiet); }

.clear-filters { width: auto; padding: 0 14px; font-weight: 600; cursor: pointer; }
.clear-filters:hover { border-color: var(--ink); }

.delivery-table-shell {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.delivery-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.delivery-table th {
    height: 38px;
    padding: 0 10px;
    background: #e9ecea;
    color: #727773;
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 500;
    text-align: left;
    text-transform: uppercase;
    vertical-align: middle;
}

.delivery-table th:nth-child(1) { width: 64px; }
.delivery-table th:nth-child(2) { width: 145px; }
.delivery-table th:nth-child(3) { width: 255px; }
.delivery-table th:nth-child(4) { width: 126px; }
.delivery-table th:nth-child(5) { width: 112px; }
.delivery-table th:nth-child(6) { width: 92px; }
.delivery-table th:nth-child(7) { width: 130px; }
.delivery-table th:nth-child(8) { width: auto; }
.delivery-table th:nth-child(9) { width: 54px; }

.delivery-table td {
    padding: 13px 10px;
    border-top: 1px solid var(--line);
    color: #464b47;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.delivery-table tbody tr { transition: background-color 150ms ease; }
.delivery-table tbody tr:hover { background: #fafbfa; }
.delivery-table tr[hidden] { display: none; }

.record-code { color: var(--ink); font-family: var(--mono); font-size: 11px; font-weight: 500; }
.workstream-name, .delivery-title { display: block; color: var(--ink); font-size: 13px; line-height: 1.35; }
.delivery-table td small { display: block; margin-top: 4px; color: var(--quiet); font-size: 11px; }
.delivery-table time { color: var(--ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
.next-step { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.scope-badge, .status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
}

.scope-badge { border: 1px solid var(--line-strong); background: var(--surface-soft); color: var(--muted); }
.scope-badge--additional { border-color: #cfb36e; color: #6b4a00; background: #fff9e9; }
.scope-badge--out_of_scope { border-color: #d9a7a7; color: var(--danger); background: var(--danger-bg); }
.scope-badge--review { border-style: dashed; }
.status-badge--done { color: var(--success); background: var(--success-bg); }
.status-badge--active { color: var(--active); background: var(--active-bg); }
.status-badge--attention { color: var(--warning); background: var(--warning-bg); }
.status-badge--blocked { color: var(--danger); background: var(--danger-bg); }
.status-badge--planned { color: var(--planned); background: var(--planned-bg); }

.row-action { text-align: right; }
.details-button {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}
.details-button:hover { border-color: var(--ink); }
.details-button svg { width: 17px; height: 17px; }
.details-button span { display: none; }

.empty-state, .system-message {
    padding: 48px 24px;
    text-align: center;
}
.empty-state strong, .empty-state span, .system-message strong, .system-message span { display: block; }
.empty-state span, .system-message span { margin-top: 5px; color: var(--muted); }

.document-list {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
.document-row {
    min-height: 76px;
    display: grid;
    grid-template-columns: 130px 1fr 24px;
    align-items: center;
    gap: 18px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
}
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: var(--surface-soft); }
.document-row__type { color: var(--quiet); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.document-row__content strong, .document-row__content small { display: block; }
.document-row__content small { margin-top: 3px; color: var(--muted); }
.document-row svg { width: 18px; height: 18px; }

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(11, 14, 12, 0.42);
}

.detail-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 90;
    width: min(540px, 100%);
    height: 100dvh;
    background: var(--surface);
    border-left: 1px solid var(--line-strong);
    overflow-y: auto;
    animation: drawer-in 180ms ease-out;
}

.detail-drawer[hidden], .drawer-backdrop[hidden] { display: none; }
body.has-drawer { overflow: hidden; }

@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer-header {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}
.drawer-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.drawer-content { padding: 28px 24px 56px; }
.drawer-content h2 { margin-bottom: 5px; font-size: 24px; }
.drawer-area { color: var(--muted); }
.drawer-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 26px; }
.drawer-section { padding: 22px 0; border-top: 1px solid var(--line); }
.drawer-section p { margin-bottom: 0; color: #424743; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    border-top: 1px solid var(--line);
}
.detail-grid > div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.detail-grid > div:nth-child(odd) { padding-right: 16px; }
.detail-grid > div:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
.detail-grid dt, .drawer-notes dt { color: var(--quiet); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.detail-grid dd, .drawer-notes dd { margin: 5px 0 0; color: var(--ink); font-weight: 600; }
.drawer-notes { margin: 0; }
.drawer-notes > div { padding: 11px 0; border-bottom: 1px solid var(--line); }
.drawer-notes > div:last-child { border-bottom: 0; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 18px 20px; }
.timeline li::before { content: ''; position: absolute; left: 2px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.timeline li::after { content: ''; position: absolute; left: 5px; top: 15px; bottom: 2px; width: 1px; background: var(--line-strong); }
.timeline li:last-child::after { display: none; }
.timeline time { color: var(--quiet); font-family: var(--mono); font-size: 9px; }
.timeline strong, .timeline span { display: block; }
.timeline strong { margin-top: 3px; }
.timeline span { margin-top: 3px; color: var(--muted); }

@media (max-width: 1100px) {
    .filters { grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(140px, 190px)); }
    .clear-filters { grid-column: 4; justify-self: end; }
    .delivery-table-shell { overflow-x: auto; }
    .delivery-table { min-width: 1180px; }
}

@media (max-width: 760px) {
    .topbar__inner, .page-shell { width: min(100% - 28px, 1560px); }
    .topbar__inner { min-height: 66px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; }
    .topbar__tools { width: 100%; justify-content: space-between; }
    .topbar__meta { font-size: 9px; }
    .page-shell { padding-top: 22px; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    h1 { font-size: 28px; }
    .updated-at { text-align: left; }
    .section-nav { width: 100%; }
    .section-nav a { flex: 1; justify-content: center; padding-inline: 8px; }
    .summary-strip { grid-template-columns: repeat(2, 1fr); }
    .summary-strip > div:nth-child(2) { border-right: 0; }
    .summary-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .filters { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .filters label:nth-child(4) { grid-column: 1 / -1; }
    .clear-filters { grid-column: 1 / -1; width: 100%; justify-self: stretch; }
    .delivery-table-shell { border: 0; background: transparent; overflow: visible; }
    .delivery-table, .delivery-table tbody { display: block; min-width: 0; }
    .delivery-table thead { display: none; }
    .delivery-table tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px 16px;
        margin-bottom: 9px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
    }
    .delivery-table td {
        display: block;
        padding: 0;
        border: 0;
    }
    .delivery-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--quiet);
        font-family: var(--mono);
        font-size: 8px;
        text-transform: uppercase;
    }
    .delivery-table td:nth-child(2), .delivery-table td:nth-child(3), .delivery-table td:nth-child(8), .delivery-table .row-action { grid-column: 1 / -1; }
    .delivery-table td:nth-child(1) { order: -4; }
    .delivery-table td:nth-child(5) { order: -3; text-align: right; }
    .delivery-table td:nth-child(2) { order: -2; }
    .delivery-table td:nth-child(3) { order: -1; }
    .delivery-table td:nth-child(5)::before { text-align: right; }
    .next-step { -webkit-line-clamp: 4; }
    .row-action { text-align: left; }
    .details-button { width: 100%; height: 38px; border-radius: 5px; gap: 8px; }
    .details-button span { display: inline; font-weight: 700; }
    .document-row { grid-template-columns: 1fr 20px; gap: 12px; }
    .document-row__type { grid-column: 1 / -1; }
    .document-row__content { grid-column: 1; }
    .detail-drawer { width: 100%; }
}

@media print {
    .topbar { position: static; }
    .section-nav, .filters, .print-command, .row-action, .drawer-backdrop, .detail-drawer { display: none; }
    body, .topbar { background: white; }
    .page-shell, .topbar__inner { width: 100%; }
    .summary-strip { break-inside: avoid; }
    .delivery-table { table-layout: auto; }
    .delivery-table th, .delivery-table td { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto; animation-duration: 0.01ms; animation-iteration-count: 1; transition-duration: 0.01ms; }
}
