:root {
    --ink: #263238;
    --paper: #f0f4f8;
    --mint: #00a676;
    --signal: #ffcf56;
    --line: rgba(38, 50, 56, 0.16);
    --muted: rgba(38, 50, 56, 0.64);
    --white: #ffffff;
    --danger: #e85f5c;
    --shadow: 0 18px 45px rgba(38, 50, 56, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(38, 50, 56, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(38, 50, 56, 0.035) 1px, transparent 1px),
        var(--paper);
    background-size: 32px 32px;
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.side-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 24px;
    background: var(--ink);
    color: var(--paper);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo {
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
}

.brand-block strong,
.brand-block span {
    display: block;
}

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

.brand-block span,
.version-stack span,
.kicker,
.search-box label,
.notebook-grid b,
.timeline-event small,
.lane-label span {
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    letter-spacing: 0;
    text-transform: uppercase;
}

.brand-block span {
    color: rgba(240, 244, 248, 0.68);
    font-size: 12px;
}

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

.tab {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(240, 244, 248, 0.16);
    border-radius: 8px;
    background: rgba(240, 244, 248, 0.04);
    color: var(--paper);
    text-align: left;
    padding: 0 12px;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
    background: rgba(0, 166, 118, 0.18);
    border-color: rgba(0, 166, 118, 0.72);
    transform: translateX(3px);
}

.version-stack {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.version-stack span {
    border: 1px solid rgba(240, 244, 248, 0.18);
    border-radius: 999px;
    padding: 6px 9px;
    color: rgba(240, 244, 248, 0.74);
    font-size: 11px;
}

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

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

.kicker {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 11px;
}

h1,
h2 {
    margin: 0;
    line-height: 1.05;
    letter-spacing: 0;
}

h1 {
    max-width: 820px;
    font-size: clamp(30px, 4vw, 54px);
}

h2 {
    font-size: clamp(24px, 3vw, 42px);
}

.search-box {
    min-width: 260px;
}

.search-box label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
}

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

.search-box input:focus {
    border-color: var(--mint);
    box-shadow: 0 0 0 3px rgba(0, 166, 118, 0.14);
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
    margin-bottom: 18px;
}

.metric-strip div {
    background: rgba(255, 255, 255, 0.78);
    padding: 16px;
}

.metric-strip span {
    display: block;
    font-size: 30px;
    font-weight: 800;
}

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

.notice {
    margin-bottom: 18px;
    border: 1px dashed rgba(232, 95, 92, 0.55);
    border-radius: 8px;
    padding: 12px 14px;
    background: rgba(255, 207, 86, 0.22);
}

.view {
    display: none;
    animation: riseIn 220ms ease both;
}

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

.case-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
}

.case-main,
.case-list,
.inspector,
.timeline-panel,
.calendar-board,
.report-layout > section,
.lab-note {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
}

.case-main,
.inspector,
.timeline-panel,
.calendar-board,
.report-layout > section,
.lab-note {
    padding: 20px;
}

.case-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.status-badge {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 7px 10px;
    background: rgba(38, 50, 56, 0.08);
    color: var(--ink);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.status-active,
.status-ready {
    background: rgba(0, 166, 118, 0.15);
}

.status-hold {
    background: rgba(255, 207, 86, 0.36);
}

.stage-track {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 24px 0;
}

.stage-track span {
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: rgba(240, 244, 248, 0.68);
}

.stage-track span.is-done {
    border-color: rgba(0, 166, 118, 0.42);
    background: rgba(0, 166, 118, 0.12);
}

.stage-track span.is-current {
    outline: 3px solid rgba(255, 207, 86, 0.48);
}

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

.stage-track small {
    margin-top: 8px;
    color: var(--muted);
}

.notebook-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--line);
}

.notebook-grid div {
    min-height: 74px;
    background: var(--white);
    padding: 12px;
}

.notebook-grid b,
.notebook-grid span {
    display: block;
}

.notebook-grid b {
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 6px;
}

.resource-readout {
    margin: 20px 0 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 14px;
}

.resource-readout span {
    position: relative;
    height: 14px;
    border-radius: 999px;
    background: rgba(38, 50, 56, 0.1);
    overflow: hidden;
}

.resource-readout span::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--value);
    background: linear-gradient(90deg, var(--mint), var(--signal));
}

.resource-readout strong {
    font-size: 26px;
}

.resource-readout small {
    grid-column: 1 / -1;
    color: var(--muted);
}

