:root {
    --ink: #0b132b;
    --paper: #f6fff8;
    --muted: #617074;
    --line: #d7e5df;
    --teal: #5bc0be;
    --teal-dark: #2f8f8d;
    --gold: #ffd166;
    --coral: #e76f51;
    --white: #ffffff;
    --shadow: 0 22px 80px rgba(11, 19, 43, 0.12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(11, 19, 43, 0.04) 1px, transparent 1px),
        linear-gradient(180deg, rgba(11, 19, 43, 0.04) 1px, transparent 1px),
        var(--paper);
    background-size: 44px 44px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.left-rail,
.inspection {
    min-width: 0;
    padding: 24px;
}

.left-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    color: var(--paper);
    background: var(--ink);
    overflow: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

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

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

.brand small {
    color: rgba(246, 255, 248, 0.62);
    font-size: 12px;
}

.rail-nav {
    display: grid;
    gap: 8px;
    margin: 34px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid rgba(246, 255, 248, 0.12);
    border-radius: var(--radius);
    color: rgba(246, 255, 248, 0.76);
    background: transparent;
    text-align: left;
}

.nav-item.is-active {
    color: var(--ink);
    background: var(--gold);
    border-color: var(--gold);
}

.nav-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--teal);
    flex: 0 0 auto;
}

.section-kicker {
    margin: 0 0 8px;
    color: var(--teal-dark);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.left-rail .section-kicker {
    color: var(--gold);
}

.stage-map ol {
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.stage-map li {
    position: relative;
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    min-height: 44px;
    color: rgba(246, 255, 248, 0.84);
}

.stage-map li::after {
    content: attr(data-count);
    justify-self: end;
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    color: var(--ink);
    background: var(--teal);
    text-align: center;
    font-size: 12px;
    font-weight: 800;
}

.stage-map span {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(246, 255, 248, 0.22);
    border-radius: 50%;
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
}

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

.topbar,
.canvas-head,
.metric-row,
.report-layout {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    max-width: 760px;
    font-size: 34px;
    line-height: 1.08;
}

h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
}

h3 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.search {
    display: grid;
    gap: 6px;
    width: min(320px, 100%);
}

.search label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.search input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
}

.metric-row {
    margin: 24px 0;
}

.metric {
    flex: 1;
    min-width: 0;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.metric-value {
    display: block;
    font-size: 42px;
    line-height: 0.95;
    font-weight: 850;
}

.metric span:last-child {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.canvas-view {
    display: none;
    animation: riseIn 220ms ease-out;
}

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

.segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.segmented button,
.primary-action,
.secondary-action {
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--white);
}

.segmented button.is-selected,
.primary-action {
    border-color: var(--ink);
    color: var(--paper);
    background: var(--ink);
}

.secondary-action {
    width: 100%;
    border-color: var(--teal);
    background: rgba(91, 192, 190, 0.14);
}

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

.track-column {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.64);
    animation: riseIn 260ms ease-out both;
    animation-delay: calc(var(--track-index) * 45ms);
}

.track-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.track-title span {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--teal);
    font-size: 12px;
    font-weight: 850;
}

.session-card {
    display: grid;
    gap: 8px;
    width: 100%;
    min-height: 138px;
    margin-bottom: 10px;
    padding: 14px;
    border: 1px solid rgba(11, 19, 43, 0.1);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
    text-align: left;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.session-card:hover,
.session-card.is-selected {
    transform: translateY(-2px);
    border-color: var(--teal-dark);
    box-shadow: var(--shadow);
}

.session-card strong {
    font-size: 15px;
    line-height: 1.25;
}

.session-card small,
.session-meta,
.timeline-item span,
.dense-list span,
.activity-feed span,
.drawer-block p {
    color: var(--muted);
}

.session-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
}

.badge {
    width: fit-content;
    max-width: 100%;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.risk-high {
    background: rgba(231, 111, 81, 0.16);
    color: #9b2f19;
}

.risk-mid {
    background: rgba(255, 209, 102, 0.34);
    color: #765516;
}

.risk-low {
    background: rgba(91, 192, 190, 0.18);
    color: #176a69;
}

.record-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.1fr) repeat(3, minmax(190px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.record-main,
.list-panel,
.risk-meter,
.activity-feed,
.drawer-block,
.risk-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
}

.record-main,
.list-panel,
.risk-meter,
.activity-feed {
    padding: 18px;
}

.definition-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0 0;
}

dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

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

.dense-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.dense-list article,
.activity-feed article {
    display: grid;
    gap: 4px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--line);
}

.dense-list article:last-child,
.activity-feed article:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.dense-list em,
.timeline-item em {
    width: fit-content;
    color: var(--teal-dark);
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
}

.timeline-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid var(--line);
}

.timeline-item time {
    font-weight: 850;
}

.timeline-item div {
    display: grid;
    gap: 4px;
}

.report-layout {
    align-items: stretch;
    margin-top: 18px;
}

.risk-meter {
    flex: 0 0 310px;
}

.report-number,
.risk-number {
    display: block;
    font-size: 58px;
    line-height: 0.95;
    font-weight: 900;
}

.activity-feed {
    flex: 1;
}

.activity-feed h3 {
    margin-bottom: 16px;
}

.activity-feed p {
    margin: 0;
}

.inspection {
    position: sticky;
    top: 0;
    height: 100vh;
    background: rgba(255, 255, 255, 0.78);
    border-left: 1px solid var(--line);
    overflow: auto;
}

.drawer-head {
    margin-bottom: 18px;
}

.risk-card {
    padding: 18px;
    margin-bottom: 14px;
}

.risk-card span:last-of-type {
    color: var(--muted);
}

.risk-line {
    height: 9px;
    margin-top: 16px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf3f0;
}

.risk-line i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
    transition: width 260ms ease;
}

.drawer-block {
    padding: 16px;
    margin-bottom: 14px;
}

.drawer-block.compact {
    background: transparent;
}

.empty-state {
    margin: 0;
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
}

.empty-state.wide {
    grid-column: 1 / -1;
}

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

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

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

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

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

    .left-rail {
        position: static;
        height: auto;
        padding: 18px;
    }

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

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

    .workspace,
    .inspection {
        padding: 18px;
    }

    .topbar,
    .canvas-head,
    .metric-row,
    .report-layout {
        display: grid;
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 27px;
    }

    .metric-value,
    .report-number,
    .risk-number {
        font-size: 42px;
    }

    .track-board,
    .record-grid {
        grid-template-columns: 1fr;
    }

    .timeline-item {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
