:root {
    --ink: #14213d;
    --paper: #ffffff;
    --signal: #fca311;
    --mint: #2a9d8f;
    --line: rgba(20, 33, 61, 0.16);
    --muted: rgba(20, 33, 61, 0.66);
    --soft: #f4f6f7;
    --danger: #b44336;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--ink);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(90deg, rgba(20, 33, 61, 0.04) 1px, transparent 1px),
        linear-gradient(0deg, rgba(20, 33, 61, 0.04) 1px, transparent 1px),
        var(--paper);
    background-size: 42px 42px;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.side-rail {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-height: 100vh;
    padding: 26px 22px;
    background: var(--ink);
    color: var(--paper);
}

.brand {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

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

.brand strong,
.topbar h1,
.section-head h2,
.inspector h2,
.detail-surface h2,
.report-surface h2,
.dialog-form h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
    letter-spacing: 0;
}

.brand strong {
    display: block;
    font-size: 25px;
    line-height: 1;
}

.brand small,
.metric small,
.request-row small,
.calendar-slot small,
.contractor p,
.section-head p,
.detail-surface p,
.report-surface p {
    color: var(--muted);
}

.side-rail .brand small,
.rail-status .mono {
    color: rgba(255, 255, 255, 0.68);
}

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

.tab,
.stage-filter button,
.icon-button,
.primary-button,
.dialog-actions button {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.tab {
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    text-align: left;
}

.tab:hover,
.tab.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--paper);
}

.rail-status {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.rail-status strong {
    display: block;
    margin-top: 6px;
    color: var(--signal);
}

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

.topbar,
.section-head,
.metric-strip,
.work-grid,
.detail-surface,
.report-surface {
    width: min(100%, 1320px);
    margin-inline: auto;
}

.topbar {
    display: flex;
    gap: 18px;
    align-items: flex-end;
    justify-content: space-between;
    min-height: 78px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--ink);
}

.eyebrow,
.mono {
    margin: 0;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.eyebrow {
    color: var(--mint);
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: 44px;
    line-height: 0.96;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    justify-content: flex-end;
}

.search-box {
    display: grid;
    gap: 5px;
    width: min(310px, 100%);
}

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

.icon-button {
    width: 42px;
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
    font-size: 22px;
}

.primary-button {
    padding: 0 18px;
    background: var(--signal);
    color: var(--ink);
    border-color: var(--signal);
    font-weight: 800;
}

.icon-button:hover,
.primary-button:hover,
.stage-filter button:hover,
.lane:hover,
.request-row:hover {
    transform: translateY(-1px);
}

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

.metric {
    min-height: 128px;
    padding: 18px;
    background: var(--paper);
}

.metric strong {
    display: block;
    margin-top: 12px;
    font-size: 36px;
    line-height: 1;
}

.metric-accent {
    background: var(--signal);
}

.metric-alert strong {
    color: var(--danger);
}

.view {
    display: none;
    animation: riseIn 260ms ease both;
}

.view.is-visible {
    display: block;
}

.command-board,
.detail-surface,
.report-surface {
    margin-top: 22px;
}

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

.section-head.compact {
    align-items: center;
}

.section-head h2,
.detail-surface h2,
.report-surface h2 {
    margin: 0;
    font-size: 28px;
    line-height: 1.05;
}

.section-head p,
.detail-surface p,
.report-surface p {
    margin: 6px 0 0;
}

.lane-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.lane {
    display: grid;
    gap: 9px;
    min-height: 154px;
    padding: 16px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    text-align: left;
}

.lane strong {
    font-size: 22px;
}

.lane small {
    color: var(--muted);
}

.lane b {
    justify-self: end;
    font-size: 24px;
}

.progress {
    display: block;
    height: 8px;
    overflow: hidden;
    background: rgba(20, 33, 61, 0.12);
}

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

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

.table-zone,
.inspector,
.detail-surface,
.report-surface {
    border-top: 2px solid var(--ink);
    padding-top: 16px;
}

.stage-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-end;
}

.stage-filter button {
    padding: 0 12px;
    background: var(--paper);
    border-color: var(--line);
    color: var(--ink);
}

.stage-filter button.is-active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

.request-table {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.request-row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 132px 62px;
    gap: 12px;
    align-items: center;
    min-height: 76px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 4px solid transparent;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    text-align: left;
}

.request-row.is-active {
    border-left-color: var(--signal);
    background: #fffaf0;
}

.request-row strong {
    display: block;
    overflow-wrap: anywhere;
}

