/* Hallmark · genre: modern-minimal · macrostructure: Workbench · theme: Cobalt · nav: N9 · footer: Ft2
 * design-system: design.md · designed-as-app · enrichment: none · contrast: pass (40–41)
 * honest: pass (46) · chrome: pass (47) · tokens: pass (48) · responsive: pass (49)
 * icons: pass (30) · mobile: pass (34, 49, 50–57) · slop: pass (42–45)
 * pre-emit critique: P5 H5 E4 S5 R5 V4
 */
@import url("../tokens.css");

:root {
  --bg: var(--color-paper-2);
  --panel: var(--color-surface);
  --panel-2: var(--color-paper);
  --ink: var(--color-ink);
  --ink-2: var(--color-ink-2);
  --ink-3: var(--color-muted);
  --line: var(--color-rule);
  --line-2: var(--color-paper-3);
  --accent: var(--color-accent);
  --accent-soft: var(--color-accent-soft);
  --ok: var(--color-ok);
  --warn: var(--color-warn);
  --bad: var(--color-bad);
  --band-outer: var(--color-band-outer);
  --band-inner: var(--color-band-inner);
  --shadow: var(--shadow-card);
  --r: var(--radius-card);
  --font: var(--font-body);
  --mono: var(--font-outlier);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--color-paper-2);
    --panel: var(--color-surface);
    --panel-2: var(--color-paper);
    --ink: var(--color-ink);
    --ink-2: var(--color-ink-2);
    --ink-3: var(--color-muted);
    --line: var(--color-rule);
    --line-2: var(--color-paper-3);
    --accent: var(--color-accent);
    --accent-soft: var(--color-accent-soft);
    --ok: var(--color-ok);
    --warn: var(--color-warn);
    --bad: var(--color-bad);
    --band-outer: var(--color-band-outer);
    --band-inner: var(--color-band-inner);
    --shadow: var(--shadow-card);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
b { font-weight: 650; }

