:root {
    --bg: #09130b;
    --bg-2: #0d1a0d;
    --panel: #111a11;
    --panel-2: #162116;
    --panel-3: #1c291c;
    --border: #213321;
    --border-strong: #355235;
    --text: #d7e4d7;
    --muted: #90a78f;
    --accent: #52e619;
    --accent-soft: rgba(82, 230, 25, 0.12);
    --archive: #9a8860;
    --archive-soft: rgba(154, 136, 96, 0.12);
    --good: #52e619;
    --warn: #e8a020;
    --bad: #ef6351;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(82,230,25,0.05), transparent 28%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    color: var(--text);
}

a { color: var(--accent); }
button, input, select, textarea { font: inherit; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(280px, 1.4fr) minmax(320px, 0.9fr) minmax(240px, 0.9fr);
    gap: 18px;
    align-items: center;
    padding: 18px 24px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(16px);
    background: rgba(10, 18, 10, 0.92);
    border-bottom: 1px solid var(--border);
}
.topbar__brand,
.topbar__status {
    display: grid;
    gap: 6px;
}
.topbar__brand {
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 14px;
}
.brand-home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.brand-home-link:hover,
.brand-home-link:focus-visible {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.18);
    transform: translateY(-1px);
}
.brand-home-link__logo {
    display: block;
    width: 188px;
    max-width: 100%;
    height: auto;
}
.topbar__brand h1 {
    margin: 0;
    font-size: 1.5rem;
}
.topbar__brand p,
.topbar__status .muted {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}
.topbar__nav {
    justify-self: center;
}

.workspace {
    padding: 22px;
}
.surface {
    display: none;
    gap: 18px;
}
.surface.is-active {
    display: grid;
}
.surface-intro {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.95fr);
    gap: 18px;
    align-items: start;
}
.surface-intro h2 {
    margin: 10px 0 8px;
    font-size: 1.85rem;
}
.surface-intro p {
    margin: 0;
    color: var(--muted);
    max-width: 74ch;
    line-height: 1.6;
}
.testing-banner {
    margin-top: 14px;
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(232, 160, 32, 0.34);
    background: linear-gradient(180deg, rgba(53,35,10,0.72), rgba(12,18,12,0.98));
    box-shadow: var(--shadow);
}
.testing-banner strong {
    color: #f7d9a1;
}
.testing-banner span {
    color: #e6d2ae;
    line-height: 1.5;
}

.workflow-rail {
    display: grid;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(17,26,17,0.95), rgba(12,18,12,0.98));
    box-shadow: var(--shadow);
}
.workflow-rail--secondary {
    border-color: rgba(154,136,96,0.28);
}
.workflow-step {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 12px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.workflow-step:last-child { border-bottom: 0; }
.workflow-step span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    color: var(--muted);
    font-weight: 700;
}
.workflow-step strong { display: block; margin-bottom: 4px; }
.workflow-step small { color: var(--muted); line-height: 1.45; }
.workflow-step.is-active span {
    background: rgba(82,230,25,0.16);
    color: #edffe7;
    border: 1px solid rgba(82,230,25,0.25);
}
.workflow-step.is-complete span {
    background: rgba(154,136,96,0.15);
    color: #f1e8d6;
    border: 1px solid rgba(154,136,96,0.25);
}
.workflow-step--next {
    opacity: 0.88;
}

