:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #f1f4ef;
  --ink: #17201b;
  --muted: #68736c;
  --line: #dce3dd;
  --line-strong: #c8d3ca;
  --green: #176b47;
  --green-dark: #0d4f35;
  --green-soft: #e5f2ea;
  --rust: #a24b35;
  --rust-soft: #faece7;
  --amber: #8a5c13;
  --amber-soft: #fff2d6;
  --shadow: 0 1px 2px rgba(24, 32, 27, .04), 0 10px 28px rgba(24, 32, 27, .035);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 107, 71, .28); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; left: 16px; top: -60px; padding: 10px 14px; color: #fff; background: var(--green-dark); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; background: #fcfdfb; border-right: 1px solid var(--line); }
.brand-block { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green-dark); color: #fff; font-weight: 800; }
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-size: 16px; letter-spacing: -.02em; }
.brand-block span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.app-nav { display: grid; gap: 5px; }
.app-nav button, .research-link { width: 100%; display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; font-weight: 650; text-decoration: none; }
.app-nav button span, .research-link span { width: 21px; color: var(--muted); text-align: center; font-size: 17px; }
.app-nav button:hover, .research-link:hover { background: var(--surface-soft); }
.app-nav button.active { background: var(--green-soft); color: var(--green-dark); }
.app-nav button.active span { color: var(--green); }
.sidebar-note { margin-top: auto; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.sidebar-note p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.workspace { min-width: 0; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px clamp(22px, 3.2vw, 50px); background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); }
.top-kicker { margin: 0 0 1px; color: var(--muted); font-size: 12px; font-weight: 700; }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.04em; }
.top-actions { display: flex; gap: 8px; }
.button { min-height: 39px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--line-strong); cursor: pointer; font-size: 13px; font-weight: 750; }
.button.secondary { background: #fff; }
.button.primary { color: #fff; background: var(--green-dark); border-color: var(--green-dark); }
.button:hover { transform: translateY(-1px); }

.filter-bar { display: flex; align-items: end; gap: 12px; padding: 15px clamp(22px, 3.2vw, 50px); background: var(--surface); border-bottom: 1px solid var(--line); }
.filter-bar label, .scenario-bar label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
select, input { min-height: 38px; padding: 0 36px 0 11px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 13px; font-weight: 650; }
.filter-context { min-width: 0; display: grid; gap: 1px; margin-left: 6px; padding-bottom: 1px; }
.filter-context strong { font-size: 12px; }
.filter-context span { color: var(--muted); font-size: 11px; }

main { max-width: 1640px; margin: 0 auto; padding: 24px clamp(22px, 3.2vw, 50px) 64px; }
.data-banner { display: flex; align-items: center; gap: 12px; padding: 10px 13px; margin-bottom: 25px; border: 1px solid #e7d7b5; border-radius: 10px; background: #fffbf1; }
.data-banner p { flex: 1; margin: 0; color: #665536; font-size: 12px; }
.text-button { padding: 2px 0; border: 0; background: transparent; color: var(--green-dark); cursor: pointer; font-size: 12px; font-weight: 800; }
.text-button:hover { text-decoration: underline; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.section-heading h2 { margin: 3px 0 0; font-size: clamp(24px, 2.3vw, 34px); line-height: 1.24; letter-spacing: -.045em; }
.section-heading > p { max-width: 420px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card.warning { border-top: 3px solid var(--amber); }
.metric-card.danger { border-top: 3px solid var(--rust); }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { margin: 7px 0 9px; font-size: clamp(23px, 2vw, 31px); font-weight: 780; letter-spacing: -.045em; white-space: nowrap; }
.metric-meta { display: flex; align-items: center; gap: 8px; min-height: 22px; color: var(--muted); font-size: 11px; }
.metric-delta { padding: 3px 6px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.metric-delta.positive { color: var(--green-dark); background: var(--green-soft); }
.metric-delta.negative { color: var(--rust); background: var(--rust-soft); }
.metric-delta.neutral { color: var(--muted); background: var(--surface-soft); }

.dashboard-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.dashboard-grid.two-one { grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.panel { min-width: 0; padding: 21px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 14px; }
.dashboard-grid .panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-head h3, .decision-card h3, .method-card h3 { margin: 3px 0 0; font-size: 17px; letter-spacing: -.025em; }
.formula, .legend { color: var(--muted); font-size: 11px; }
.flow-chart { display: grid; gap: 11px; }
.flow-row { display: grid; grid-template-columns: 88px minmax(80px, 1fr) 94px; align-items: center; gap: 12px; font-size: 12px; }
.flow-row strong { text-align: right; font-size: 13px; }
.bar-track { height: 11px; overflow: hidden; border-radius: 99px; background: #edf0ed; }
.bar-fill { display: block; height: 100%; border-radius: inherit; }
.bar-fill.green { background: var(--green); }
.bar-fill.rust { background: #c77b66; }
.panel-note { margin: 16px 0 0; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.status-chip { display: inline-flex; align-items: center; width: fit-content; padding: 3px 7px; border-radius: 6px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-chip.good { color: var(--green-dark); background: var(--green-soft); }
.status-chip.warning { color: var(--amber); background: var(--amber-soft); }
.status-chip.danger { color: var(--rust); background: var(--rust-soft); }
.status-chip.neutral { color: #526058; background: #edf1ee; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-dot.warning { background: #cc8c24; }

.decision-list { display: grid; gap: 8px; }
.decision-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.decision-card:first-child { padding-top: 0; border-top: 0; }
.decision-card h3 { font-size: 14px; }
.decision-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.decision-card .text-button { align-self: end; white-space: nowrap; }

.table-panel { padding-bottom: 16px; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
thead th { color: var(--muted); background: #f8faf8; font-size: 10px; font-weight: 800; letter-spacing: .02em; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
td small, th small { display: block; margin-top: 2px; color: var(--muted); font-weight: 500; }
.na { color: var(--muted); font-size: 11px; }
.amount-risk { color: var(--rust); background: #fff8f5; }

.summary-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-bottom: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.summary-strip div { display: grid; gap: 4px; padding: 17px 20px; background: var(--surface); }
.summary-strip span { color: var(--muted); font-size: 11px; }
.summary-strip strong { font-size: 19px; letter-spacing: -.03em; }

.scenario-bar { display: flex; align-items: end; gap: 14px; padding: 15px 17px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 13px; background: #f1f5f1; }
.scenario-bar label:nth-child(2) { position: relative; }
.scenario-bar input { width: 180px; padding-right: 33px; }
.scenario-bar label > span { position: absolute; right: 11px; bottom: 9px; color: var(--muted); font-size: 11px; }
.scenario-bar p { margin: 0 0 9px auto; color: var(--muted); font-size: 11px; }
.cash-chart { min-height: 210px; }
.cash-chart svg { display: block; width: 100%; height: auto; max-height: 250px; }
.zero-line { stroke: #c7d0c9; stroke-width: 1; stroke-dasharray: 5 5; }
.cash-line { stroke: var(--green); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.cash-point { fill: #fff; stroke: var(--green-dark); stroke-width: 3; }

.assumptions ul { margin: 0; padding-left: 20px; color: #455048; }
.assumptions li + li { margin-top: 7px; }
.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.method-card { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(0, 1.3fr); gap: 22px; padding: 19px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.method-card p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.method-card dl { margin: 0; }
.method-card dl div { padding: 7px 0; border-bottom: 1px solid var(--line); }
.method-card dl div:last-child { border-bottom: 0; }
.method-card dt { color: var(--muted); font-size: 10px; font-weight: 800; }
.method-card dd { margin: 2px 0 0; font-size: 12px; }
.formula-list { margin-top: 14px; }
.formula-list h3 { margin: 0 0 14px; }
.formula-list dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.formula-list dl div { padding: 13px; background: var(--surface); }
.formula-list dt { font-size: 11px; font-weight: 800; }
.formula-list dd { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding: 22px 12px; }
  .brand-block { justify-content: center; padding: 0 0 24px; }
  .brand-block > div:last-child { display: none; }
  .brand-block > div:last-child, .app-nav button:not(.active)::after, .app-nav button, .research-link { font-size: 0; }
  .app-nav button, .research-link { justify-content: center; padding: 12px; }
  .app-nav button span, .research-link span { width: auto; font-size: 18px; }
  .sidebar-note { padding: 10px; text-align: center; }
  .sidebar-note p { display: none; }
  .dashboard-grid.two-one { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .method-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 10; top: 0; width: 100%; height: auto; display: block; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-block, .sidebar-note { display: none; }
  .app-nav { display: flex; gap: 4px; overflow-x: auto; }
  .app-nav button, .research-link { flex: 0 0 auto; width: auto; display: grid; gap: 2px; justify-items: center; padding: 7px 10px; font-size: 10px; }
  .app-nav button span, .research-link span { font-size: 15px; }
  .topbar { min-height: 70px; padding: 13px 16px; }
  .topbar h1 { font-size: 20px; }
  .top-kicker { display: none; }
  .button { min-height: 36px; padding: 0 10px; font-size: 11px; }
  .filter-bar { align-items: stretch; flex-wrap: wrap; padding: 12px 16px; }
  .filter-bar label { flex: 1; }
  .filter-bar select { width: 100%; }
  .filter-context { flex-basis: 100%; margin-left: 0; }
  main { padding: 16px 14px 48px; }
  .data-banner { align-items: start; flex-wrap: wrap; }
  .data-banner p { flex: 1 1 210px; }
  .section-heading { display: block; }
  .section-heading h2 { font-size: 25px; }
  .section-heading > p { margin-top: 7px; text-align: left; }
  .metric-grid, .metric-grid.three { grid-template-columns: 1fr 1fr; }
  .metric-card { padding: 15px; }
  .metric-value { font-size: 22px; white-space: normal; }
  .panel { padding: 16px; border-radius: 14px; }
  .panel-head { display: block; }
  .formula, .legend, .panel-head > .status-chip { display: inline-flex; margin-top: 7px; }
  .flow-row { grid-template-columns: 65px minmax(70px, 1fr) 76px; gap: 7px; }
  .decision-card { grid-template-columns: 1fr; }
  .decision-card .text-button { justify-self: start; }
  .summary-strip { grid-template-columns: 1fr; }
  .scenario-bar { align-items: stretch; flex-wrap: wrap; }
  .scenario-bar label { flex: 1 1 150px; }
  .scenario-bar input, .scenario-bar select { width: 100%; }
  .scenario-bar p { flex-basis: 100%; margin: 0; }
  .method-card { grid-template-columns: 1fr; gap: 10px; }
  .formula-list dl { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .top-actions { gap: 5px; }
  .button { padding: 0 8px; }
  .metric-grid, .metric-grid.three { grid-template-columns: 1fr; }
  .filter-bar { gap: 8px; }
  .filter-bar label { min-width: 130px; }
  .formula-list dl { grid-template-columns: 1fr; }
  .flow-row { grid-template-columns: 58px minmax(40px, 1fr) 72px; font-size: 11px; }
}
