:root {
  --ink: #171a19;
  --muted: #686d69;
  --paper: #f2efe7;
  --card: #fbfaf6;
  --line: #d8d4ca;
  --line-dark: #b6b1a6;
  --accent: #ef5b2a;
  --accent-soft: #ffe2d5;
  --teal: #1b8c86;
  --teal-soft: #dcefed;
  --gold: #c68c2c;
  --danger: #a83e35;
  --shadow: 0 14px 40px rgba(29, 31, 29, 0.08);
  --sidebar: 248px;
  --font-sk: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-numeric: Roboto, "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 8%, rgba(239, 91, 42, 0.08), transparent 25rem),
    var(--paper);
  font-family: var(--font-sk);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: 74px 1fr;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 26px;
  background: rgba(21, 24, 23, 0.96);
  color: #f7f4ec;
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid #f5f2e9;
  font: 800 13px/1 var(--font-numeric); letter-spacing: -1px; position: relative;
}
.brand-mark::after { content: ""; position: absolute; right: -4px; bottom: -4px; width: 9px; height: 9px; background: var(--accent); }
.brand strong { display: block; letter-spacing: .08em; font-size: 13px; }
.brand small { display: block; margin-top: 3px; color: #aaa9a4; font-size: 10px; letter-spacing: .03em; }
.topbar-meta { display: flex; align-items: center; gap: 14px; margin-right: auto; }
.status-dot, .date-chip { font-size: 10px; letter-spacing: .09em; color: #c5c3bd; white-space: nowrap; }
.status-dot i { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: #6ec69c; box-shadow: 0 0 0 4px rgba(110,198,156,.12); }
.date-chip { padding-left: 14px; border-left: 1px solid #444744; }
.scenario-switch { display: flex; padding: 3px; border: 1px solid #414441; border-radius: 7px; }
.scenario-switch button { border: 0; background: transparent; color: #aaa9a4; padding: 7px 12px; font-size: 11px; border-radius: 4px; cursor: pointer; }
.scenario-switch button.active { color: white; background: #3a3d3a; box-shadow: inset 0 0 0 1px #535652; }
.export-button { border: 1px solid #595c58; background: transparent; color: white; border-radius: 6px; padding: 8px 12px; font-size: 11px; letter-spacing: .08em; cursor: pointer; }
.export-button:hover { background: white; color: var(--ink); }
.mobile-menu { display: none; border: 0; background: none; color: white; font-size: 20px; }

.sidebar {
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  padding: 28px 16px 20px;
  background: #e9e6de;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar-label { margin: 0 10px 13px; color: #8a8c88; font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.nav-group { margin-bottom: 17px; }
.nav-group-title { margin: 0 10px 5px; color: #a09d95; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.nav-button {
  width: 100%; display: grid; grid-template-columns: 25px 1fr; align-items: center; border: 0;
  padding: 8px 10px; background: transparent; border-radius: 6px; color: #60635f;
  text-align: left; font-size: 11px; cursor: pointer; transition: .15s ease;
}
.nav-button span:first-child { font-variant-numeric: tabular-nums; color: #aaa69d; font-size: 9px; }
.nav-button:hover { background: rgba(255,255,255,.55); color: var(--ink); }
.nav-button.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.05); font-weight: 700; }
.nav-button.active span:first-child { color: var(--accent); }
.sidebar-note { margin: 24px 7px 0; padding: 15px; border: 1px solid #d2cec5; background: rgba(255,255,255,.28); }
.sidebar-note span { color: #929089; font-size: 8px; letter-spacing: .13em; }
.sidebar-note strong { display: block; margin-top: 8px; font: 700 17px/1.2 var(--font-numeric); }
.sidebar-note p { color: var(--muted); font-size: 10px; line-height: 1.55; margin-bottom: 0; }

main { min-width: 0; padding: 42px clamp(24px, 4vw, 68px) 80px; }
.loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); font-size: 12px; }
.loading span { width: 26px; height: 26px; margin-bottom: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: end; margin-bottom: 30px; }
.page-kicker { margin-bottom: 11px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.page-head h1 { max-width: 820px; margin: 0; font: 500 clamp(31px, 4vw, 52px)/1.12 var(--font-sk); letter-spacing: -.04em; }
.page-head p { max-width: 740px; margin: 15px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.page-index { color: #d6d1c8; font: 500 clamp(60px, 8vw, 108px)/.8 var(--font-numeric); }

.signal-bar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 22px; color: var(--muted); font-size: 10px; }
.signal-bar::before { content: ""; width: 32px; height: 2px; background: var(--accent); }
.scenario-name { color: var(--ink); font-weight: 800; text-transform: uppercase; }
.model-label { padding: 4px 7px; background: #e6e2d8; border-radius: 3px; letter-spacing: .06em; }
.scenario-guide-button { margin-left: 2px; border: 0; border-bottom: 1px solid var(--line-dark); padding: 3px 1px; background: transparent; color: var(--ink); font-size: 9px; font-weight: 700; cursor: pointer; }
.scenario-guide-button:hover { color: var(--accent); border-color: var(--accent); }

.insight-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 24px; border: 1px solid var(--line); background: #eae7df; }
.insight-item { position: relative; min-height: 108px; padding: 20px 22px 18px 50px; border-right: 1px solid var(--line); font: 500 13px/1.6 var(--font-sk); }
.insight-item:last-child { border-right: 0; }
.insight-item b { position: absolute; top: 20px; left: 19px; color: var(--accent); font: 800 10px/1 var(--font-numeric); }

.page-year-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: -2px 0 22px; padding: 15px 17px; border: 1px solid var(--line); background: var(--card); }
.page-year-bar > div:first-child { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.page-year-bar span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.page-year-bar strong { color: var(--accent); font: 700 18px/1 var(--font-numeric); }
.page-year-bar small { color: var(--muted); font-size: 10px; }
.year-switch { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #ece9e1; }
.year-switch button { min-width: 58px; border: 0; border-radius: 4px; padding: 8px 10px; background: transparent; color: var(--muted); font: 700 10px/1 var(--font-numeric); cursor: pointer; transition: .15s ease; }
.year-switch button:hover { color: var(--ink); background: rgba(255,255,255,.55); }
.year-switch button.active { color: white; background: var(--ink); box-shadow: 0 2px 8px rgba(23,26,25,.18); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.kpi-card, .chart-card, .panel, .risk-card, .flow-card {
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 1px 0 rgba(255,255,255,.8);
}
.kpi-card { min-height: 184px; padding: 19px 20px; display: flex; flex-direction: column; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.kpi-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.confidence { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
.confidence::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.confidence.high::before { background: var(--teal); }
.confidence.low::before { background: var(--danger); }
.kpi-value { margin: 20px 0 7px; font: 500 clamp(29px, 3.2vw, 43px)/1 var(--font-numeric); letter-spacing: -.04em; }
.kpi-change { color: var(--teal); font-size: 11px; font-weight: 700; }
.kpi-change.negative { color: var(--danger); }
.kpi-driver { margin-top: auto; padding-top: 15px; color: var(--muted); font-size: 10px; line-height: 1.45; border-top: 1px solid #e6e2d8; }
.kpi-driver strong { color: var(--ink); }

.chart-card { min-width: 0; padding: 23px 24px 18px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 16px; }
.chart-eyebrow { margin-bottom: 7px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.chart-head h2 { margin: 0; font: 500 20px/1.3 var(--font-sk); letter-spacing: -.025em; }
.chart-description { max-width: 650px; min-height: 34px; margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.why-button, .source-link { border: 1px solid var(--line); background: transparent; border-radius: 5px; padding: 6px 9px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .05em; cursor: pointer; white-space: nowrap; }
.why-button:hover, .source-link:hover { border-color: var(--ink); color: var(--ink); }
.chart-wrap { position: relative; min-height: 220px; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-footer { display: flex; justify-content: space-between; gap: 16px; align-items: center; min-height: 30px; margin-top: 13px; padding-top: 12px; border-top: 1px solid #e7e3da; color: #8b8c87; font-size: 9px; }
.chart-footer > span:first-child { line-height: 1.45; }
.chart-legend { display: flex; gap: 13px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-item i { width: 7px; height: 7px; border-radius: 2px; }

.axis-line { stroke: #d8d4ca; stroke-width: 1; }
.axis-label { fill: #8b8c87; font-size: 10px; font-family: var(--font-numeric); }
.grid-line { stroke: #e8e4db; stroke-width: 1; stroke-dasharray: 3 5; }
.chart-path { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { stroke: var(--card); stroke-width: 3; cursor: crosshair; }
.forecast-zone { fill: #efebe2; }

.contribution-list { display: grid; gap: 13px; padding: 4px 0; }
.contribution-row { display: grid; grid-template-columns: minmax(130px, 1fr) 4fr auto; align-items: center; gap: 12px; font-size: 10px; }
.bar-track { height: 8px; background: #e9e6dd; overflow: hidden; border-radius: 1px; }
.bar-fill { height: 100%; min-width: 2px; }
.contribution-value { min-width: 68px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.risk-card { min-height: 148px; padding: 20px; }
.risk-card .risk-num { color: var(--accent); font: 500 26px/1 var(--font-numeric); }
.risk-card h3 { margin: 24px 0 7px; font-size: 12px; }
.risk-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.data-table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--card); }
.data-table { width: 100%; border-collapse: collapse; font-size: 10px; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 11px 12px; background: #eae7df; color: #747771; text-align: right; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table td { padding: 12px; text-align: right; border-bottom: 1px solid #ebe7de; font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f6f3ec; }
.product-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.product-name i { width: 7px; height: 20px; }
.type-pill { display: inline-block; padding: 4px 6px; background: #e8e5dd; border-radius: 3px; color: var(--muted); font-size: 8px; letter-spacing: .04em; }

.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 21px; align-items: stretch; margin: 15px 0; }
.flow-card { position: relative; min-height: 170px; padding: 19px; }
.flow-card:not(:last-child)::after { content: "→"; position: absolute; right: -18px; top: 50%; color: var(--accent); font-size: 18px; }
.flow-card small { color: var(--muted); font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.flow-card strong { display: block; margin: 22px 0 8px; font: 500 26px/1 var(--font-numeric); }
.flow-card p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.flow-card .flow-end { color: var(--teal); font-size: 11px; font-weight: 700; }

.panel { padding: 22px; }
.panel h3 { margin: 0 0 7px; font: 500 17px/1.35 var(--font-sk); }
.panel > p { margin: 0 0 18px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.metric-list { display: grid; gap: 10px; }
.metric-row { display: grid; grid-template-columns: minmax(110px, 1fr) 3fr 48px; align-items: center; gap: 10px; font-size: 10px; }

.timeline { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--card); }
.timeline-step { min-height: 190px; padding: 22px; border-right: 1px solid var(--line); }
.timeline-step:last-child { border-right: 0; }
.timeline-year { color: var(--accent); font: 500 31px/1 var(--font-numeric); }
.timeline-step h3 { margin: 28px 0 8px; font-size: 12px; }
.timeline-step p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.stage-pill { display: inline-block; margin-top: 14px; padding: 5px 7px; background: var(--teal-soft); color: var(--teal); font-size: 8px; font-weight: 800; letter-spacing: .06em; }

.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 28px; }
.control { padding: 14px 0; border-bottom: 1px solid #e7e3da; }
.control-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 10px; }
.control-label strong { font-variant-numeric: tabular-nums; color: var(--accent); }
input[type="range"] { width: 100%; height: 3px; appearance: none; background: #d8d4ca; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--ink); cursor: grab; }
.reset-button { margin-top: 18px; padding: 9px 12px; border: 1px solid var(--line-dark); background: transparent; border-radius: 4px; font-size: 10px; cursor: pointer; }

.tornado { display: grid; gap: 11px; padding: 12px 0; }
.tornado-row { display: grid; grid-template-columns: 92px 1fr 48px; gap: 10px; align-items: center; font-size: 9px; }
.tornado-track { position: relative; height: 15px; background: linear-gradient(to right, transparent 49.8%, #ada9a0 50%, transparent 50.2%); }
.tornado-neg, .tornado-pos { position: absolute; top: 2px; height: 11px; }
.tornado-neg { right: 50%; background: #929792; }
.tornado-pos { left: 50%; background: var(--accent); }
.tornado-value { text-align: right; font-weight: 700; }
.heatmap { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: 9px; }
.heatmap th { color: var(--muted); font-weight: 600; padding: 7px; }
.heatmap td { text-align: center; padding: 14px 5px; font-weight: 700; border-radius: 2px; }

.filter-bar { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 4px; padding: 10px 11px; font-size: 10px; color: var(--ink); }
.source-title { max-width: 270px; white-space: normal; line-height: 1.4; }
.source-title a { text-decoration-color: #aaa; text-underline-offset: 2px; }
.source-count { margin: 9px 0 0; color: var(--muted); font-size: 9px; }

.callout { display: flex; gap: 14px; align-items: flex-start; margin: 18px 0; padding: 15px 17px; background: var(--accent-soft); border-left: 3px solid var(--accent); color: #6a3a29; font-size: 10px; line-height: 1.55; }
.callout strong { color: #442619; }
.callout.teal { background: var(--teal-soft); border-color: var(--teal); color: #285b57; }

.section-space { margin-top: 18px; }
.section-title { margin: 35px 0 14px; font: 500 22px/1.3 var(--font-sk); }
.mini-note { color: var(--muted); font-size: 9px; line-height: 1.45; }
.positive { color: var(--teal); }
.negative { color: var(--danger); }

.tooltip { position: fixed; z-index: 100; display: none; pointer-events: none; max-width: 260px; padding: 10px 12px; background: #171a19; color: white; border-radius: 5px; box-shadow: var(--shadow); font-size: 10px; line-height: 1.5; }
.tooltip.visible { display: block; }

dialog { position: fixed; width: min(760px, calc(100vw - 30px)); max-height: 80vh; overflow: auto; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 31px; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(18,20,19,.62); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 13px; right: 15px; border: 0; background: transparent; font-size: 24px; cursor: pointer; }
#dialog-content h2 { margin: 0 0 15px; font: 500 27px/1.25 var(--font-sk); }
#dialog-content h3 { margin: 22px 0 8px; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; }
#dialog-content p, #dialog-content li { color: var(--muted); font-size: 11px; line-height: 1.65; }
#dialog-content a { color: var(--accent); }
.scenario-guide-intro { margin: 0 0 18px; }
.scenario-definition-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.scenario-definition { padding: 16px; border: 1px solid var(--line); background: #f2efe7; }
.scenario-definition.active { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.scenario-definition > span { color: var(--accent); font: 700 9px/1 var(--font-numeric); letter-spacing: .1em; }
#dialog-content .scenario-definition h3 { margin: 11px 0 8px; text-transform: none; letter-spacing: 0; font-size: 13px; }
#dialog-content .scenario-definition p { margin: 0; font-size: 10px; }
.scenario-assumption-table { max-height: 340px; }
.scenario-assumption-table .data-table th:first-child { min-width: 170px; }
.mobile-backdrop { display: none; }

@media (max-width: 1120px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: 1fr; }
  .flow-card { min-height: 120px; }
  .flow-card:not(:last-child)::after { content: "↓"; right: 50%; top: auto; bottom: -20px; }
  .topbar-meta { display: none; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .topbar { height: 64px; padding: 0 15px; gap: 11px; }
  .mobile-menu { display: block; }
  .brand { min-width: 0; margin-right: auto; }
  .brand small { display: none; }
  .scenario-switch button { padding: 6px 8px; }
  .export-button { display: none; }
  .sidebar { position: fixed; z-index: 60; top: 0; left: 0; width: 260px; height: 100vh; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .mobile-backdrop.open { display: block; position: fixed; z-index: 50; inset: 0; background: rgba(0,0,0,.42); }
  main { padding: 30px 17px 60px; }
  .page-head { grid-template-columns: 1fr; }
  .page-index { display: none; }
  .insight-strip, .grid-2, .grid-3, .grid-4, .control-grid, .timeline { grid-template-columns: 1fr; }
  .insight-item, .timeline-step { border-right: 0; border-bottom: 1px solid var(--line); }
  .insight-item:last-child, .timeline-step:last-child { border-bottom: 0; }
  .span-2 { grid-column: auto; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .chart-card { padding: 19px 15px 14px; }
  .chart-head { flex-direction: column; }
  .page-year-bar { align-items: stretch; flex-direction: column; gap: 12px; }
  .page-year-bar > div:first-child { flex-wrap: wrap; }
  .page-year-bar small { flex-basis: 100%; }
  .year-switch { width: 100%; overflow-x: auto; }
  .year-switch button { flex: 1 0 54px; }
  .scenario-definition-grid { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .sidebar { display: none; }
  .app-shell { display: block; }
  main { padding: 0; }
  .chart-card, .kpi-card, .panel { break-inside: avoid; box-shadow: none; }
}
