:root {
    --ink: #1a1a2e;
    --paper: #f2e9e4;
    --paper-soft: #fbf7f3;
    --mauve: #9a8c98;
    --cedar: #c9ada7;
    --line: #2a293b;
    --green: #3f7652;
    --amber: #b78334;
    --red: #a14645;
    --shadow: 0 18px 45px rgba(26, 26, 46, 0.12);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(26, 26, 46, 0.04) 1px, transparent 1px),
        linear-gradient(0deg, rgba(26, 26, 46, 0.035) 1px, transparent 1px),
        var(--paper);
    background-size: 22px 22px;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.left-rail,
.inspection-drawer {
    background: var(--ink);
    color: var(--paper);
    border-right: 2px solid var(--line);
    padding: 24px;
}

.inspection-drawer {
    background: #fffaf6;
    color: var(--ink);
    border-right: 0;
    border-left: 2px solid var(--line);
}

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

.brand img {
    width: 46px;
    height: 46px;
    box-shadow: 6px 6px 0 var(--cedar);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 18px;
    line-height: 1;
}

.brand small,
.mono {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.brand small {
    color: var(--cedar);
    margin-top: 5px;
}

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

.tab,
.icon-button,
.primary-button,
.lane,
.inspection-row {
    border: 2px solid var(--line);
    border-radius: 0;
}

.tab {
    background: transparent;
    color: var(--paper);
    padding: 13px 12px;
    text-align: left;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
    background: var(--paper);
    color: var(--ink);
    transform: translateX(3px);
}

.rail-note {
    margin-top: 48px;
    border-top: 2px solid var(--cedar);
    padding-top: 18px;
}

.rail-note strong {
    display: block;
    margin-top: 8px;
}

.work-canvas {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 2px solid var(--line);
    padding-bottom: 22px;
}

.eyebrow {
    margin: 0 0 8px;
    color: #65545f;
    font-size: 14px;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(34px, 5vw, 72px);
    line-height: 0.93;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 6px;
    font-size: 22px;
    line-height: 1.1;
}

h3 {
    margin-bottom: 6px;
    font-size: 18px;
}

.toolbar {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.search-box {
    display: grid;
    gap: 4px;
    min-width: 240px;
}

.search-box input,
.dialog-form textarea {
    width: 100%;
    border: 2px solid var(--line);
    background: #fffaf6;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
}

.search-box input:focus,
.dialog-form textarea:focus {
    box-shadow: 0 0 0 3px var(--cedar);
}

.icon-button,
.primary-button {
    min-height: 44px;
    background: var(--paper-soft);
    color: var(--ink);
    padding: 0 14px;
    box-shadow: 4px 4px 0 var(--cedar);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.icon-button {
    width: 46px;
    font-size: 24px;
    line-height: 1;
}

.primary-button {
    background: var(--ink);
    color: var(--paper);
    font-weight: 800;
}

.icon-button:hover,
.primary-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--cedar);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 2px solid var(--line);
    border-top: 0;
    background: #fffaf6;
}

.metric {
    min-width: 0;
    padding: 18px;
    border-right: 2px solid var(--line);
}

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

.metric strong {
    display: block;
    margin: 6px 0 4px;
    font-size: clamp(30px, 4vw, 58px);
    line-height: 0.95;
}

.metric small {
    color: #6c5c63;
}

.metric-risk {
    background: #efe3dd;
}

.metric-blocked {
    background: #ead1ca;
}

.view {
    display: none;
    animation: liftIn 220ms ease both;
}

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

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

.board-header,
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin: 28px 0 14px;
}

.board-header p {
    margin-bottom: 0;
    color: #665660;
}

.lane-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 2px solid var(--line);
    background: #fffaf6;
}

.lane {
    display: grid;
    gap: 9px;
    min-height: 150px;
    padding: 18px;
    background: transparent;
    border-width: 0 2px 0 0;
    color: var(--ink);
    text-align: left;
    transition: background 160ms ease;
}

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

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

.lane:hover {
    background: #f4ded7;
}

.risk-line,
.capacity {
    height: 8px;
    background: rgba(26, 26, 46, 0.14);
    overflow: hidden;
}

