:root {
    --ink: #0d1b2a;
    --paper: #f5ebe0;
    --steel: #778da9;
    --amber: #e0a458;
    --line: rgba(13, 27, 42, 0.18);
    --soft: rgba(245, 235, 224, 0.72);
    --danger: #b74434;
    --ok: #3d7a61;
    --shadow: 0 18px 50px rgba(13, 27, 42, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(13, 27, 42, 0.06) 1px, transparent 1px),
        linear-gradient(0deg, rgba(13, 27, 42, 0.05) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
    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 {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    min-height: 100vh;
}

.metric-spine {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    color: var(--paper);
    background: var(--ink);
    border-right: 6px solid var(--amber);
}

.brand {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 10px;
    align-items: center;
    color: var(--paper);
    text-decoration: none;
}

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

.brand span {
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

.spine-title {
    display: grid;
    gap: 5px;
    padding: 14px 0;
    border-top: 1px solid rgba(245, 235, 224, 0.22);
    border-bottom: 1px solid rgba(245, 235, 224, 0.22);
}

.spine-title span,
.metric span,
.metric em,
.case-grid span,
.note-block h2,
.next-action span,
.board-head span,
.search-box span,
.quick-form span,
.forge-dial span,
.report-grid span,
.action-log h2 {
    font-size: 11px;
    line-height: 1.2;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.spine-title strong {
    font-size: 14px;
    line-height: 1.2;
}

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

.metric {
    min-height: 96px;
    display: grid;
    align-content: space-between;
    gap: 8px;
    padding: 13px;
    background: rgba(245, 235, 224, 0.08);
    border: 1px solid rgba(245, 235, 224, 0.22);
    border-radius: 6px;
}

.metric strong {
    font-size: clamp(28px, 5vw, 42px);
    line-height: 0.95;
}

.metric em {
    color: rgba(245, 235, 224, 0.72);
    font-style: normal;
}

.metric-amber {
    border-color: var(--amber);
}

.metric-paper {
    background: rgba(245, 235, 224, 0.16);
}

.metric-steel {
    border-color: var(--steel);
}

.forge-dial {
    margin-top: auto;
    display: grid;
    place-items: center;
    gap: 8px;
    aspect-ratio: 1;
    border: 2px solid var(--amber);
    border-radius: 50%;
    box-shadow: inset 0 0 0 12px rgba(224, 164, 88, 0.12);
}

.forge-dial strong {
    max-width: 120px;
    overflow-wrap: anywhere;
    text-align: center;
}

.workbench {
    min-width: 0;
    padding: 18px;
}

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

.title-block p {
    margin: 0 0 6px;
    color: rgba(13, 27, 42, 0.72);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.title-block h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 54px);
    line-height: 0.95;
    letter-spacing: 0;
}

.view-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.tab,
.quick-form button,
.machine-panel button,
.stage-btn {
    min-height: 38px;
    padding: 0 13px;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--ink);
    border-radius: 5px;
    font-weight: 850;
}

.tab.is-active,
.quick-form button,
.machine-panel button,
.stage-btn.is-current {
    color: var(--paper);
    background: var(--ink);
}

.quick-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 14px;
    margin: 16px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.32);
    border: 1px solid var(--line);
    border-radius: 7px;
}

.quick-form {
    display: grid;
    grid-template-columns: 190px minmax(220px, 1fr) 96px;
    gap: 10px;
    align-items: end;
}

.quick-form label,
.search-box {
    display: grid;
    gap: 5px;
}

.quick-form input,
.quick-form select,
.search-box input {
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 5px;
    outline: none;
}

.quick-form input:focus,
.quick-form select:focus,
.search-box input:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.18);
}

.sync {
    min-width: 122px;
    padding: 10px;
    color: var(--paper);
    background: var(--steel);
    border-radius: 5px;
    text-align: center;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
    gap: 16px;
    align-items: start;
}

.board-panel,
.inspector {
    min-width: 0;
}

.board-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: end;
    margin-bottom: 10px;
}

.search-box {
    width: min(280px, 100%);
}

.board {
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.lane {
    min-width: 190px;
    min-height: 530px;
    background: rgba(245, 235, 224, 0.68);
    border: 1px solid var(--line);
    border-radius: 7px;
}

.lane header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px;
    padding: 10px;
    color: var(--paper);
    background: var(--ink);
    border-radius: 6px 6px 0 0;
}

.lane header strong {
    font-size: 13px;
    text-transform: uppercase;
}

.lane header span {
    color: var(--amber);
    font-size: 12px;
    font-weight: 850;
}

.lane-stack {
    display: grid;
    gap: 9px;
    padding: 10px;
}

