:root {
    color-scheme: light;
    --ink: #0b132b;
    --paper: #f6fff8;
    --line: rgba(11, 19, 43, 0.13);
    --muted: #667085;
    --teal: #5bc0be;
    --gold: #ffd166;
    --red: #d95c4b;
    --green: #1f8f62;
    --white: #ffffff;
    --shadow: 0 22px 55px rgba(11, 19, 43, 0.13);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(91, 192, 190, 0.12), transparent 34%),
        radial-gradient(circle at 78% 18%, rgba(255, 209, 102, 0.26), transparent 32%),
        var(--paper);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.left-rail {
    padding: 24px 18px;
    background: var(--ink);
    color: var(--paper);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

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

.brand strong {
    display: block;
    font-size: 20px;
    letter-spacing: 0;
}

.brand small,
.caption {
    color: rgba(246, 255, 248, 0.66);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
    font-weight: 800;
}

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

.nav-tab {
    width: 100%;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid rgba(246, 255, 248, 0.14);
    border-radius: 8px;
    background: transparent;
    color: rgba(246, 255, 248, 0.8);
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-tab:hover,
.nav-tab.is-active {
    transform: translateX(3px);
    background: rgba(91, 192, 190, 0.16);
    color: var(--paper);
}

.nav-icon,
.badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--teal);
    color: var(--ink);
    font-size: 11px;
    font-weight: 900;
}

.rail-note {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(246, 255, 248, 0.16);
}

.rail-note strong {
    display: block;
    margin-top: 8px;
    line-height: 1.35;
    font-size: 14px;
}

.workspace {
    min-width: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar,
.canvas-head,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar h1 {
    margin: 3px 0 0;
    font-size: clamp(31px, 4.6vw, 62px);
    line-height: 0.95;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.search-box {
    min-width: 250px;
    height: 44px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
}

.search-box span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.search-box input {
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

.icon-button,
.primary-button,
.calendar-row button {
    min-height: 44px;
    border-radius: 8px;
    border: 0;
    font-weight: 900;
}

.icon-button {
    width: 44px;
    background: var(--white);
    color: var(--ink);
    border: 1px solid var(--line);
}

.primary-button,
.calendar-row button {
    padding: 0 16px;
    background: var(--gold);
    color: var(--ink);
}

.metric-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric {
    min-height: 116px;
    padding: 15px;
    border-top: 3px solid var(--ink);
    background: rgba(255, 255, 255, 0.62);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

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

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

.metric .caption,
.canvas-head .caption,
.drawer-head .caption {
    color: var(--muted);
}

.metric strong {
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1;
    letter-spacing: 0;
}

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

.track-map {
    padding: 18px 0;
    overflow: hidden;
}

.track-line {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 10px;
    position: relative;
}

.track-node {
    min-height: 142px;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 8px 25px rgba(11, 19, 43, 0.06);
    animation: rise 420ms ease both;
    animation-delay: var(--delay);
}

.track-node h3 {
    margin: 14px 0 6px;
    font-size: 18px;
}

.track-node p {
    min-height: 38px;
    margin: 0;
    color: var(--muted);
    line-height: 1.35;
}

.track-progress,
.mini-progress,
.meter-bar {
    height: 7px;
    border-radius: 99px;
    overflow: hidden;
    background: rgba(11, 19, 43, 0.12);
}

.track-progress {
    margin-top: 14px;
}

.track-progress i,
.mini-progress i,
.meter-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--teal), var(--gold));
    transition: width 240ms ease;
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
    animation: lift 220ms ease both;
}

.canvas-head {
    margin-bottom: 12px;
}

.canvas-head h2 {
    margin: 3px 0 0;
    font-size: 24px;
    letter-spacing: 0;
}

.source-pill,
.stage-pill,
.risk-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.source-pill,
.stage-pill {
    background: rgba(91, 192, 190, 0.16);
    color: #11615f;
}

.risk-pill.is-hot {
    background: rgba(217, 92, 75, 0.16);
    color: #9d2d20;
}

.risk-pill.is-watch {
    background: rgba(255, 209, 102, 0.32);
    color: #76540d;
}

.risk-pill.is-calm {
    background: rgba(31, 143, 98, 0.14);
    color: #146342;
}

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

.case-card {
    min-height: 216px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
    text-align: left;
    display: grid;
    align-content: start;
    gap: 9px;
    box-shadow: 0 8px 22px rgba(11, 19, 43, 0.06);
    transition: transform 170ms ease, border 170ms ease, box-shadow 170ms ease;
}

.case-card:hover,
.case-card.is-selected {
    transform: translateY(-2px);
    border-color: rgba(91, 192, 190, 0.8);
    box-shadow: var(--shadow);
}

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

.case-card small,
.case-footer {
    color: var(--muted);
    line-height: 1.35;
}

.case-code {
    color: #11615f;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.mini-progress {
    width: 100%;
}

.detail-panel,
.calendar-list,
.report-grid,
.timeline {
    display: grid;
    gap: 12px;
}

.record-hero {
    padding: 18px;
    border-left: 5px solid var(--teal);
    background: rgba(255, 255, 255, 0.72);
}

.record-hero h3 {
    margin: 6px 0;
    font-size: 26px;
}

.record-hero p {
    margin: 0;
    color: var(--muted);
}

.record-grid,
.drawer-facts {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.record-grid div,
.drawer-facts div {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.66);
}

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

dd {
    margin: 5px 0 0;
    line-height: 1.3;
}

.timeline-row,
.calendar-row,
.report-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
}