/* ── 상단바 ────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { font-size: 22px; line-height: 1; }
.topbar h1 { font-size: 15.5px; }
.sub { margin: 1px 0 0; font-size: 11.5px; color: var(--ink-3); }
.topactions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.modeswitch { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.modeswitch button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 6px;
  font-size: 12.5px; color: var(--ink-2);
}
.modeswitch button.on { background: var(--accent); color: var(--color-accent-ink); font-weight: 600; }

button.primary {
  border: 0; background: var(--accent); color: var(--color-accent-ink); font-weight: 600;
  padding: 9px 16px; border-radius: 8px; font-size: 13px;
}
button.primary:disabled { opacity: .55; cursor: progress; }
button.ghost {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
  padding: 7px 12px; border-radius: 7px; font-size: 12.5px;
}
button.ghost:hover { border-color: var(--line); color: var(--ink-2); }
button.ghost.sm { padding: 5px 9px; font-size: 11.5px; }

/* ── 레이아웃 ──────────────────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: 372px minmax(0, 1fr);
  gap: 18px; padding: 18px; max-width: 1500px; margin: 0 auto;
  align-items: start;
}
/* grid item 의 기본 min-width:auto 때문에 좁은 화면에서 컬럼이 안 줄어든다 */
.layout > * { min-width: 0; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.inputs { position: sticky; top: 62px; max-height: calc(100vh - 78px); overflow-y: auto; padding-right: 4px; }
@media (max-width: 1000px) { .inputs { position: static; max-height: none; } }
.inputs::-webkit-scrollbar { width: 8px; }
.inputs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ── 입력 패널 ─────────────────────────────────────────────────────── */
.quickstat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 13px; margin-bottom: 10px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
}
.quickstat .qs { min-width: 0; overflow-wrap: anywhere; }
.quickstat .qs .k { font-size: 10.5px; color: var(--ink-3); }
.quickstat .qs .v { font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em; }
.quickstat .qs .v.small { font-size: 12px; font-weight: 550; }
.quickstat .warnline { grid-column: 1/-1; font-size: 11.5px; color: var(--warn); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 8px; overflow: hidden; box-shadow: var(--shadow);
}
.phead {
  width: 100%; display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; padding: 11px 13px; text-align: left;
}
.phead .pic { font-size: 14px; }
.phead .ptitle { flex: 1; font-size: 13px; font-weight: 620; }
.phead .chev { color: var(--ink-3); font-size: 11px; transition: transform var(--dur-micro) var(--ease-in-out); }
.phead[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.pbody { padding: 2px 13px 13px; border-top: 1px solid var(--line-2); }
.pbody .note { overflow-wrap: anywhere;
  margin: 10px 0; padding: 8px 10px; background: var(--accent-soft);
  border-radius: 7px; font-size: 11.5px; color: var(--ink-2); line-height: 1.5;
}

.field { margin: 11px 0; }
.field > label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.inwrap { display: flex; align-items: center; gap: 6px; }
.inwrap input, .field select {
  flex: 1; min-width: 0; width: 100%;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 7px;
  padding: 7px 9px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.inwrap input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.inwrap input[type=number] { -moz-appearance: textfield; }
.inwrap input::-webkit-outer-spin-button, .inwrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.unit { font-size: 11.5px; color: var(--ink-3); flex-shrink: 0; min-width: 20px; }
.hint { display: block; font-size: 10.8px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; overflow-wrap: anywhere; }
.conv { display: block; font-size: 10.8px; color: var(--accent); margin-top: 3px; min-height: 0; }

.field.bool { display: flex; flex-direction: column; }
/* `.field > label` 보다 특이도가 높아야 한다 (아니면 display:block 이 이겨서 토글이 찌그러진다) */
.field.bool > label.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  display: block; width: 34px; height: 19px; border-radius: 10px; background: var(--line);
  position: relative; flex: 0 0 34px; transition: background-color var(--dur-micro) var(--ease-in-out);
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--color-surface); transition: transform var(--dur-micro) var(--ease-in-out);
  box-shadow: var(--shadow-card);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .lbl { font-size: 12.5px; }

.oneoff { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.oneoff input { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 5px 7px; font-size: 12px; min-width: 0; }
.oneoff .oo-age { width: 52px; } .oneoff .oo-amt { width: 76px; } .oneoff .oo-label { flex: 1; }
.oneoff .oo-del { border: 0; background: transparent; color: var(--ink-3); padding: 2px 5px; }
.oneoff .oo-del:hover { color: var(--ink-3); }

.formactions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.privacy { font-size: 11px; color: var(--ink-3); line-height: 1.5; margin: 8px 0 20px; }

/* 간편/상세 모드 */
body.simple .adv { display: none !important; }
.hidden-cond { display: none !important; }

/* ── 결과 ──────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; box-shadow: var(--shadow);
}
.kpi .k { font-size: 11.5px; color: var(--ink-3); margin-bottom: 4px; }
.kpi .v { font-size: 25px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .v.sm { font-size: 19px; }
.kpi .s { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.kpi.ok .v { color: var(--ok); } .kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); }

.tabs { display: flex; gap: 3px; overflow-x: auto; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: transparent; padding: 8px 13px; font-size: 12.5px; color: var(--ink-3);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 620; }

.tabpane { display: none; }
.tabpane.on { display: block; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 17px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card h2 { font-size: 13.5px; margin-bottom: 3px; }
.cardsub { margin: 0 0 12px; font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.badge {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 6px;
  background: var(--accent-soft); color: var(--accent); border-radius: 5px;
  font-size: 10px; font-weight: 600; letter-spacing: 0;
}
.badge.approx { background: var(--color-warn-soft); color: var(--warn); }
.badge.low { background: var(--color-bad-soft); color: var(--bad); }
.badge.high { background: var(--color-ok-soft); color: var(--ok); }

.chart { width: 100%; overflow-x: auto; }
.chart svg { width: 100%; height: auto; display: block; }

/* 차트 요소 */
.ch-grid { stroke: var(--line-2); stroke-width: 1; }
.ch-zero { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-axis { stroke: var(--line); stroke-width: 1; }
.ch-ylab { fill: var(--ink-3); font-size: 10px; text-anchor: end; font-family: var(--font); }
.ch-xlab { fill: var(--ink-3); font-size: 10px; text-anchor: middle; font-family: var(--font); }
.ch-sub { fill: var(--ink-3); font-size: 9px; text-anchor: middle; font-family: var(--font); }
.ch-band-outer { fill: var(--band-outer); }
.ch-band-inner { fill: var(--band-inner); }
.ch-median { fill: none; stroke: var(--accent); stroke-width: 2; }
.ch-marker { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 4 3; opacity: .7; }
.ch-marker-t { fill: var(--ink-3); font-size: 9.5px; font-family: var(--font); }
.ch-bar { fill: var(--accent); }
.ch-bar.ok { fill: var(--ok); } .ch-bar.warn { fill: var(--warn); } .ch-bar.bad { fill: var(--bad); }
.ch-bar.hl { stroke: var(--ink); stroke-width: 1.5; }
.ch-barval { fill: var(--ink-2); font-size: 11px; font-weight: 620; text-anchor: middle; font-family: var(--font); }
.ch-target { stroke: var(--ink-3); stroke-dasharray: 4 3; stroke-width: 1; }
.ch-target-t { fill: var(--ink-3); font-size: 9.5px; text-anchor: end; font-family: var(--font); }
.ch-rowlab { fill: var(--ink-2); font-size: 11px; text-anchor: end; font-family: var(--font); }
.ch-tbar.pos { fill: var(--ok); } .ch-tbar.neg { fill: var(--bad); }
.ch-tval { font-size: 10.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.ch-tval.pos { fill: var(--ok); } .ch-tval.neg { fill: var(--bad); }
.ch-hit { cursor: crosshair; }
svg.stack { height: 26px; border-radius: 5px; overflow: hidden; }

.legend, .legendrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 9px; font-size: 11px; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg i, .lg .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.outer { background: var(--band-outer); } .sw.inner { background: var(--band-inner); }
.sw.med { background: var(--accent); height: 3px; border-radius: 1px; }

/* 결과 리스트 */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.rows { display: flex; flex-direction: column; gap: 7px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 7px; font-size: 12.5px;
}
.row .rl { color: var(--ink-2); min-width: 0; }
.row .rv { font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .rv.ok { color: var(--ok); } .row .rv.warn { color: var(--warn); } .row .rv.bad { color: var(--bad); }

.fireBox .big { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.fireBox .note2 { font-size: 12px; color: var(--ink-2); margin-top: 6px; line-height: 1.55; }

.tablewrap { overflow-x: auto; max-height: 460px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 11.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-2); }
th { position: sticky; top: 0; background: var(--panel); color: var(--ink-3); font-weight: 600; text-align: right; z-index: 1; }
th:first-child, td:first-child { text-align: left; }
tbody tr.retired { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

.disclaimer {
  font-size: 11px; color: var(--ink-3); line-height: 1.65;
  padding: 13px 15px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); margin: 4px 0 30px;
}

.progress {
  position: fixed; right: 20px; bottom: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-input);
  padding: 9px 15px; box-shadow: var(--shadow-float); font-size: 12.5px;
  display: flex; align-items: center; gap: 10px; z-index: 50;
}
.progress .bar {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin var(--dur-loader) linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .progress .bar { animation-duration: var(--dur-loader-reduced); } }

.empty { font-size: 12px; color: var(--ink-3); padding: 10px 0; }
.kpi .v.skel { color: var(--ink-3); font-weight: 500; }

/* ── 모바일 ────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 9px 12px; position: static; }
  .brand { flex: 1 1 100%; }
  .topbar h1 { font-size: 14px; }
  .sub { display: none; }
  .topactions { flex: 1 1 100%; justify-content: space-between; }
  button.primary { flex: 1; margin-left: 8px; }

  .layout { padding: 12px; gap: 12px; }
  .inputs { padding-right: 0; }
  .quickstat { padding: 10px; gap: 8px 10px; }

  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .v { font-size: 20px; }
  .kpi .v.sm { font-size: 16px; }
  .kpi .s { font-size: 10.5px; }

  .card { padding: 12px 13px; }
  .tabs { margin: 0 -12px 12px; padding: 0 12px; }

  /* 차트는 가로 스크롤 없이 축소되게 둔다 */
  .chart svg { min-width: 0; }
  .oneoff { flex-wrap: wrap; }
  .oneoff .oo-label { flex: 1 1 100%; }
  .progress { left: 12px; right: 12px; justify-content: center; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
  .quickstat { grid-template-columns: 1fr; }
}

/* ── Hallmark Cobalt workbench override ───────────────────────────── */
html,
body {
  overflow-x: clip;
}

html {
  background: var(--color-paper-2);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 20rem;
  background: var(--color-paper-2);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
}

::selection {
  background: var(--color-selection);
  color: var(--color-ink);
}

h1,
h2,
h3 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  letter-spacing: -0.025em;
}

button,
input,
select {
  font-family: var(--font-body);
}

button,
[role="tab"],
.switch {
  -webkit-tap-highlight-color: transparent;
}

button {
  min-height: 2.75rem;
  line-height: 1;
  white-space: nowrap;
  transition:
    background-color var(--dur-short) var(--ease-out),
    color var(--dur-short) var(--ease-out),
    border-color var(--dur-short) var(--ease-out),
    transform var(--dur-micro) var(--ease-out),
    opacity var(--dur-micro) var(--ease-out);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.switch input:focus-visible + .track {
  outline: var(--rule-fine) solid var(--color-focus);
  outline-offset: var(--space-3xs);
}

button:active:not(:disabled) {
  transform: translateY(var(--rule-hair));
}

button:disabled,
button[aria-disabled="true"],
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button[data-state="loading"] {
  cursor: progress;
  opacity: 0.72;
}

button[data-state="error"] {
  border-color: var(--color-bad);
  color: var(--color-bad);
}

button[data-state="success"] {
  border-color: var(--color-ok);
  color: var(--color-ok);
}

.topbar {
  position: static;
  z-index: var(--z-sticky-nav);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
  padding:
    var(--space-xs)
    max(var(--space-sm), env(safe-area-inset-right))
    var(--space-xs)
    max(var(--space-sm), env(safe-area-inset-left));
  background: var(--color-surface);
  color: var(--color-ink);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}

.brand {
  gap: var(--space-xs);
  align-items: center;
}

.logo {
  position: relative;
  display: block;
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  overflow: hidden;
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-input);
  color: transparent;
  font-size: 0;
}

.logo::before,
.logo::after {
  content: "";
  position: absolute;
  inset-inline-start: var(--space-2xs);
  inset-block-end: var(--space-2xs);
  width: var(--space-3xs);
  background: var(--color-accent);
  border-radius: var(--radius-small);
}

.logo::before {
  height: var(--space-xs);
}

.logo::after {
  inset-inline-start: var(--space-sm);
  height: var(--space-md);
}

.topbar h1 {
  font-size: clamp(var(--text-base), 3.8vw, var(--text-md));
  line-height: 1.2;
}

.sub {
  max-width: 65ch;
  margin-block-start: var(--space-3xs);
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.topactions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-2xs);
  width: 100%;
}

.modeswitch {
  display: grid;
  grid-template-columns: repeat(2, minmax(3.25rem, 1fr));
  padding: var(--space-3xs);
  background: var(--color-paper-2);
  color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-input);
}

.modeswitch button {
  min-height: 2.25rem;
  padding-inline: var(--space-xs);
  border-radius: var(--radius-small);
  color: var(--color-neutral);
  font-size: var(--text-sm);
}

.modeswitch button.on {
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: var(--shadow-card);
}

button.primary {
  margin: 0;
  min-height: 2.75rem;
  padding-inline: var(--space-sm);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border: var(--rule-hair) solid var(--color-accent);
  border-radius: var(--radius-input);
  font-size: var(--text-sm);
  font-weight: 700;
}

button.primary:focus-visible {
  outline-color: var(--color-focus-on-accent);
  outline-offset: var(--rule-hair);
  box-shadow: 0 0 0 var(--space-3xs) var(--color-focus);
}

button.ghost {
  min-height: 2.75rem;
  padding-inline: var(--space-xs);
  background: var(--color-paper);
  color: var(--color-ink-2);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-input);
  font-size: var(--text-sm);
}

