:root {
    color-scheme: light;
    --ink: #1f2933;
    --paper: #fbfbf2;
    --blue: #4c6fff;
    --orange: #f9703e;
    --muted: #6b7280;
    --line: rgba(31, 41, 51, 0.14);
    --soft: #eef2f6;
    --ok: #0f9f6e;
    --warn: #b7791f;
    --danger: #c2410c;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(31, 41, 51, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(31, 41, 51, 0.035) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--paper);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0;
}

.brand img {
    flex: 0 0 auto;
}

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

.nav__item {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid rgba(251, 251, 242, 0.14);
    border-radius: var(--radius);
    color: rgba(251, 251, 242, 0.72);
    background: transparent;
    text-align: left;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav__item:hover,
.nav__item.is-active {
    color: var(--paper);
    background: rgba(76, 111, 255, 0.28);
    transform: translateX(2px);
}

.rail__note {
    margin-top: auto;
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: 10px;
    align-items: start;
    color: rgba(251, 251, 242, 0.72);
    font-size: 13px;
    line-height: 1.45;
}

.pulse {
    width: 10px;
    height: 10px;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 0 0 rgba(249, 112, 62, 0.5);
    animation: pulse 1.8s infinite;
}

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

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

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

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

h1 {
    font-size: clamp(32px, 5vw, 64px);
}

h2 {
    font-size: 25px;
}

.topbar__actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.search {
    display: grid;
    gap: 6px;
    min-width: 280px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.search input,
.intake input,
.intake select,
.intake textarea,
.filters select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    outline: none;
}

.search input:focus,
.intake input:focus,
.intake select:focus,
.intake textarea:focus,
.filters select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(76, 111, 255, 0.14);
}

.primary-btn,
.ghost-btn,
.chip {
    min-height: 42px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 10px 13px;
    font-weight: 800;
    white-space: nowrap;
}

.primary-btn {
    color: var(--paper);
    background: var(--blue);
}

.ghost-btn,
.chip {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.65);
    border-color: var(--line);
}

.ghost-btn:hover,
.chip:hover,
.chip.is-active {
    border-color: rgba(76, 111, 255, 0.5);
    background: rgba(76, 111, 255, 0.1);
}

.summary-strip {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 0.5fr)) minmax(250px, 1fr);
    gap: 1px;
    margin: 0 -26px 16px;
    padding: 0 26px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: rgba(251, 251, 242, 0.94);
    backdrop-filter: blur(14px);
}

.metric {
    min-height: 84px;
    display: grid;
    align-content: center;
    gap: 5px;
    padding: 12px 16px;
    border-right: 1px solid var(--line);
}

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

.metric strong {
    font-size: 34px;
    line-height: 1;
}

.metric.hot strong {
    color: var(--orange);
}

.flow {
    min-width: 0;
    display: flex;
    align-items: stretch;
    gap: 3px;
    padding: 14px 0 14px 16px;
}

.flow__seg {
    min-width: 58px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--paper);
    background: var(--ink);
    overflow: hidden;
}

.flow__seg b,
.flow__seg em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flow__seg em {
    font-style: normal;
    opacity: 0.72;
}

.flow__seg--parts,
.flow__seg--repair {
    background: var(--blue);
}

.flow__seg--warranty {
    background: var(--ok);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.filters select {
    max-width: 170px;
}

.screen {
    display: none;
}

.screen.is-active {
    display: block;
    animation: rise 180ms ease-out;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.58);
}

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

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

th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: var(--muted);
    background: #f7f7ee;
    font-size: 12px;
    text-transform: uppercase;
}

td {
    line-height: 1.35;
}

td span,
td small {
    display: block;
}

td small {
    margin-top: 5px;
    color: var(--muted);
}

meter {
    width: 100%;
    height: 8px;
    margin-top: 10px;
}