.timeline-row,
.calendar-row {
    padding: 14px;
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
}

.timeline-row {
    grid-template-columns: 126px minmax(0, 1fr);
}

.timeline-row time,
.timeline-row span,
.calendar-row time {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.timeline-row p,
.calendar-row span,
.report-group span {
    margin: 4px 0 0;
    color: var(--muted);
}

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

.report-group {
    padding: 16px;
}

.report-group h3 {
    margin: 0 0 12px;
}

.report-group p {
    margin: 0;
    padding: 11px 0;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.inspection-drawer {
    padding: 24px 18px;
    border-left: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.drawer-head h2 {
    margin: 6px 0;
    font-size: 28px;
    line-height: 1.05;
}

.drawer-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.drawer-meter {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
}

.drawer-meter span {
    color: rgba(246, 255, 248, 0.68);
    font-size: 12px;
    font-weight: 900;
}

.drawer-meter strong {
    display: block;
    margin: 5px 0 12px;
    font-size: 42px;
    line-height: 1;
}

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

.check-row {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(246, 255, 248, 0.72);
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 11px;
    align-items: start;
}

.check-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: var(--gold);
    color: var(--ink);
    font-size: 10px;
    font-weight: 900;
}

.check-row.is-done .check-dot {
    background: var(--teal);
}

.check-row strong,
.check-row p {
    display: block;
    margin: 0;
}

.check-row p {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.35;
}

.empty {
    color: var(--muted);
}

dialog {
    width: min(460px, calc(100vw - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
}

dialog::backdrop {
    background: rgba(11, 19, 43, 0.42);
}

.dialog-form {
    padding: 20px;
    display: grid;
    gap: 16px;
    background: var(--paper);
}

.dialog-form h2 {
    margin: 4px 0 0;
}

.dialog-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
}

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

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

.dialog-actions button {
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 0 14px;
}

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

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

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

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

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

    .left-rail {
        padding: 16px;
    }

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

    .topbar,
    .toolbar,
    .canvas-head {
        align-items: stretch;
        flex-direction: column;
    }

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

    .metric-row,
    .track-line,
    .case-grid,
    .report-grid,
    .record-grid,
    .drawer-facts {
        grid-template-columns: 1fr;
    }

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

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