button.ghost.sm {
  min-height: 2.75rem;
  padding-inline: var(--space-xs);
  font-size: var(--text-xs);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-md);
  align-items: start;
  width: 100%;
  max-width: 100rem;
  margin-inline: auto;
  padding:
    var(--space-sm)
    max(var(--space-sm), env(safe-area-inset-right))
    max(var(--space-lg), env(safe-area-inset-bottom))
    max(var(--space-sm), env(safe-area-inset-left));
}

.inputs {
  position: static;
  max-height: none;
  padding-inline-end: 0;
  scrollbar-color: var(--color-rule-2) transparent;
  scrollbar-width: thin;
}

.inputs::-webkit-scrollbar {
  width: var(--space-2xs);
}

.inputs::-webkit-scrollbar-thumb {
  background: var(--color-rule-2);
  border-radius: var(--radius-pill);
}

.quickstat {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs) var(--space-sm);
  margin-block-end: var(--space-xs);
  padding: var(--space-sm);
  background: var(--color-graphite);
  color: var(--color-on-graphite);
  border: var(--rule-hair) solid var(--color-graphite-2);
  border-radius: var(--radius-card);
  box-shadow: none;
}

.quickstat .qs .k {
  color: var(--color-on-graphite-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.quickstat .qs .v,
.quickstat .qs .v.small {
  margin-block-start: var(--space-3xs);
  color: var(--color-on-graphite);
  font-family: var(--font-outlier);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.quickstat .warnline {
  padding-block-start: var(--space-2xs);
  color: var(--color-warn);
  border-top: var(--rule-hair) solid var(--color-graphite-2);
  font-size: var(--text-xs);
}

.panel {
  margin-block-end: var(--space-2xs);
  overflow: clip;
  background: var(--color-surface);
  color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-input);
  box-shadow: none;
}

.phead {
  position: relative;
  gap: var(--space-xs);
  min-height: 3rem;
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-ink);
}

.phead::before {
  content: "";
  flex: 0 0 var(--space-3xs);
  width: var(--space-3xs);
  height: var(--space-3xs);
  background: var(--color-rule-2);
  border-radius: var(--radius-small);
}

.phead[aria-expanded="true"] {
  background: var(--color-paper);
  color: var(--color-ink);
}

.phead[aria-expanded="true"]::before {
  background: var(--color-accent);
}

.phead .pic {
  display: none;
}

.phead .ptitle {
  font-size: var(--text-sm);
  font-weight: 700;
}

.phead .chev {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.pbody {
  padding: var(--space-2xs) var(--space-sm) var(--space-sm);
  border-top: var(--rule-hair) solid var(--color-rule);
}

.pbody .note {
  margin-block: var(--space-xs);
  padding: var(--space-xs);
  background: var(--color-accent-soft);
  color: var(--color-ink-2);
  border-radius: var(--radius-input);
  font-size: var(--text-xs);
  line-height: 1.55;
}

.field {
  margin-block: var(--space-xs);
}

.field > label {
  margin-block-end: var(--space-3xs);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

.inwrap {
  gap: var(--space-2xs);
}

.inwrap input,
.field select,
.oneoff input {
  min-height: 2.75rem;
  padding: 0 var(--space-xs);
  background: var(--color-paper);
  color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-input);
  outline: var(--rule-fine) solid transparent;
  outline-offset: var(--rule-hair);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  transition:
    background-color var(--dur-short) var(--ease-out),
    border-color var(--dur-short) var(--ease-out),
    opacity var(--dur-micro) var(--ease-out);
}

.inwrap input:focus,
.field select:focus,
.oneoff input:focus,
.inwrap input:active,
.field select:active,
.oneoff input:active {
  background: var(--color-surface);
  border-color: var(--color-ink-2);
  outline: var(--rule-fine) solid var(--color-focus);
  outline-offset: var(--rule-hair);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--color-bad);
}

input[data-state="success"],
select[data-state="success"] {
  border-color: var(--color-ok);
}

.unit,
.hint,
.conv {
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.hint,
.conv {
  margin-block-start: var(--space-3xs);
  min-height: 1lh;
}

.conv {
  color: var(--color-accent);
}

.field.bool > label.switch {
  min-height: 2.75rem;
  gap: var(--space-xs);
  color: var(--color-ink-2);
}

.switch .track {
  flex-basis: 2.25rem;
  width: 2.25rem;
  height: 1.25rem;
  background: var(--color-rule-2);
  border-radius: var(--radius-pill);
}

.switch .track::after {
  inset-block-start: var(--rule-fine);
  inset-inline-start: var(--rule-fine);
  width: var(--space-sm);
  height: var(--space-sm);
  background: var(--color-surface);
  border-radius: var(--radius-pill);
}

.switch input:checked + .track {
  background: var(--color-accent);
}

.switch input:disabled + .track {
  cursor: not-allowed;
  opacity: 0.52;
}

.switch:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.72;
}

.switch input:checked + .track::after {
  transform: translateX(var(--space-sm));
}

.switch .lbl {
  font-size: var(--text-sm);
}

.oneoff {
  gap: var(--space-2xs);
  margin-block-end: var(--space-2xs);
}

.oneoff .oo-del {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  color: var(--color-muted);
  border: var(--rule-hair) solid transparent;
  border-radius: var(--radius-input);
}

.formactions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2xs);
  margin-block: var(--space-xs);
}

