:root {
    --ink: #1a1a2e;
    --paper: #f2e9e4;
    --paper-deep: #e5d7d0;
    --mauve: #9a8c98;
    --clay: #c9ada7;
    --signal: #d65a31;
    --mint: #5f8d7a;
    --line: rgba(26, 26, 46, 0.18);
    --muted: rgba(26, 26, 46, 0.64);
    --white: #fffaf6;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    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(26, 26, 46, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
        linear-gradient(rgba(26, 26, 46, 0.03) 1px, transparent 1px) 0 0 / 32px 32px,
        var(--paper);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.left-rail,
.inspector {
    background: rgba(255, 250, 246, 0.72);
    backdrop-filter: blur(18px);
}

.left-rail {
    border-right: 2px solid var(--ink);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    font-size: 18px;
}

.brand img {
    flex: 0 0 auto;
}

.rail-nav {
    display: grid;
    gap: 4px;
}

.nav-item {
    width: 100%;
    min-height: 42px;
    border: 0;
    border-left: 4px solid transparent;
    background: transparent;
    color: var(--muted);
    text-align: left;
    padding: 10px 12px;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-item:hover,
.nav-item.is-active {
    background: var(--ink);
    border-left-color: var(--signal);
    color: var(--white);
}

.rail-note {
    margin-top: auto;
    border-top: 2px solid var(--ink);
    padding-top: 18px;
    line-height: 1.35;
}

.note-kicker,
.eyebrow {
    display: block;
    color: var(--mauve);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.workspace {
    min-width: 0;
    padding: 24px 28px 30px;
}

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

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

h1 {
    margin-bottom: 0;
    font-size: clamp(32px, 5vw, 58px);
    line-height: 0.95;
    letter-spacing: 0;
}

.top-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.search {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.search input,
.top-actions select,
.action-form textarea {
    border: 2px solid var(--ink);
    background: var(--white);
    color: var(--ink);
    border-radius: 0;
    outline: none;
}

.search input {
    width: min(32vw, 320px);
    min-height: 42px;
    padding: 0 12px;
}

.top-actions select {
    min-height: 42px;
    padding: 0 34px 0 12px;
}

.screen {
    display: none;
    animation: surface-in 220ms ease both;
}

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

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

.metric {
    min-height: 132px;
    padding: 18px;
    border-right: 2px solid var(--ink);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

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

.metric span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(44px, 8vw, 76px);
    line-height: 0.82;
    font-weight: 700;
}

.stage-board {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    border-top: 2px solid var(--ink);
    border-left: 2px solid var(--ink);
    overflow-x: auto;
}

.stage-column {
    min-height: 520px;
    background: rgba(255, 250, 246, 0.62);
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
}

.stage-heading {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    border-bottom: 2px solid var(--ink);
    background: var(--paper-deep);
}

.stage-heading strong {
    font-size: 14px;
}

.stage-heading span {
    min-width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    background: var(--ink);
    color: var(--white);
    font-size: 12px;
    font-weight: 800;
}

.incident {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--line);
    background: transparent;
    color: var(--ink);
    text-align: left;
    padding: 16px 14px;
    display: grid;
    gap: 12px;
    transition: background 160ms ease, transform 160ms ease;
}

.incident:hover,
.incident.is-selected {
    background: #fffaf6;
}

.incident:hover {
    transform: translateY(-1px);
}

.incident-title {
    display: block;
    font-weight: 800;
    line-height: 1.18;
}

.incident-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.risk-line {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 800;
}

.risk-line i,
.gauge-track {
    height: 8px;
    background: rgba(26, 26, 46, 0.12);
    overflow: hidden;
}

.risk-line i::before,
.gauge-track i {
    display: block;
    height: 100%;
    width: var(--risk, 0%);
    background: var(--risk-color, var(--mint));
    transition: width 240ms ease;
}

.risk-line i::before {
    content: "";
}

.inspector {
    border-left: 2px solid var(--ink);
    padding: 24px 20px;
    overflow-y: auto;
}

.inspector-header {
    border-bottom: 2px solid var(--ink);
    padding-bottom: 18px;
}

.inspector-header span {
    display: inline-block;
    margin-bottom: 12px;
    background: var(--clay);
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.inspector-header h2 {
    margin-bottom: 0;
    font-size: 26px;
    line-height: 1.05;
}

.detail-list {
    margin: 18px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 2px solid var(--ink);
    border-left: 2px solid var(--ink);
}

.detail-list div {
    min-height: 74px;
    padding: 10px;
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    background: var(--white);
}

.detail-list dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-list dd {
    margin: 8px 0 0;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.risk-gauge {
    padding: 16px 0 20px;
    border-bottom: 2px solid var(--ink);
}

.risk-gauge span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.risk-gauge strong {
    display: block;
    margin: 4px 0 12px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 64px;
    line-height: 0.9;
}

.inspection-block {
    padding: 18px 0;
    border-bottom: 2px solid var(--ink);
}

.inspection-block h3,
.section-head h2 {
    margin-bottom: 8px;
}

.inspection-block p,
.section-head p,
.team-grid p {
    color: var(--muted);
    line-height: 1.5;
}

.action-form {
    margin-top: 18px;
    display: grid;
    gap: 10px;
}

.action-form label {
    font-weight: 800;
}

.action-form textarea {
    width: 100%;
    resize: vertical;
    padding: 10px;
}

.action-form button {
    min-height: 44px;
    border: 2px solid var(--ink);
    background: var(--ink);
    color: var(--white);
    font-weight: 800;
    transition: transform 160ms ease, background 160ms ease;
}

.action-form button:hover {
    background: var(--signal);
    transform: translateY(-1px);
}

.section-head {
    padding: 28px 0 16px;
    border-bottom: 2px solid var(--ink);
}

.section-head h2 {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1;
}

.timeline,
.workflow-grid,
.team-grid {
    display: grid;
    border-left: 2px solid var(--ink);
    border-top: 2px solid var(--ink);
    background: rgba(255, 250, 246, 0.5);
}

.timeline {
    margin-top: 20px;
}

.timeline-item,
.rule-row,
.team-grid article {
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    background: var(--white);
}

.timeline-item {
    display: grid;
    grid-template-columns: 160px 120px 1fr;
    gap: 14px;
    padding: 16px;
}

.timeline-item time,
.timeline-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.workflow-grid {
    margin-top: 20px;
}

.rule-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 120px minmax(180px, 1.4fr);
    gap: 12px;
    align-items: center;
    padding: 18px;
}

.rule-row span,
.team-grid span {
    font-weight: 800;
}

.rule-row strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 28px;
}

.rule-row em {
    color: var(--muted);
    font-style: normal;
}

.team-grid {
    margin-top: 20px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.team-grid article {
    min-height: 210px;
    padding: 18px;
}

.team-grid strong {
    display: block;
    margin: 20px 0 12px;
    font-size: 24px;
    line-height: 1.05;
}

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

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

    .inspector {
        grid-column: 1 / -1;
        border-left: 0;
        border-top: 2px solid var(--ink);
    }

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

    .metric:nth-child(2) {
        border-right: 0;
    }

    .metric:nth-child(1),
    .metric:nth-child(2) {
        border-bottom: 2px solid var(--ink);
    }
}

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

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

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

    .rail-note {
        margin-top: 0;
    }

    .workspace {
        padding: 18px 14px;
    }

    .topbar,
    .top-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .search input,
    .top-actions select {
        width: 100%;
    }

    .metrics-strip {
        grid-template-columns: 1fr;
        border-top: 2px solid var(--ink);
    }

    .metric,
    .metric:nth-child(2) {
        min-height: 108px;
        border-right: 0;
        border-bottom: 2px solid var(--ink);
    }

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

    .stage-board {
        grid-template-columns: minmax(230px, 1fr);
        overflow: visible;
    }

    .stage-column {
        min-height: auto;
    }

    .timeline-item,
    .rule-row,
    .team-grid {
        grid-template-columns: 1fr;
    }

    .team-grid article {
        min-height: 0;
    }
}