.case-card {
    width: 100%;
    min-height: 158px;
    display: grid;
    gap: 10px;
    padding: 12px;
    color: var(--ink);
    text-align: left;
    background: var(--soft);
    border: 1px solid var(--line);
    border-left: 6px solid var(--steel);
    border-radius: 6px;
    box-shadow: none;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.case-card:hover,
.case-card.is-active {
    transform: translateY(-2px);
    background: #fff7ec;
    border-color: var(--ink);
    border-left-color: var(--amber);
}

.card-top,
.card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-top b {
    font-size: 12px;
}

.case-card strong {
    font-size: 15px;
    line-height: 1.18;
}

.card-meta,
.card-bottom em {
    color: rgba(13, 27, 42, 0.68);
    font-size: 12px;
    font-style: normal;
}

.card-bottom b {
    color: var(--danger);
    font-size: 12px;
}

.priority {
    padding: 4px 7px;
    border-radius: 4px;
    color: var(--paper);
    background: var(--steel);
    font-size: 10px;
    font-style: normal;
    font-weight: 900;
    text-transform: uppercase;
}

.priority-critical {
    background: var(--danger);
}

.priority-high {
    background: var(--amber);
    color: var(--ink);
}

.inspector {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 14px;
    padding: 14px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 7px;
    box-shadow: var(--shadow);
}

.inspector-head {
    display: grid;
    gap: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(245, 235, 224, 0.22);
}

.inspector-head span,
.inspector-head em {
    color: rgba(245, 235, 224, 0.7);
    font-size: 12px;
    font-style: normal;
    font-weight: 850;
    text-transform: uppercase;
}

.inspector-head strong {
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.02;
}

.inspector-head.compact strong {
    font-size: clamp(22px, 2.6vw, 30px);
}

.case-grid,
.report-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.case-grid div,
.report-grid div,
.machine-panel,
.note-block,
.next-action,
.action-log,
.timeline div {
    padding: 12px;
    background: rgba(245, 235, 224, 0.08);
    border: 1px solid rgba(245, 235, 224, 0.18);
    border-radius: 6px;
}

.case-grid div,
.report-grid div {
    display: grid;
    gap: 7px;
}

.case-grid strong,
.report-grid strong {
    font-size: 17px;
    line-height: 1.15;
}

.report-grid em {
    color: rgba(245, 235, 224, 0.68);
    font-size: 12px;
    font-style: normal;
    line-height: 1.35;
}

.stage-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.stage-btn {
    min-width: 0;
    color: var(--paper);
    border-color: rgba(245, 235, 224, 0.3);
}

.stage-btn.is-current {
    color: var(--ink);
    background: var(--amber);
    border-color: var(--amber);
}

.note-block {
    display: grid;
    gap: 8px;
}

.note-block h2,
.action-log h2 {
    margin: 0;
    color: var(--amber);
}

.note-block p,
.next-action strong {
    margin: 0;
    line-height: 1.45;
}

.note-block ul {
    margin: 0;
    padding-left: 18px;
    color: rgba(245, 235, 224, 0.82);
}

.note-block li + li {
    margin-top: 4px;
}

.next-action {
    display: grid;
    gap: 8px;
    border-color: var(--amber);
}

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

.timeline div,
.calendar-row,
.action-log p {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.timeline b,
.calendar-row b {
    color: var(--amber);
    font-size: 20px;
}

.machine-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.machine-panel span {
    grid-column: 1 / -1;
    color: var(--amber);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.machine-panel button {
    color: var(--ink);
    background: var(--amber);
    border-color: var(--amber);
}

.calendar-list {
    display: grid;
    gap: 9px;
}

.calendar-row {
    width: 100%;
    min-height: 68px;
    padding: 10px;
    color: var(--paper);
    text-align: left;
    background: rgba(245, 235, 224, 0.08);
    border: 1px solid rgba(245, 235, 224, 0.18);
    border-radius: 6px;
}

.calendar-row span {
    display: grid;
    gap: 4px;
}

.calendar-row em,
.calendar-row i {
    color: rgba(245, 235, 224, 0.68);
    font-size: 12px;
    font-style: normal;
}

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

.action-log p {
    margin: 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(245, 235, 224, 0.12);
}

.action-log p:last-child {
    border-bottom: 0;
}

.action-log b {
    color: var(--amber);
}

.action-log span {
    line-height: 1.35;
}

.action-log em {
    color: rgba(245, 235, 224, 0.62);
    font-size: 11px;
    font-style: normal;
    text-transform: uppercase;
}

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

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

    .metric-spine {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) 120px;
        align-items: stretch;
    }

    .metrics {
        grid-template-columns: repeat(4, minmax(120px, 1fr));
        overflow-x: auto;
    }

    .metric {
        min-height: 86px;
    }

    .forge-dial {
        width: 104px;
        margin-top: 0;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .inspector {
        position: static;
    }
}

@media (max-width: 760px) {
    .workbench,
    .metric-spine {
        padding: 12px;
    }

    .metric-spine {
        grid-template-columns: 1fr;
        border-right: 0;
        border-bottom: 5px solid var(--amber);
    }

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

    .forge-dial {
        width: 100%;
        aspect-ratio: auto;
        min-height: 70px;
        border-radius: 7px;
    }

    .topbar,
    .board-head,
    .quick-create {
        display: grid;
        grid-template-columns: 1fr;
    }

    .view-tabs {
        justify-content: start;
    }

    .quick-form {
        grid-template-columns: 1fr;
    }

    .board {
        grid-template-columns: repeat(4, minmax(220px, 78vw));
    }

    .lane {
        min-height: 410px;
    }

    .case-grid,
    .report-grid,
    .stage-strip,
    .machine-panel,
    .timeline div,
    .calendar-row,
    .action-log p {
        grid-template-columns: 1fr;
    }
}
