:root {
    --ink: #0b132b;
    --paper: #f6fff8;
    --panel: #ffffff;
    --line: #dbe8e2;
    --muted: #68776f;
    --teal: #5bc0be;
    --yellow: #ffd166;
    --red: #ef476f;
    --green: #2a9d8f;
    --shadow: 0 18px 45px rgba(11, 19, 43, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(91, 192, 190, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(11, 19, 43, 0.05) 1px, transparent 1px),
        var(--paper);
    background-size: 34px 34px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    color: #f6fff8;
    background: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.brand {
    color: inherit;
    text-decoration: none;
    display: grid;
    grid-template-columns: 46px 1fr;
    align-items: center;
    gap: 12px;
}

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

.brand small,
.rail-note span,
.mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    letter-spacing: 0;
    text-transform: uppercase;
}

.brand small {
    color: rgba(246, 255, 248, 0.68);
}

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

.tab {
    min-height: 44px;
    border: 1px solid rgba(246, 255, 248, 0.13);
    color: rgba(246, 255, 248, 0.76);
    background: transparent;
    border-radius: 8px;
    text-align: left;
    padding: 0 14px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
    color: #0b132b;
    background: var(--yellow);
    transform: translateX(2px);
}

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

.rail-note span,
.mono {
    color: var(--muted);
    font-size: 11px;
}

.rail-note .mono {
    color: rgba(246, 255, 248, 0.58);
}

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

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--green);
    font-size: 13px;
    font-weight: 750;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1;
    letter-spacing: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search input {
    width: min(260px, 42vw);
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    padding: 0 14px;
    color: var(--ink);
    outline: none;
}

.search input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(91, 192, 190, 0.18);
}

.primary-button,
.ghost-button,
.icon-button {
    min-height: 42px;
    border-radius: 8px;
    border: 0;
    padding: 0 16px;
    background: var(--ink);
    color: #f6fff8;
    font-weight: 760;
}

.icon-button {
    width: 42px;
    padding: 0;
    background: var(--teal);
    color: var(--ink);
}

.ghost-button {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
}

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

.metric {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.76);
    border-radius: 8px;
    padding: 15px;
    min-width: 0;
}

.metric strong {
    display: block;
    margin: 4px 0 2px;
    font-size: clamp(27px, 4vw, 44px);
    line-height: 1;
    letter-spacing: 0;
}

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

.metric-alert {
    border-color: rgba(239, 71, 111, 0.35);
}

.metric-stock {
    border-color: rgba(91, 192, 190, 0.55);
}

.metric-money {
    border-color: rgba(255, 209, 102, 0.9);
}

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

.canvas {
    min-width: 0;
}

.view {
    display: none;
}

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

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

.track-step {
    position: relative;
    min-height: 132px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px;
    text-align: left;
    color: var(--ink);
    background: var(--panel);
    overflow: hidden;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.track-step:hover {
    transform: translateY(-2px);
    border-color: var(--teal);
    box-shadow: var(--shadow);
}

.badge {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 50%;
    color: var(--ink);
    background: var(--yellow);
    font-weight: 850;
}

.track-step b,
.track-step small {
    display: block;
}

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

.track-step em,
.route-track {
    display: block;
    height: 7px;
    margin-top: 13px;
    border-radius: 999px;
    background: #e7efeb;
    overflow: hidden;
}

.track-step em i,
.route-track span {
    display: block;
    height: 100%;
    background: var(--teal);
    border-radius: inherit;
    transition: width 250ms ease;
}

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

.case-card,
.detail-card,
.report-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
}

.case-card {
    min-height: 220px;
    padding: 17px;
    transition: transform 170ms ease, border-color 170ms ease, background 170ms ease;
}

.case-card:hover,
.case-card.is-selected {
    transform: translateY(-2px);
    border-color: var(--ink);
    background: #fff;
}

.case-card.danger {
    border-left: 6px solid var(--red);
}

.case-card.watch {
    border-left: 6px solid var(--yellow);
}

.case-row,
.section-head,
.route-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stage-pill,
.today-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    background: rgba(91, 192, 190, 0.18);
    color: #0a5f5c;
    font-size: 12px;
    font-weight: 760;
    white-space: nowrap;
}

.case-card h2 {
    margin: 18px 0 8px;
    font-size: 24px;
    line-height: 1.08;
}

.case-card p {
    color: var(--muted);
}

.case-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
}

.case-stats span {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.case-stats b,
.case-stats small {
    display: block;
}

.case-stats b {
    font-size: 23px;
}

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

.inspector {
    position: sticky;
    top: 26px;
    min-width: 0;
    border-radius: 8px;
    padding: 20px;
    background: var(--ink);
    color: #f6fff8;
    box-shadow: var(--shadow);
}

.inspector h2 {
    margin: 8px 0 10px;
    font-size: 28px;
    line-height: 1.05;
}

.inspector p {
    color: rgba(246, 255, 248, 0.75);
}

.inspector dl,
.detail-card dl {
    display: grid;
    gap: 12px;
    margin: 16px 0 0;
}

.inspector dl div,
.detail-card dl div {
    border-top: 1px solid rgba(246, 255, 248, 0.16);
    padding-top: 10px;
}

.detail-card dl div {
    border-color: var(--line);
}

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

.inspector dt {
    color: rgba(246, 255, 248, 0.55);
}

dd {
    margin: 3px 0 0;
    overflow-wrap: anywhere;
}

.route-panel {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(246, 255, 248, 0.16);
}

.route-line {
    margin: 8px 0 10px;
}

.route-line strong {
    color: var(--yellow);
}

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

.section-head h2 {
    margin: 4px 0 0;
    font-size: 26px;
}

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

.detail-card,
.report-card {
    padding: 17px;
}

.detail-card h3 {
    margin: 8px 0 0;
    font-size: 23px;
}

.report-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: clamp(30px, 5vw, 54px);
    line-height: 1;
}

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

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

.calendar-row,
.timeline-row {
    display: grid;
    align-items: center;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    gap: 14px;
    min-height: 76px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.calendar-row time {
    font-size: 25px;
    font-weight: 850;
}

.calendar-row span,
.timeline-row small {
    display: block;
    color: var(--muted);
}

.calendar-row strong {
    color: var(--green);
}

.calendar-row.urgent strong,
.calendar-row.risk strong {
    color: var(--red);
}

.timeline {
    margin-top: 14px;
}

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

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--teal);
}

.timeline-row p {
    margin: 4px 0;
    color: var(--ink);
}

.empty {
    padding: 20px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
}

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

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

.dialog-form {
    display: grid;
    gap: 16px;
    padding: 22px;
}

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

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

.dialog-actions button:not(.primary-button) {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0 16px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

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

    .rail {
        position: static;
        height: auto;
    }

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

    .tab {
        text-align: center;
    }

    .inspector {
        position: static;
    }
}

@media (max-width: 760px) {
    .workspace {
        padding: 16px;
    }

    .topbar,
    .section-head {
        display: grid;
    }

    .toolbar {
        justify-content: stretch;
    }

    .search,
    .search input,
    .primary-button {
        width: 100%;
    }

    .metric-strip,
    .progress-map,
    .case-board,
    .detail-grid,
    .report-grid,
    .tabs {
        grid-template-columns: 1fr;
    }

    .case-stats {
        grid-template-columns: 1fr;
    }

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

