:root {
    --ink: #263238;
    --paper: #f0f4f8;
    --mint: #00a676;
    --amber: #ffcf56;
    --line: rgba(38, 50, 56, 0.16);
    --muted: rgba(38, 50, 56, 0.68);
    --panel: rgba(255, 255, 255, 0.72);
    --shadow: 0 18px 40px rgba(38, 50, 56, 0.12);
}

* {
    box-sizing: border-box;
}

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

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

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand img {
    width: 52px;
    height: 52px;
}

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

.brand strong {
    font-size: 1.2rem;
}

.brand span,
.mono,
.rail-note span,
.metric-strip span,
.notebook-grid span,
.report-totals span {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.74rem;
    letter-spacing: 0;
    text-transform: uppercase;
}

.brand span,
.rail-note span,
.rail-note strong {
    color: rgba(240, 244, 248, 0.72);
}

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

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

.tab:hover,
.tab.is-active {
    color: var(--paper);
    background: rgba(0, 166, 118, 0.22);
    transform: translateX(3px);
}

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

.rail-note strong {
    display: block;
    margin-top: 8px;
    line-height: 1.4;
}

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

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

.topbar h1,
.calendar-head h2,
.details-grid h2,
.report-head h2 {
    margin: 4px 0 0;
    font-size: clamp(1.45rem, 2vw, 2.2rem);
    line-height: 1.08;
}

.mono {
    margin: 0;
    color: var(--muted);
}

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

.search span {
    font-size: 0.78rem;
    color: var(--muted);
}

.search input,
.quick-consume select,
.quick-consume input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    padding: 0 12px;
}

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

.metric-strip div {
    min-height: 88px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.62);
}

.metric-strip strong {
    display: block;
    margin-top: 8px;
    font-size: 1.7rem;
}

.screen {
    display: none;
    animation: rise 220ms ease both;
}

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

.case-layout,
.details-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
    gap: 20px;
}

.active-case,
.notebook-panel,
.details-grid > div,
.report-view {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.active-case {
    min-height: 430px;
    padding: clamp(20px, 4vw, 42px);
    background:
        linear-gradient(135deg, rgba(0, 166, 118, 0.12), transparent 52%),
        rgba(255, 255, 255, 0.7);
}

.case-kicker,
.panel-head,
.detail-title,
.report-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.active-case h2 {
    max-width: 780px;
    margin: 28px 0 12px;
    font-size: clamp(2rem, 5vw, 4.8rem);
    line-height: 0.98;
}

.active-case p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

.badge,
.alert-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid rgba(38, 50, 56, 0.18);
    border-radius: 5px;
    padding: 0 9px;
    color: var(--ink);
    background: rgba(255, 207, 86, 0.35);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.75rem;
}

.badge.is-hot {
    color: #fff;
    background: #b84432;
}

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

.notebook-grid div {
    min-height: 92px;
    padding: 14px;
    background: rgba(240, 244, 248, 0.84);
}

.notebook-grid strong {
    display: block;
    margin-top: 8px;
}

.alert-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.quiet,
.status-line {
    color: var(--muted);
}

.notebook-panel,
.details-grid > div,
.report-view {
    padding: 18px;
}

.workflow-steps {
    display: grid;
    gap: 10px;
    margin: 18px 0 28px;
}

.workflow-step {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.68);
    text-align: left;
}

.workflow-step span {
    display: grid;
    place-items: center;
    height: 100%;
    color: var(--paper);
    background: var(--ink);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.workflow-step.is-done {
    border-color: rgba(0, 166, 118, 0.42);
}

.workflow-step.is-done span {
    background: var(--mint);
}

.quick-consume {
    display: grid;
    gap: 12px;
}

.consume-line {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px;
}

.consume-line button,
.report-head button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    color: var(--ink);
    background: var(--amber);
    padding: 0 16px;
    font-weight: 700;
}

.resource-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.resource-chip {
    position: relative;
    display: grid;
    min-width: 138px;
    gap: 2px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.68);
}

.resource-chip::before {
    position: absolute;
    inset: auto 0 0 0;
    height: 4px;
    background: linear-gradient(90deg, var(--mint) var(--level), rgba(38, 50, 56, 0.14) var(--level));
    content: "";
}

.resource-chip small,
.case-row small,
.lane header small,
.lane-test small,
td small,
.detail-columns small {
    display: block;
    color: var(--muted);
}

.lane-board {
    display: grid;
    gap: 12px;
}

.lane {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
    padding: 12px;
}

.lane header {
    border-right: 1px solid var(--line);
    padding-right: 12px;
}

.lane header strong {
    display: block;
    margin: 4px 0;
}

.lane-track {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 10px;
    min-height: 112px;
}

.lane-test {
    position: relative;
    display: grid;
    align-content: start;
    gap: 5px;
    min-height: 104px;
    border: 1px solid rgba(0, 166, 118, 0.34);
    border-radius: 6px;
    color: var(--ink);
    background: rgba(0, 166, 118, 0.12);
    padding: 10px;
    text-align: left;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.lane-test:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(38, 50, 56, 0.14);
}

.lane-test.has-conflict {
    border-color: rgba(184, 68, 50, 0.5);
    background: rgba(255, 207, 86, 0.2);
}

.lane-test em {
    color: #9b3527;
    font-size: 0.78rem;
    font-style: normal;
}

.case-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.case-row {
    display: grid;
    gap: 4px;
    width: 100%;
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.62);
    padding: 10px 12px;
    text-align: left;
}

.case-row.is-selected {
    border-color: var(--mint);
    box-shadow: inset 4px 0 0 var(--mint);
}

.case-details {
    margin-top: 14px;
}

.detail-title {
    display: block;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.detail-title h3 {
    margin: 8px 0;
    font-size: 1.35rem;
}

.detail-title p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

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

.detail-columns ul {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.detail-columns li {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
}

.detail-columns em {
    display: block;
    margin-top: 4px;
    color: #9b3527;
    font-size: 0.82rem;
    font-style: normal;
}

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

.report-totals div {
    padding: 14px;
    background: rgba(240, 244, 248, 0.9);
}

.report-totals strong {
    display: block;
    margin-top: 6px;
    font-size: 1.55rem;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 18px;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

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

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

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

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

    .tab {
        text-align: center;
        padding: 0 8px;
    }

    .case-layout,
    .details-grid,
    .lane {
        grid-template-columns: 1fr;
    }

    .lane header {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 0 0 12px;
    }
}

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

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

    .metric-strip,
    .notebook-grid,
    .report-totals,
    .detail-columns {
        grid-template-columns: 1fr;
    }

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

    .active-case {
        min-height: 0;
    }

    .active-case h2 {
        font-size: 2rem;
    }

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

    .consume-line {
        grid-template-columns: 1fr;
    }
}