.privacy {
  margin: var(--space-xs) 0 var(--space-lg);
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.55;
}

.results {
  min-width: 0;
}

.kpis {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
  margin-block-end: var(--space-sm);
}

.kpi {
  min-width: 0;
  padding: var(--space-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-card);
  box-shadow: none;
}

.kpi:first-child {
  grid-column: 1 / -1;
  background: var(--color-graphite);
  color: var(--color-on-graphite);
  border-color: var(--color-graphite-2);
}

.kpi .k {
  margin-block-end: var(--space-2xs);
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.kpi:first-child .k,
.kpi:first-child .s {
  color: var(--color-on-graphite-muted);
}

.kpi .v,
.kpi .v.sm,
.fireBox .big {
  color: var(--color-ink);
  font-family: var(--font-outlier);
  font-size: clamp(var(--text-lg), 6vw, var(--text-xl));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.kpi:first-child .v {
  color: var(--color-on-graphite);
}

.kpi .s {
  margin-block-start: var(--space-2xs);
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.kpi.ok .v,
.row .rv.ok {
  color: var(--color-ok);
}

.kpi.warn .v,
.row .rv.warn {
  color: var(--color-warn);
}

.kpi.bad .v,
.row .rv.bad {
  color: var(--color-bad);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow: visible;
  margin: 0 0 var(--space-xs);
  padding: var(--space-3xs);
  background: var(--color-surface);
  color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-input);
}

.tabs button {
  min-width: 0;
  min-height: 2.75rem;
  padding-inline: var(--space-2xs);
  color: var(--color-muted);
  border: 0;
  border-radius: var(--radius-small);
  font-size: var(--text-xs);
}

.tabs button.on {
  background: var(--color-paper-3);
  color: var(--color-ink);
  border-bottom-color: transparent;
  font-weight: 700;
}

.tabpane.on {
  display: block;
  animation: tab-in var(--dur-short) var(--ease-out) both;
}

@keyframes tab-in {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.card {
  margin-block-end: var(--space-xs);
  padding: var(--space-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-card);
  box-shadow: none;
}

.card h2 {
  margin-block-end: var(--space-2xs);
  font-size: var(--text-md);
  line-height: 1.2;
}

.cardsub {
  max-width: 72ch;
  margin: 0 0 var(--space-sm);
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.badge {
  margin-inline-start: var(--space-2xs);
  padding: var(--space-3xs) var(--space-2xs);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-radius: var(--radius-small);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
}

.badge.approx {
  background: var(--color-warn-soft);
  color: var(--color-warn);
}

.badge.low {
  background: var(--color-bad-soft);
  color: var(--color-bad);
}

.badge.high {
  background: var(--color-ok-soft);
  color: var(--color-ok);
}

.chart {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--color-rule-2) transparent;
}

.chart svg {
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
}

.ch-ylab,
.ch-xlab,
.ch-sub,
.ch-marker-t,
.ch-barval,
.ch-target-t,
.ch-rowlab,
.ch-tval {
  font-family: var(--font-body);
}

.legend,
.legendrow {
  gap: var(--space-xs);
  margin-block-start: var(--space-xs);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
}

.lg {
  gap: var(--space-3xs);
}

.kv {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2xs) var(--space-sm);
  font-size: var(--text-sm);
}

.kv dt {
  color: var(--color-muted);
}

.rows {
  gap: 0;
  border-top: var(--rule-hair) solid var(--color-rule);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-sm);
  align-items: start;
  padding: var(--space-xs) 0;
  background: transparent;
  color: var(--color-ink);
  border: 0;
  border-bottom: var(--rule-hair) solid var(--color-rule);
  border-radius: 0;
  font-size: var(--text-sm);
}

.row .rl {
  color: var(--color-ink-2);
  line-height: 1.55;
}

.row .rv {
  max-width: 32ch;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-weight: 600;
  text-align: end;
  white-space: normal;
}

.fireBox .note2 {
  margin-block-start: var(--space-xs);
  color: var(--color-ink-2);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.tablewrap {
  max-height: min(60dvh, 32rem);
  overflow: auto;
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-input);
  scrollbar-color: var(--color-rule-2) transparent;
}

table {
  width: 100%;
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}

th {
  background: var(--color-paper-3);
  color: var(--color-ink-2);
  font-weight: 700;
}

tbody tr.retired {
  background: var(--color-accent-soft);
  color: var(--color-ink);
}

.disclaimer {
  max-width: 72ch;
  margin: var(--space-sm) 0 var(--space-xl);
  padding: var(--space-sm) 0 0;
  background: transparent;
  color: var(--color-muted);
  border: 0;
  border-top: var(--rule-hair) solid var(--color-rule-2);
  border-radius: 0;
  font-size: var(--text-xs);
  line-height: 1.7;
}

.progress {
  inset-inline: var(--space-sm);
  inset-block-end: max(var(--space-sm), env(safe-area-inset-bottom));
  justify-content: center;
  gap: var(--space-xs);
  min-height: 2.75rem;
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-graphite);
  color: var(--color-on-graphite);
  border: var(--rule-hair) solid var(--color-graphite-2);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-float);
  font-size: var(--text-sm);
  z-index: var(--z-toast);
}

