:root {
    --ink: #0b132b;
    --paper: #f6fff8;
    --aqua: #5bc0be;
    --sun: #ffd166;
    --line: rgba(11, 19, 43, 0.14);
    --muted: #607174;
    --white: #ffffff;
    --danger: #f05d5e;
    --good: #2d936c;
    --shadow: 0 18px 60px rgba(11, 19, 43, 0.16);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.rail {
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-height: 100vh;
    padding: 22px 18px;
    color: var(--paper);
    background:
        linear-gradient(180deg, rgba(91, 192, 190, 0.18), rgba(255, 209, 102, 0.08) 48%, rgba(11, 19, 43, 0)),
        var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    font-weight: 850;
    line-height: 0.95;
    letter-spacing: 0;
}

.brand img {
    flex: 0 0 auto;
}

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

.nav-button {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(246, 255, 248, 0.12);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: left;
    color: rgba(246, 255, 248, 0.72);
    background: transparent;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

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

.rail-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid rgba(246, 255, 248, 0.18);
    font-size: 12px;
    color: rgba(246, 255, 248, 0.62);
}

.rail-foot strong {
    color: var(--sun);
    font-size: 11px;
    overflow-wrap: anywhere;
}

.workspace {
    min-width: 0;
    padding: 26px;
    background:
        radial-gradient(circle at 10% 12%, rgba(91, 192, 190, 0.16), transparent 32%),
        linear-gradient(135deg, rgba(246, 255, 248, 0.96), #edf6f0);
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow,
.sheet-kicker,
.section-head span {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    max-width: 760px;
    font-size: clamp(30px, 4.2vw, 58px);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 14px;
    font-size: 24px;
    line-height: 1.06;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.control-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: min(100%, 520px);
}

.control-strip input,
.note-form input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.74);
}

.accent-button,
.ghost-button {
    min-height: 42px;
    border-radius: 8px;
    padding: 10px 14px;
    white-space: nowrap;
}

.accent-button {
    border: 0;
    color: var(--ink);
    background: var(--sun);
    font-weight: 850;
}

.ghost-button {
    border: 1px solid var(--line);
    color: var(--ink);
    background: rgba(255, 255, 255, 0.6);
}

.metric-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.metric {
    min-height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 34px rgba(11, 19, 43, 0.06);
}

.metric span {
    display: block;
    min-height: 30px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.metric strong {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 36px;
    line-height: 1;
}

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

.metric-alert {
    border-color: rgba(240, 93, 94, 0.42);
}

.metric-good {
    border-color: rgba(45, 147, 108, 0.35);
}

.screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 18px;
    align-items: stretch;
}

.is-hidden {
    display: none !important;
}

.canvas,
.inspector {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow);
}

.canvas {
    padding: 18px;
}

.inspector {
    padding: 20px;
}

.route-map {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.route-step {
    min-height: 156px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    text-align: left;
    background: #f9fffb;
    transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.route-step:hover,
.route-step.is-active {
    border-color: var(--aqua);
    box-shadow: 0 14px 32px rgba(91, 192, 190, 0.16);
    transform: translateY(-2px);
}

.route-badge {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-bottom: 12px;
    border-radius: 50%;
    color: var(--ink);
    background: var(--sun);
    font-weight: 900;
}

.route-step strong,
.case-card strong,
.calendar-slot strong,
.timeline-item strong {
    display: block;
    overflow-wrap: anywhere;
}

.route-step small {
    display: block;
    margin-top: 9px;
    color: var(--muted);
    line-height: 1.35;
}

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

.case-card {
    display: grid;
    gap: 9px;
    min-height: 180px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px;
    text-align: left;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(91, 192, 190, 0.12), transparent 55%),
        var(--white);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.case-card:hover,
.case-card.is-selected {
    border-color: rgba(11, 19, 43, 0.45);
    box-shadow: 0 16px 34px rgba(11, 19, 43, 0.14);
    transform: translateY(-2px);
}

.case-code,
.case-meta,
.case-foot,
.calendar-slot small,
.timeline-item small,
.timeline-item span,
.list-row small {
    color: var(--muted);
    font-size: 12px;
}

.case-card strong {
    font-size: 19px;
    line-height: 1.1;
}

.progress-line,
.risk-meter {
    position: relative;
    overflow: hidden;
    height: 9px;
    border-radius: 999px;
    background: rgba(11, 19, 43, 0.1);
}

.progress-line i,
.risk-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--aqua), var(--sun), var(--danger));
}

.case-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.case-foot b {
    color: var(--ink);
}

.case-foot em {
    font-style: normal;
}

.inspector dl {
    display: grid;
    grid-template-columns: minmax(96px, 0.9fr) minmax(0, 1.1fr);
    gap: 9px 12px;
    margin: 0 0 18px;
}

.inspector dt {
    color: var(--muted);
    font-size: 12px;
}

.inspector dd {
    margin: 0;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.risk-meter {
    height: 34px;
    margin-bottom: 18px;
}

.risk-meter strong {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--ink);
    font-size: 14px;
}

.note-form {
    display: grid;
    gap: 12px;
}

.note-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-head strong {
    overflow-wrap: anywhere;
}

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

.detail-grid > div {
    min-width: 0;
    border-top: 4px solid var(--aqua);
    padding-top: 14px;
}

.compact-list,
.calendar-board,
.timeline {
    display: grid;
    gap: 10px;
}

.list-row,
.calendar-slot,
.timeline-item,
.report-tile {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    background: rgba(255, 255, 255, 0.76);
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.list-row span {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.list-row strong {
    flex: 0 0 auto;
}

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

.sheet-copy {
    color: #2e4246;
    line-height: 1.5;
}

.badge-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 18px;
}

.badge-strip span {
    display: grid;
    gap: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 10px;
    background: #fbfffc;
}

.badge-strip b {
    color: var(--ink);
    font-size: 26px;
    line-height: 1;
}

.calendar-slot {
    width: 100%;
    display: grid;
    gap: 7px;
    text-align: left;
    color: var(--ink);
}

.calendar-slot span {
    width: fit-content;
    border-radius: 999px;
    padding: 4px 8px;
    color: var(--ink);
    background: var(--sun);
    font-size: 12px;
    font-weight: 850;
}

.calendar-slot.is-selected {
    border-color: var(--aqua);
}

.setting-list {
    display: grid;
    gap: 12px;
}

.setting-list label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 9px;
    color: #2e4246;
    line-height: 1.35;
}

.report-tile {
    min-height: 150px;
}

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

.report-tile strong {
    display: block;
    margin: 13px 0 8px;
    font-size: 38px;
    line-height: 1;
    overflow-wrap: anywhere;
}

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

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

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(340px, calc(100vw - 36px));
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--paper);
    background: var(--ink);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1120px) {
    .metric-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .inspector {
        order: -1;
    }
}

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

    .rail {
        min-height: auto;
        padding: 14px;
    }

    .brand {
        justify-content: center;
    }

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

    .nav-button {
        text-align: center;
        padding: 9px 6px;
        font-size: 13px;
    }

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

    .workspace {
        padding: 16px;
    }

    .topbar,
    .control-strip {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-row,
    .route-map,
    .case-stack,
    .detail-grid,
    .report-grid {
        grid-template-columns: 1fr;
    }

    .route-step {
        min-height: 118px;
    }
}

@media (max-width: 480px) {
    .rail-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    h1 {
        font-size: 32px;
    }

    .metric strong,
    .report-tile strong {
        font-size: 30px;
    }

    .inspector dl {
        grid-template-columns: 1fr;
    }

    .case-foot,
    .list-row,
    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