.case-note {
    margin: 0 0 18px;
    color: var(--muted);
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.primary-action,
.secondary-action {
    min-height: 42px;
    border-radius: 8px;
    padding: 0 14px;
}

.primary-action {
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
}

.secondary-action {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink);
}

.case-list {
    display: grid;
    align-content: start;
    gap: 1px;
    overflow: hidden;
    background: var(--line);
}

.case-row {
    width: 100%;
    border: 0;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    text-align: left;
    padding: 14px;
}

.case-row.is-selected {
    background: rgba(0, 166, 118, 0.13);
}

.case-row span,
.case-row small {
    display: block;
}

.case-row span {
    font-weight: 800;
}

.case-row small {
    margin-top: 4px;
    color: var(--muted);
}

.split-view,
.report-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.62fr);
    gap: 18px;
}

.inspector dl {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px 18px;
    margin: 22px 0 0;
}

.inspector dt {
    color: var(--muted);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.inspector dd {
    margin: 0;
}

.timeline-panel ol {
    list-style: none;
    padding: 0;
    margin: 18px 0 0;
}

.timeline-event {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 96px;
    gap: 12px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding: 13px 0;
}

.timeline-event time {
    color: var(--muted);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

.timeline-event small {
    justify-self: end;
    border-radius: 999px;
    padding: 5px 8px;
    background: rgba(38, 50, 56, 0.07);
    font-size: 10px;
}

.severity-warning small {
    background: rgba(255, 207, 86, 0.38);
}

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

.lanes {
    display: grid;
    gap: 14px;
}

.lane {
    display: grid;
    grid-template-columns: 220px minmax(460px, 1fr);
    gap: 12px;
    align-items: stretch;
}

.lane-label {
    border-right: 3px solid var(--ink);
    padding: 10px 12px 10px 0;
}

.lane-label b,
.lane-label span {
    display: block;
}

.lane-label span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.lane-track {
    position: relative;
    min-height: 88px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        repeating-linear-gradient(90deg, rgba(38, 50, 56, 0.07), rgba(38, 50, 56, 0.07) 1px, transparent 1px, transparent 10%),
        rgba(255, 255, 255, 0.72);
    overflow: hidden;
}

.tick {
    position: absolute;
    top: 7px;
    transform: translateX(-50%);
    color: rgba(38, 50, 56, 0.48);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 10px;
}

.booking-chip {
    position: absolute;
    top: 30px;
    min-height: 46px;
    border: 1px solid rgba(38, 50, 56, 0.18);
    border-radius: 8px;
    background: color-mix(in srgb, var(--chip), white 78%);
    color: var(--ink);
    padding: 7px 9px;
    text-align: left;
    overflow: hidden;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.booking-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(38, 50, 56, 0.15);
}

.booking-chip b,
.booking-chip span,
.booking-chip em {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.booking-chip b {
    font-size: 12px;
}

.booking-chip span,
.booking-chip em {
    font-size: 11px;
}

.booking-conflict {
    background: rgba(255, 207, 86, 0.5);
    outline: 2px dashed rgba(232, 95, 92, 0.72);
}

.report-bars {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.report-row {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr) 36px;
    gap: 12px;
    align-items: center;
}

.report-row > div {
    height: 16px;
    border-radius: 999px;
    background: rgba(38, 50, 56, 0.09);
    overflow: hidden;
}

.report-row i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ink), var(--mint));
}

.lab-note {
    align-self: stretch;
    display: grid;
    align-content: center;
}

.lab-note b,
.lab-note span {
    display: block;
}

.lab-note span {
    margin: 8px 0;
    font-size: clamp(54px, 7vw, 96px);
    font-weight: 900;
    color: var(--mint);
}

.lab-note p {
    margin: 0;
    color: var(--muted);
}

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

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

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

    .side-rail {
        position: static;
        height: auto;
        padding: 16px;
    }

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

    .topbar,
    .case-head,
    .calendar-head {
        align-items: stretch;
        flex-direction: column;
    }

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

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

    .case-layout,
    .split-view,
    .report-layout {
        grid-template-columns: 1fr;
    }

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

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

    .lane-track {
        overflow-x: auto;
    }
}

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

    .screen-tabs,
    .metric-strip,
    .stage-track,
    .notebook-grid {
        grid-template-columns: 1fr;
    }

    .timeline-event,
    .inspector dl,
    .report-row {
        grid-template-columns: 1fr;
    }

    .timeline-event small {
        justify-self: start;
    }

    .resource-readout {
        grid-template-columns: 1fr;
    }
}