.surface-grid {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.worksheet {
    position: sticky;
    top: 104px;
}
.worksheet-form {
    display: grid;
    gap: 16px;
}
.worksheet-card,
.result-card {
    background: linear-gradient(180deg, rgba(17,26,17,0.97), rgba(12,18,12,0.98));
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.worksheet-card {
    padding: 16px;
}
.worksheet-card--feature {
    border-color: rgba(82,230,25,0.28);
}
.worksheet-card__head,
.result-card__head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.worksheet-card__head h3,
.result-card__head h3 {
    margin: 0;
    font-size: 1rem;
}

.field-grid {
    display: grid;
    gap: 12px;
}
.field-grid--one { grid-template-columns: 1fr; }
.field-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field {
    display: grid;
    gap: 6px;
}
.field--full { grid-column: 1 / -1; }
.field span:first-child {
    color: var(--text);
    font-size: 0.92rem;
}
.field-input {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: rgba(7, 13, 7, 0.88);
}
.field-input input,
.field-input select,
textarea,
select {
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--text);
    outline: none;
}
.field-input span:last-child {
    color: var(--muted);
    font-size: 0.84rem;
    white-space: nowrap;
}
textarea,
select {
    background: rgba(7, 13, 7, 0.88);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 12px;
}
textarea {
    min-height: 110px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.button-group--tight {
    margin-bottom: 0;
}
.toggle-chip {
    position: relative;
    cursor: pointer;
}
.toggle-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.toggle-chip span {
    display: inline-flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: var(--muted);
    font-weight: 600;
}
.toggle-chip input:checked + span {
    border-color: rgba(82,230,25,0.25);
    background: rgba(82,230,25,0.13);
    color: #efffe9;
}
.toggle-chip--switch input:checked + span {
    border-color: rgba(154,136,96,0.28);
    background: rgba(154,136,96,0.12);
    color: #f2e7cf;
}
.worksheet-note,
.muted {
    color: var(--muted);
    line-height: 1.5;
}
.worksheet-note { margin: 0; font-size: 0.9rem; }

.result-surface {
    display: grid;
    gap: 18px;
}
.result-card {
    padding: 18px;
}
.result-card--hero {
    border-color: rgba(82,230,25,0.26);
}
.result-card--notes {
    border-color: rgba(232,160,32,0.22);
}
.action-link {
    border: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
    gap: 1px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--border);
}
.stat-card {
    background: linear-gradient(180deg, rgba(19,28,19,0.98), rgba(12,18,12,0.98));
    padding: 18px 16px;
    min-height: 116px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.stat-card--featured {
    background: linear-gradient(180deg, rgba(26,46,23,0.94), rgba(12,18,12,0.98));
}
.stat-card--warn {
    background: linear-gradient(180deg, rgba(53,35,10,0.70), rgba(12,18,12,0.98));
}
.stat-card span {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 10px;
}
.stat-big {
    font-size: 1.6rem;
    line-height: 1.05;
    font-weight: 800;
    margin-bottom: 6px;
}
.stat-sub,
.stat-meta {
    color: var(--muted);
    font-size: 0.9rem;
}
.badge-row {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.result-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.chart {
    min-height: 330px;
}
.chart--hero {
    min-height: 480px;
}
.duct-diagram {
    background: linear-gradient(180deg, rgba(13,21,13,0.95), rgba(10,16,10,0.95));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    overflow: auto;
    cursor: zoom-in;
}
.duct-diagram svg {
    display: block;
    min-width: 100%;
    height: auto;
}
.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
thead {
    background: rgba(154,136,96,0.08);
}
th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}
tbody td {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
}
.warning-list {
    margin: 0;
    padding-left: 18px;
    color: #e8dbbb;
    display: grid;
    gap: 10px;
}
.warning-list li { line-height: 1.5; }

.chip,
.status-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(82,230,25,0.24);
    background: var(--accent-soft);
    color: #eafee5;
    font-size: 0.78rem;
    font-weight: 700;
}
.chip--brand {
    border-color: rgba(154,136,96,0.28);
    background: var(--archive-soft);
    color: #eadfc9;
}
.chip--muted {
    border-color: rgba(154,136,96,0.22);
    background: rgba(154,136,96,0.08);
    color: #e8dcc4;
}
.status-pill {
    font-size: 0.88rem;
}
.eyebrow {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.segmented-control {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: rgba(17, 26, 17, 0.9);
}
.segmented-control__button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    border-radius: 10px;
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
}
.segmented-control__button.is-active {
    border-color: rgba(82,230,25,0.25);
    background: rgba(82,230,25,0.14);
    color: #efffe9;
}
.badge--good,
.badge--warn,
.badge--bad {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.76rem;
}
.badge--good {
    background: rgba(82,230,25,0.12);
    color: #d8ffd8;
    border: 1px solid rgba(82,230,25,0.24);
}
.badge--warn {
    background: rgba(232,160,32,0.12);
    color: #ffe3ad;
    border: 1px solid rgba(232,160,32,0.24);
}
.badge--bad {
    background: rgba(239,99,81,0.12);
    color: #ffd3cf;
    border: 1px solid rgba(239,99,81,0.24);
}

@media (max-width: 1320px) {
    .topbar {
        grid-template-columns: 1fr;
        align-items: start;
    }
    .topbar__nav {
        justify-self: start;
    }
    .surface-intro,
    .surface-grid,
    .result-grid-2 {
        grid-template-columns: 1fr;
    }
    .worksheet {
        position: static;
    }
}

@media (max-width: 820px) {
    .workspace,
    .topbar {
        padding-left: 14px;
        padding-right: 14px;
    }
    .topbar__brand {
        grid-template-columns: 1fr;
    }
    .brand-home-link {
        justify-self: start;
    }
    .brand-home-link__logo {
        width: 156px;
    }
    .field-grid--two,
    .result-grid-2 {
        grid-template-columns: 1fr;
    }
    .segmented-control {
        width: 100%;
    }
    .segmented-control__button {
        padding-left: 10px;
        padding-right: 10px;
    }
}