[style*="margin-top"] {
  margin-block-start: var(--space-xs) !important;
}

.progress .bar {
  width: var(--space-sm);
  height: var(--space-sm);
  border: var(--rule-fine) solid var(--color-graphite-2);
  border-top-color: var(--color-accent);
}

.empty {
  padding-block: var(--space-xs);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (hover: hover) and (pointer: fine) {
  button.primary:hover {
    transform: translateY(calc(var(--rule-hair) * -1));
  }

  button.ghost:hover {
    border-color: var(--color-accent);
  }

  .phead:hover,
  .tabs button:hover {
    background: var(--color-paper-3);
  }

  .inwrap input:hover,
  .field select:hover,
  .oneoff input:hover {
    background: var(--color-paper-2);
  }

  .oneoff .oo-del:hover {
    color: var(--color-bad);
  }
}

@media (pointer: coarse) {
  button,
  input,
  select,
  .switch {
    min-height: 2.75rem;
  }
}

@media (min-width: 26rem) {
  .quickstat,
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 40rem) {
  .topbar {
    position: sticky;
    top: 0;
    display: flex;
    min-height: 4.5rem;
    padding-inline: max(var(--space-md), env(safe-area-inset-left));
  }

  .topactions {
    display: flex;
    width: auto;
  }

  .layout {
    gap: var(--space-lg);
    padding: var(--space-md);
  }

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

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

  .tabs button {
    font-size: var(--text-sm);
  }

  .card,
  .kpi {
    padding: var(--space-md);
  }

  .progress {
    inset-inline: auto var(--space-md);
    min-width: 12rem;
  }
}

@media (min-width: 62.5rem) {
  .layout {
    grid-template-columns: minmax(20rem, 23rem) minmax(0, 1fr);
    padding: var(--space-lg);
  }

  .inputs {
    position: sticky;
    top: calc(4.5rem + var(--space-sm));
    max-height: calc(100dvh - 5.5rem);
    overflow-y: auto;
    padding-inline-end: var(--space-2xs);
  }

  .tabs {
    position: sticky;
    top: 4.5rem;
    z-index: var(--z-raised);
  }
}

@media (min-width: 75rem) {
  .tabpane.on[data-pane="overview"] {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-xs);
  }

  .tabpane[data-pane="overview"] .card {
    margin-block-end: 0;
  }

  .tabpane[data-pane="overview"] .card:nth-child(1) {
    grid-column: span 8;
  }

  .tabpane[data-pane="overview"] .card:nth-child(2) {
    grid-column: span 4;
  }

  .tabpane[data-pane="overview"] .card:nth-child(3) {
    grid-column: span 5;
  }

  .tabpane[data-pane="overview"] .card:nth-child(4) {
    grid-column: span 7;
  }
}

