:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #080a0d;
    color: #f4f6f8;
    font-synthesis: none;
    --ink: #f4f6f8;
    --muted: #8e969f;
    --faint: #59616b;
    --line: #232931;
    --panel: #101419;
    --panel-strong: #151b21;
    --accent: #80f0bb;
    --accent-deep: #173c31;
    --amber: #f3c76b;
    --red: #ff756f;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #080a0d; }
body { min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.planner-page { width: min(1480px, 100%); margin: 0 auto; padding: 22px 34px 18px; }
.topbar { height: 72px; display: flex; align-items: flex-start; justify-content: space-between; }
h1, h2, p { margin: 0; }
h1 { font-size: 28px; line-height: 1; letter-spacing: -0.04em; font-weight: 650; }
.eyebrow { color: var(--accent); font-size: 10px; line-height: 1.2; font-weight: 750; letter-spacing: 0.16em; margin-bottom: 8px; }

.settings-button, .reset-button { border: 1px solid var(--line); color: var(--ink); background: #101419; border-radius: 8px; }
.settings-button { display: flex; align-items: center; gap: 9px; padding: 10px 14px; font-size: 13px; }
.settings-button:hover, .reset-button:hover { border-color: #3b444e; background: #151a20; }
.settings-button__mark { color: var(--accent); font-size: 19px; line-height: 0; }

.planner-grid { display: grid; grid-template-columns: minmax(380px, 0.78fr) minmax(620px, 1.52fr); min-height: calc(100vh - 146px); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel); box-shadow: 0 22px 80px rgba(0,0,0,.22); }
.input-panel { padding: 22px 24px 18px; border-right: 1px solid var(--line); background: #0d1115; }
.input-section + .input-section { border-top: 1px solid var(--line); margin-top: 21px; padding-top: 20px; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-heading > span { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #304039; border-radius: 50%; color: var(--accent); font: 700 10px/1 ui-monospace, SFMono-Regular, monospace; }
.section-heading .eyebrow { margin-bottom: 3px; color: var(--faint); }
.section-heading h2 { font-size: 18px; letter-spacing: -0.025em; }

.field { display: grid; gap: 7px; margin-bottom: 13px; color: #a9b0b8; font-size: 11px; font-weight: 650; letter-spacing: .02em; }
.field > label { color: #a9b0b8; }
.field label em { margin-left: 4px; color: #5f6872; font-style: normal; font-weight: 500; }
.field input, .field select { width: 100%; height: 40px; border: 1px solid #293039; border-radius: 7px; outline: none; background: #151a20; color: var(--ink); padding: 0 11px; font-size: 14px; font-weight: 560; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: #555e68; }
.field input:focus, .field select:focus { border-color: #5ab58c; box-shadow: 0 0 0 3px rgba(128,240,187,.08); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #87919c 50%), linear-gradient(135deg, #87919c 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: #a8504c; box-shadow: 0 0 0 3px rgba(255,117,111,.06); }
.field-error { margin: -1px 0 0; color: #ef8c86; font-size: 10px; font-weight: 560; line-height: 1.35; letter-spacing: 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 42px; }
.input-with-unit b { position: absolute; right: 11px; top: 13px; color: #636c76; font-size: 10px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 13px; border: 1px solid #293039; border-radius: 8px; background: #0a0e12; }
.segmented button { height: 33px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.segmented button.active { color: #07140f; background: var(--accent); }
.segmented--small button { font-size: 11px; }
.reset-button { width: 100%; height: 37px; margin-top: 3px; color: var(--muted); font-size: 12px; }
.control-row { display: grid; grid-template-columns: 1.25fr .75fr; gap: 9px; }
.current-tag { margin-left: auto; padding: 5px 7px; border: 1px solid #273a32; border-radius: 5px; color: #70b795; font: 700 8px/1 ui-monospace, SFMono-Regular, monospace; letter-spacing: .08em; }
.optional-field { margin-top: -1px; }
.formula-note { margin: -3px 1px 10px; color: #66707a; font-size: 10px; line-height: 1.4; }
.formula-note strong { color: #919ba5; font-weight: 650; }

.plan-panel { position: relative; padding: 28px; overflow: hidden; background: radial-gradient(circle at 80% 12%, rgba(53,107,84,.14), transparent 35%), #11161b; }
.plan-panel::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .3; background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px); background-size: 100% 42px; }
.plan-empty { position: relative; display: flex; min-height: 100%; flex-direction: column; justify-content: center; max-width: 570px; padding-left: 34px; }
.plan-empty h2 { max-width: 470px; font-size: clamp(30px, 3vw, 48px); letter-spacing: -.045em; line-height: 1.02; }
.plan-empty > p:not(.eyebrow) { max-width: 510px; margin-top: 15px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.plan-empty__ladder { position: absolute; left: 0; top: 50%; display: grid; gap: 25px; transform: translateY(-50%); }
.plan-empty__ladder i { display: block; width: 12px; height: 1px; background: #3b454f; }
.plan-empty__ladder i:nth-child(3) { width: 22px; background: var(--accent); }
.plan-empty--invalid .eyebrow { color: var(--red); }
.plan-empty--invalid .plan-empty__ladder i:nth-child(3) { background: var(--red); }
.empty-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 38px; }
.empty-metrics span { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; color: #6f7882; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.empty-metrics b { color: #77818b; font: 500 22px/1 ui-monospace, SFMono-Regular, monospace; }

.plan-ready { position: relative; min-height: 100%; }
.plan-header { display: flex; align-items: flex-start; justify-content: space-between; min-height: 69px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.plan-title-line { display: flex; align-items: center; gap: 11px; }
.plan-title-line h2 { font-size: 26px; line-height: 1; letter-spacing: -.035em; }
.direction-pill { padding: 4px 7px; border: 1px solid #38624f; border-radius: 5px; color: var(--accent); background: rgba(128,240,187,.06); font: 750 9px/1 ui-monospace, SFMono-Regular, monospace; letter-spacing: .09em; }
.product-caption { margin-top: 8px; color: #6f7882; font-size: 10px; }
.copy-cluster { min-width: 95px; text-align: right; }
.copy-button { min-width: 91px; height: 35px; border: 1px solid #365344; border-radius: 7px; color: #bdf8d9; background: #14251e; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.copy-button:hover:not(:disabled) { background: #1b3429; border-color: #4e8069; }
.copy-button:disabled { cursor: not-allowed; opacity: .35; }
.copy-feedback { display: block; min-height: 13px; margin-top: 5px; color: var(--accent); font-size: 9px; }
.copy-feedback--error { color: var(--red); }

.plan-content { display: grid; grid-template-columns: minmax(390px, 1.25fr) minmax(250px, .75fr); min-height: calc(100% - 69px); }
.plan-summary { padding: 21px 24px 0 0; border-right: 1px solid var(--line); }
.price-ladder { padding: 21px 0 0 24px; }
.risk-hero { padding: 17px 19px 16px; border: 1px solid #29463a; border-radius: 10px; background: linear-gradient(135deg, rgba(128,240,187,.09), rgba(128,240,187,.018)); }
.risk-hero p { color: #a6b2ac; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.risk-hero strong { display: block; margin: 7px 0 5px; color: var(--accent); font: 620 clamp(31px, 3vw, 43px)/1 ui-monospace, SFMono-Regular, monospace; letter-spacing: -.055em; }
.risk-hero span { color: #748079; font-size: 10px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 9px; margin-top: 11px; overflow: hidden; }
.metric { min-height: 81px; padding: 13px 15px; background: rgba(255,255,255,.012); }
.metric:nth-child(odd) { border-right: 1px solid var(--line); }
.metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.metric > span { display: block; color: #717b85; font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 7px; color: #e6eaed; font: 600 18px/1 ui-monospace, SFMono-Regular, monospace; letter-spacing: -.035em; }
.metric small { display: block; margin-top: 7px; color: #606a74; font-size: 9px; }
.metric--primary strong { color: var(--accent); }
.metric--danger strong { color: #ff9993; font-size: 15px; }
.levels-strip { display: grid; grid-template-columns: .85fr .85fr 1.3fr; margin-top: 11px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.levels-strip > div { min-height: 63px; padding: 11px 13px; }
.levels-strip > div + div { border-left: 1px solid var(--line); }
.levels-strip span, .levels-strip small { display: block; color: #6d7680; font-size: 8px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.levels-strip strong { display: block; margin-top: 7px; font: 600 15px/1 ui-monospace, SFMono-Regular, monospace; }
.levels-strip small { margin-top: 6px; color: #59636d; font-size: 8px; letter-spacing: 0; text-transform: none; }
.status-card { display: grid; grid-template-columns: 37px 1fr; gap: 12px; align-items: center; min-height: 75px; margin-top: 11px; padding: 11px 14px; border: 1px solid; border-radius: 9px; }
.status-card__icon { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid currentColor; border-radius: 50%; font: 750 16px/1 ui-monospace, SFMono-Regular, monospace; }
.status-card span { display: block; font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.status-card strong { display: block; margin: 4px 0 3px; color: var(--ink); font-size: 14px; }
.status-card p { color: #738079; font-size: 9px; line-height: 1.35; }
.status-card--ok { border-color: #2a513f; color: var(--accent); background: rgba(128,240,187,.035); }
.status-card--warning { border-color: #5d4d2c; color: var(--amber); background: rgba(243,199,107,.04); }
.status-card--warning p { color: #978661; }
.status-card--invalid { border-color: #603532; color: var(--red); background: rgba(255,117,111,.045); }
.status-card--invalid p { color: #a0716e; }
.limit-note { display: flex; justify-content: space-between; gap: 15px; margin-top: 11px; color: #7c858f; font-size: 9px; }
.limit-note span { color: #525b65; text-transform: uppercase; letter-spacing: .08em; }
.zero-position { display: grid; gap: 4px; margin-bottom: 10px; padding: 10px 12px; border: 1px solid #624e2d; border-radius: 8px; color: var(--amber); background: rgba(243,199,107,.045); font-size: 10px; }
.zero-position span { color: #917e58; }

.ladder-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.ladder-heading h3 { font-size: 15px; letter-spacing: -.02em; }
.ladder-heading > span { margin-top: 16px; color: #68727c; font: 500 9px/1 ui-monospace, SFMono-Regular, monospace; }
.price-ladder ol { display: grid; gap: 0; margin: 18px 0 14px; padding: 0; list-style: none; }
.ladder-item { display: grid; grid-template-columns: 71px minmax(32px, 1fr) 58px; align-items: center; min-height: 43px; color: #7e8791; }
.ladder-price { font: 540 12px/1 ui-monospace, SFMono-Regular, monospace; }
.ladder-item i { height: 1px; margin: 0 9px; background: #303841; }
.ladder-item strong { font: 750 9px/1 ui-monospace, SFMono-Regular, monospace; text-align: right; letter-spacing: .04em; }
.ladder-item--target { color: #a9b2bb; }
.ladder-item--target i { background: #414a54; }
.ladder-item--entry { min-height: 48px; color: var(--accent); }
.ladder-item--entry i { height: 2px; background: var(--accent); box-shadow: 0 0 10px rgba(128,240,187,.32); }
.ladder-item--entry strong { padding: 4px 5px; border-radius: 4px; color: #0a1a12; background: var(--accent); }
.ladder-item--stop { color: var(--amber); }
.ladder-item--stop i { background: #856b37; }
.ladder-item--knockout { color: var(--red); }
.ladder-item--knockout i { background: #7c3f3b; }
.ko-detail { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding-top: 13px; border-top: 1px solid var(--line); }
.ko-detail span { color: #626c76; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.ko-detail strong { color: #d8dde1; font: 600 12px/1 ui-monospace, SFMono-Regular, monospace; }
.ko-detail small { grid-column: 1 / -1; color: #505963; font-size: 8.5px; }

.settings-backdrop { position: fixed; z-index: 50; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.58); cursor: default; backdrop-filter: blur(2px); }
.settings-drawer { position: fixed; z-index: 51; top: 0; right: 0; width: min(430px, 100%); height: 100vh; overflow-y: auto; padding: 27px 29px 22px; border-left: 1px solid #2a323a; background: #0e1318; box-shadow: -24px 0 70px rgba(0,0,0,.4); }
.settings-drawer > header { display: flex; justify-content: space-between; align-items: flex-start; }
.settings-drawer h2 { font-size: 24px; letter-spacing: -.035em; }
.close-button { width: 34px; height: 34px; border: 1px solid #2b333c; border-radius: 7px; color: #aab2ba; background: #151a20; font-size: 21px; line-height: 1; }
.drawer-intro { margin: 18px 0 21px; color: #707a84; font-size: 11px; line-height: 1.55; }
.field-label { margin-bottom: 7px; color: #a9b0b8; font-size: 11px; font-weight: 650; }
.derived-value { display: flex; justify-content: space-between; align-items: center; min-height: 39px; margin: -4px 0 16px; padding: 0 11px; border: 1px solid #223229; border-radius: 7px; background: #111b17; }
.derived-value span { color: #708078; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.derived-value strong { color: var(--accent); font: 600 13px/1 ui-monospace, SFMono-Regular, monospace; }
.settings-divider { height: 1px; margin: 5px 0 17px; background: var(--line); }
.settings-drawer > footer { display: flex; align-items: center; gap: 8px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); color: #667079; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.saved-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(128,240,187,.45); }

.estimate-notice { display: flex; align-items: center; gap: 8px; min-height: 44px; color: #6e7680; font-size: 10.5px; }
.estimate-notice span { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid #39414a; border-radius: 50%; color: #8b949d; font: 700 10px serif; }

.boot-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 15px; background: #080a0d; color: #89929b; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.boot-screen span { width: 24px; height: 24px; border: 2px solid #26312c; border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui { display: none; position: fixed; inset: auto 16px 16px; z-index: 1000; padding: 12px 16px; border: 1px solid #733a37; border-radius: 8px; background: #291514; color: #ffd7d4; font-size: 13px; }
#blazor-error-ui .reload { color: white; margin-left: 8px; }
#blazor-error-ui .dismiss { border: 0; color: white; background: transparent; font-size: 17px; }
.not-found { padding: 15vh 8vw; }

@media (max-width: 980px) {
    .planner-page { padding: 18px; }
    .planner-grid { grid-template-columns: 1fr; }
    .input-panel { border-right: 0; border-bottom: 1px solid var(--line); }
    .plan-panel { min-height: 500px; }
    .plan-content { grid-template-columns: 1fr; }
    .plan-summary { padding-right: 0; border-right: 0; }
    .price-ladder { margin-top: 22px; padding-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
    .planner-page { padding: 14px; }
    .topbar { height: 68px; }
    .settings-button { padding: 9px 10px; }
    .field-grid, .empty-metrics { grid-template-columns: 1fr; }
    .control-row, .metric-grid { grid-template-columns: 1fr; }
    .metric:nth-child(odd), .metric:nth-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
    .levels-strip { grid-template-columns: 1fr; }
    .levels-strip > div + div { border-left: 0; border-top: 1px solid var(--line); }
    .plan-panel { padding: 22px; }
    .plan-empty { padding-left: 23px; }
}