.stage,
.severity {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    min-height: 26px;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.stage-diagnostics {
    color: var(--ink);
    background: #dde3e8;
}

.stage-parts,
.stage-repair {
    color: var(--paper);
    background: var(--blue);
}

.stage-warranty {
    color: var(--paper);
    background: var(--ok);
}

.severity-critical,
.severity-high {
    color: var(--paper);
    background: var(--orange);
}

.severity-medium {
    color: var(--ink);
    background: #ffd166;
}

.severity-low {
    color: var(--paper);
    background: var(--ok);
}

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

.intake {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 840px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.64);
}

.form-head,
.wide,
.form-status {
    grid-column: 1 / -1;
}

.intake label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.form-status {
    min-height: 22px;
    margin: 0;
    color: var(--orange);
    font-weight: 800;
}

.section-head,
.finance-layout {
    display: grid;
    gap: 18px;
}

.document-list,
.finance-ledger {
    display: grid;
    gap: 8px;
}

.doc-row,
.ledger-row,
.ledger-total {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px 120px;
    gap: 12px;
    align-items: center;
    min-height: 66px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.64);
}

.doc-row span,
.ledger-row small,
.ledger-row em {
    color: var(--muted);
}

.ledger-total {
    grid-template-columns: minmax(0, 1fr) auto;
    color: var(--paper);
    background: var(--ink);
}

.ledger-row {
    grid-template-columns: 100px 130px 160px minmax(0, 1fr);
}

.ledger-row em {
    font-style: normal;
}

.inspector {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 24px 18px;
    border-left: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.42);
}

.graph-board {
    position: relative;
    min-height: 210px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at 25% 35%, rgba(76, 111, 255, 0.24), transparent 18%),
        linear-gradient(135deg, rgba(31, 41, 51, 0.96), rgba(31, 41, 51, 0.82));
    overflow: hidden;
}

.node,
.heat,
.line {
    position: absolute;
    display: block;
}

.node {
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 4px solid var(--paper);
    border-radius: 50%;
    background: var(--blue);
}

.node-a {
    left: 36px;
    bottom: 40px;
}

.node-b {
    left: 132px;
    top: 38px;
    background: var(--orange);
}

.node-c {
    right: 42px;
    bottom: 50px;
    background: var(--paper);
}

.line {
    height: 3px;
    background: rgba(251, 251, 242, 0.7);
    transform-origin: left center;
}

.line-ab {
    left: 59px;
    bottom: 64px;
    width: 116px;
    transform: rotate(-34deg);
}

.line-bc {
    left: 154px;
    top: 63px;
    width: 126px;
    transform: rotate(32deg);
}

.heat {
    border-radius: 50%;
    background: rgba(249, 112, 62, 0.22);
    border: 1px solid rgba(249, 112, 62, 0.5);
    animation: heat 2.4s infinite alternate;
}

.heat-one {
    width: 92px;
    height: 92px;
    left: 92px;
    top: 20px;
}

.heat-two {
    width: 70px;
    height: 70px;
    right: 20px;
    bottom: 26px;
}

.activity {
    overflow: auto;
    display: grid;
    gap: 8px;
    padding-right: 2px;
}

.activity__item {
    display: grid;
    gap: 5px;
    padding: 12px;
    border-left: 3px solid var(--blue);
    background: rgba(255, 255, 255, 0.66);
}

.activity__item span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.activity__item.tone-accent {
    border-left-color: var(--orange);
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 10px rgba(249, 112, 62, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(249, 112, 62, 0);
    }
}

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

@keyframes heat {
    from {
        transform: scale(0.92);
        opacity: 0.55;
    }
    to {
        transform: scale(1.08);
        opacity: 1;
    }
}

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

    .inspector {
        display: none;
    }
}

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

    .rail {
        position: static;
        height: auto;
        padding: 14px;
    }

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

    .rail__note {
        display: none;
    }

    .workspace {
        padding: 16px;
    }

    .topbar,
    .topbar__actions {
        display: grid;
        align-items: stretch;
    }

    .search {
        min-width: 0;
    }

    .summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin: 0 -16px 14px;
        padding: 0 16px;
    }

    .flow {
        grid-column: 1 / -1;
        padding-left: 0;
        overflow-x: auto;
    }

    .intake,
    .doc-row,
    .ledger-row {
        grid-template-columns: 1fr;
    }
}