@media (min-width: 90rem) {
  .layout {
    grid-template-columns: minmax(22rem, 25rem) minmax(0, 1fr);
    gap: var(--space-xl);
    padding-inline: var(--space-xl);
  }

  .kpis {
    grid-template-columns: 1.2fr 1fr 1fr;
  }

  .kpi:first-child {
    grid-column: span 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: var(--dur-micro) !important;
    animation-iteration-count: 1 !important;
    transition-duration: var(--dur-micro) !important;
  }

  button.primary:hover,
  button:active:not(:disabled) {
    transform: none;
  }
}

/* ── 처음 진입 화면 (welcome) ──────────────────────────────────────────
 * 처음 열었을 때 오른쪽 대시보드가 기본값으로 계산되어 있으면 당황스럽다.
 * 입력만 먼저 보여주고, "시뮬레이션 보기"를 눌러야 오른쪽 대시보드가 생성된다.
 */
body.welcome .layout { grid-template-columns: minmax(0, 1fr); max-width: 46rem; }
body.welcome .results { display: none; }
body.welcome .inputs { position: static; max-height: none; }
body.welcome .topactions #runBtn { display: none; }

.startCta { display: none; }
body.welcome .startCta {
  display: block;
  position: sticky; bottom: 0; z-index: 5;
  margin-top: 14px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--color-paper-2) 62%, transparent);
}
.startCta button.primary.lg {
  width: 100%; min-height: 3.25rem; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow-float);
}
.startCtaHint { margin: 8px 2px 0; font-size: 11.5px; color: var(--color-muted); text-align: center; line-height: 1.5; }

/* 입력 패널이 왼쪽 컬럼으로 이동하는 동안 JS 가 이 속성들을 인라인으로 채운다 */
.inputs.flip { will-change: transform, width; }

.results.enter { opacity: 0; transform: translateX(16px); }
.results.enter-active {
  opacity: 1; transform: translateX(0);
  transition: opacity var(--dur-long) var(--ease-out), transform var(--dur-long) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .results.enter, .results.enter-active { opacity: 1; transform: none; transition: none; }
}