.request-row small {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--mint);
}

.status-dot.watch {
    background: var(--signal);
}

.status-dot.risk {
    background: var(--danger);
}

.row-meta {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.25;
}

.conversion-badge {
    display: inline-grid;
    place-items: center;
    width: 58px;
    height: 34px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 7px;
    font-weight: 800;
}

.inspector {
    position: sticky;
    top: 26px;
}

.inspector h2 {
    margin: 8px 0;
    font-size: 31px;
}

.inspector p {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.45;
}

.inspector dl {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px 10px;
    margin: 0;
}

.inspector dt {
    color: var(--muted);
}

.inspector dd {
    margin: 0;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.detail-surface,
.report-surface {
    display: grid;
    grid-template-columns: 0.75fr 1.25fr;
    gap: 22px;
}

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

.contractor,
.report-grid article,
.risk-line,
.calendar-slot,
.timeline-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
}

.contractor {
    min-height: 174px;
    padding: 15px;
}

.contractor.is-chosen {
    border-color: var(--signal);
    box-shadow: inset 0 -5px 0 var(--signal);
}

.contractor h3 {
    margin: 8px 0 6px;
    font-size: 20px;
}

.contractor-metrics {
    display: grid;
    gap: 5px;
    margin-top: 14px;
}

.contractor-metrics span {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 5px;
}

.timeline {
    display: grid;
    gap: 8px;
    width: min(100%, 1320px);
    margin: 18px auto 0;
}

.timeline-item {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
}

.timeline-item time {
    color: var(--muted);
    font-weight: 800;
}

.timeline-item p {
    margin: 4px 0 8px;
    color: var(--muted);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    width: min(100%, 1320px);
    margin: 18px auto 0;
}

.calendar-slot {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
    min-height: 140px;
    padding: 14px;
    border-top: 6px solid var(--mint);
}

.calendar-slot.stage-spec {
    border-top-color: var(--signal);
}

.calendar-slot.stage-shop {
    border-top-color: var(--ink);
}

.calendar-slot.stage-install {
    border-top-color: var(--danger);
}

.calendar-slot time {
    display: grid;
    gap: 12px;
    align-content: start;
    color: var(--muted);
    font-weight: 800;
}

.calendar-slot time b {
    color: var(--ink);
    font-size: 24px;
}

.calendar-slot strong,
.calendar-slot small {
    display: block;
    overflow-wrap: anywhere;
}

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

.report-grid article,
.risk-line {
    min-height: 126px;
    padding: 16px;
}

.report-grid strong {
    display: block;
    margin-top: 12px;
    font-size: 34px;
    line-height: 1;
}

.risk-line {
    grid-column: 1 / -1;
    background: var(--ink);
    color: var(--paper);
}

.risk-line strong {
    display: block;
    margin-top: 8px;
    color: var(--signal);
}

.empty-state {
    min-height: 120px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
}

dialog {
    width: min(520px, calc(100% - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    color: var(--ink);
}

dialog::backdrop {
    background: rgba(20, 33, 61, 0.62);
}

.dialog-form {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.dialog-form label {
    display: grid;
    gap: 8px;
    font-weight: 800;
}

.dialog-form textarea {
    width: 100%;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.dialog-actions button {
    padding: 0 14px;
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
}

.dialog-actions .primary-button {
    background: var(--signal);
    border-color: var(--signal);
}

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

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

    .side-rail {
        position: static;
        min-height: auto;
        padding: 16px;
    }

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

    .tab {
        text-align: center;
    }

    .rail-status {
        display: none;
    }

    .work-grid,
    .detail-surface,
    .report-surface {
        grid-template-columns: 1fr;
    }

    .inspector {
        position: static;
    }

    .lane-board,
    .calendar-grid,
    .report-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .workspace {
        padding: 16px;
    }

    .topbar {
        display: grid;
        align-items: start;
    }

    .topbar h1 {
        font-size: 34px;
    }

    .toolbar {
        justify-content: stretch;
    }

    .search-box,
    .primary-button {
        width: 100%;
    }

    .metric-strip,
    .lane-board,
    .calendar-grid,
    .comparison-grid,
    .report-grid {
        grid-template-columns: 1fr;
    }

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

    .request-row {
        grid-template-columns: 12px minmax(0, 1fr) 58px;
        align-items: start;
    }

    .row-meta {
        grid-column: 2 / -1;
    }

    .inspector dl {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .timeline-item,
    .calendar-slot {
        grid-template-columns: 1fr;
    }
}