.risk-line span,
.capacity span {
    display: block;
    height: 100%;
    background: var(--green);
    transition: width 260ms ease;
}

.is-watch .risk-line span,
.risk-pill.is-watch {
    background: var(--amber);
}

.is-hot .risk-line span,
.risk-pill.is-hot {
    background: var(--red);
}

.table-zone {
    margin-top: 26px;
}

.inspection-table {
    border: 2px solid var(--line);
    background: #fffaf6;
}

.inspection-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1.25fr 1.45fr 0.85fr 82px;
    gap: 16px;
    align-items: center;
    border-width: 0 0 2px 0;
    background: transparent;
    color: var(--ink);
    padding: 14px 16px;
    text-align: left;
    transition: background 160ms ease, padding-left 160ms ease;
}

.inspection-row:last-child {
    border-bottom: 0;
}

.inspection-row:hover,
.inspection-row.is-selected {
    background: #f4ded7;
    padding-left: 22px;
}

.inspection-row span {
    min-width: 0;
}

.inspection-row strong,
.inspection-row small {
    display: block;
    overflow-wrap: anywhere;
}

.inspection-row small {
    color: #6a5a62;
    margin-top: 4px;
}

.risk-pill {
    justify-self: end;
    min-width: 58px;
    padding: 8px 10px;
    background: var(--green);
    color: #fffaf6;
    text-align: center;
    font-weight: 800;
}

.inspection-drawer {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}

.inspection-drawer h2 {
    margin-top: 16px;
    font-size: 30px;
}

.inspection-drawer p {
    color: #5f515a;
    line-height: 1.55;
}

dl {
    margin: 26px 0;
}

dl div {
    border-top: 2px solid var(--line);
    padding: 12px 0;
}

dt {
    color: #6d5e66;
    font-size: 12px;
    text-transform: uppercase;
}

dd {
    margin: 4px 0 0;
    font-weight: 800;
}

.drawer-route {
    display: grid;
    gap: 8px;
}

.route-step {
    border: 2px solid var(--line);
    padding: 10px 12px;
    background: var(--paper);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.route-step.is-current {
    background: var(--ink);
    color: var(--paper);
    box-shadow: 5px 5px 0 var(--cedar);
}

.timeline,
.workflow-grid,
.team-grid {
    display: grid;
    gap: 12px;
}

.timeline-item,
.workflow-step,
.team-member,
.empty {
    border: 2px solid var(--line);
    background: #fffaf6;
    padding: 18px;
    box-shadow: var(--shadow);
}

.timeline-item p,
.workflow-step p,
.team-member p {
    color: #5f515a;
    line-height: 1.5;
}

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

.workflow-step {
    display: grid;
    gap: 16px;
}

.workflow-step div,
.team-member div:first-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
}

.workflow-step strong {
    font-size: 32px;
}

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

.team-member h3 {
    margin-bottom: 0;
}

dialog {
    width: min(520px, calc(100vw - 28px));
    border: 2px solid var(--line);
    padding: 0;
    background: #fffaf6;
    color: var(--ink);
    box-shadow: 12px 12px 0 var(--cedar);
}

dialog::backdrop {
    background: rgba(26, 26, 46, 0.45);
}

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

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

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

.dialog-actions button:not(.primary-button) {
    border: 2px solid var(--line);
    background: transparent;
    padding: 10px 14px;
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .inspection-drawer {
        grid-column: 1 / -1;
        position: static;
        height: auto;
        border-left: 0;
        border-top: 2px solid var(--line);
    }
}

@media (max-width: 860px) {
    .app-shell {
        display: block;
    }

    .left-rail {
        padding: 16px;
        border-right: 0;
        border-bottom: 2px solid var(--line);
    }

    .brand {
        margin-bottom: 16px;
    }

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

    .tab {
        padding: 10px 8px;
        text-align: center;
        font-size: 13px;
    }

    .rail-note {
        margin-top: 16px;
    }

    .work-canvas {
        padding: 16px;
    }

    .topbar,
    .toolbar,
    .board-header,
    .section-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .search-box {
        min-width: 0;
    }

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

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

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

    .inspection-row {
        grid-template-columns: 1fr;
        gap: 9px;
    }

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

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

