:root {
  --bg: #f4f6f5; --card: #fff; --ink: #1f2430; --ink-strong: #152b3c; --muted: #6b7280;
  --line: #e3e6ec;
  --accent: #2fa968; --accent-dark: #248a53; --accent-soft: #e8f5ee; --accent-line: #bfe6cf;
  --accent-ink: #fff; --slate: #152b3c; --slate-2: #22384a; --slate-soft: #eef2f5; --warn: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}
.container { max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; }

/* 브로셔형 헤더 */
.app-header {
  display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px;
  padding-bottom: 16px; margin-bottom: 4px; border-bottom: 2px solid var(--slate);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  flex: none; width: 46px; height: 46px; border-radius: 11px;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 800;
  font-style: italic; box-shadow: 0 4px 14px rgba(47,169,104,.32); letter-spacing: -.5px;
}
.brand-mark sub { font-size: .58em; font-style: normal; }
.eyebrow {
  margin: 0 0 2px; font-size: 11px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent-dark);
}
h1 { font-size: 24px; margin: 0; color: var(--ink-strong); letter-spacing: -.4px; }
.subtitle { font-size: 13px; color: var(--muted); font-weight: 400; }

/* 카드 섹션 제목: 슬레이트 볼드 + 그린 밑줄 */
h2 {
  font-size: 16px; margin: 0 0 14px; color: var(--ink-strong); font-weight: 800;
  letter-spacing: -.2px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  position: relative;
}
h2::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 42px; height: 3px;
  background: var(--accent); border-radius: 2px;
}
.card-head h2 { border: none; padding-bottom: 0; margin-bottom: 0; }
.card-head h2::after { display: none; }
.card-head { padding-bottom: 8px; border-bottom: 1px solid var(--line); position: relative; }
.card-head::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 42px; height: 3px;
  background: var(--accent); border-radius: 2px;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
label { display: inline-flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
input[type="number"] { width: 110px; }
textarea { resize: vertical; min-width: 240px; }
.model-field { display: block; margin-top: 12px; }
.model-field input { width: 100%; max-width: 420px; }
.hint { color: var(--muted); font-weight: 400; }
button {
  font: inherit; cursor: pointer; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
button:hover { background: #f0f2f6; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); margin-top: 14px; font-weight: 600; box-shadow: 0 2px 8px rgba(47,169,104,.24); }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); filter: none; }

.head-actions { display: flex; gap: 8px; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
button.primary-soft { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-line); font-weight: 600; }
button.primary-soft:hover { background: #d7efe0; }
button:disabled { opacity: .7; cursor: default; }

/* 분류 트리 — 폴더 = 카드, 잎(요소) = 정렬된 표 행 */
#tree {
  /* 잎 행과 머리글이 공유하는 열 정의(단일 진실원) → 모든 요소가 칼같이 정렬.
     번호 열은 px 고정(머리글 10.5px·행 15px에서 em이 달라지는 것 방지),
     마지막 열도 px 고정(버튼 있는 행 vs 빈 머리글 폭 불일치 방지) */
  --leaf-cols: 30px 14px 96px minmax(80px, 1fr) 80px 58px 84px 52px 124px;
  overflow-x: auto; /* 깊은 중첩으로 표가 길어지면 카드 안에서 가로 스크롤 */
}
.tree-group { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fafbfd; }
.tree-group .tree-group { margin-bottom: 6px; }
.group-head {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: #eef2f9; border-bottom: 1px solid var(--line); border-radius: 7px 7px 0 0; cursor: default;
}
.group-head .g-collapse { border: none; background: none; padding: 0 2px; font-size: 13px; color: var(--muted); }
.group-head .g-icon { color: var(--accent); flex: none; display: block; }
.group-head .g-tag {
  flex: none; font-size: 10.5px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 5px; padding: 1px 6px;
}
.group-head .g-name { font-weight: 700; width: 140px; background: transparent; border-color: transparent; padding: 4px 6px; }
.group-head .g-name:hover, .group-head .g-name:focus { background: #fff; border-color: var(--line); }
.group-head .g-value { width: 78px; padding: 4px 6px; }
.group-head .g-unit { width: 60px; padding: 4px 6px; }
.group-head .g-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.group-head .g-actions { margin-left: auto; display: flex; gap: 6px; }
.group-head .g-actions button { padding: 4px 9px; font-size: 12.5px; white-space: nowrap; }
.group-head .g-calc { font-style: italic; color: var(--accent); border-color: var(--accent-line); }
.group-head .g-calc:hover { background: var(--accent-soft); }
.group-head .g-calc.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.group-head .g-remove { color: var(--warn); border-color: #f1d4d4; }
.g-grip { cursor: grab; color: #b6bdca; user-select: none; font-size: 13px; letter-spacing: -2px; flex: none; }

.node-num {
  font: 600 12px ui-monospace, "Consolas", monospace; color: var(--accent);
  min-width: 2.1em; text-align: right; user-select: none; flex: none;
}
.group-head .node-num { font-size: 13px; }
.leaf-row .node-num { color: var(--muted); }

/* 분류 설정(⚙) — 기본 숨김, 보통 건드릴 필요 없음 */
.group-head .g-config { color: var(--muted); }
.group-head .g-config.active { background: var(--accent); color: #fff; border-color: var(--accent); }
/* 분류 계산식 행(상시 노출) — 모델식이 합성방식을 결정 */
.group-model {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px 10px;
  padding: 8px 12px; background: #f7f9fc; border-bottom: 1px solid var(--line);
}
.group-model label { flex-direction: row; align-items: center; gap: 6px; font-size: 11.5px; margin: 0; }
.group-model input { padding: 5px 7px; }
.group-model .gm-sym input { width: 82px; }
.group-model .gm-model { flex: 1 1 320px; }
.group-model .gm-model input { width: 100%; font-family: ui-monospace, "Consolas", monospace; font-size: 12.5px; }
.gm-badge { flex: none; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 3px 9px; white-space: nowrap; cursor: help; }
.gm-badge.gm-sens { color: #fff; background: var(--accent); }
.gm-badge.gm-direct { color: #fff; background: var(--slate); }
.gm-badge.gm-rel { color: #8a5a00; background: #fdf0d5; border: 1px solid #f3d9a6; }
.gm-hint { flex-basis: 100%; font-size: 11.5px; color: #9a6a2f; font-weight: 600; }
.gm-hint:empty { display: none; }

/* 수학적 모델링 (MathLive 수식편집기) */
#equations { display: flex; flex-direction: column; gap: 10px; }
.eq-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
math-field.eq-field {
  flex: 1 1 340px; font-size: 21px; min-height: 46px; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  --caret-color: var(--accent); --selection-background-color: var(--accent-soft);
}
math-field.eq-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.eq-vars { flex: 1 1 220px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.eq-vars .eq-ok { color: var(--accent-dark); font-weight: 700; }
.eq-vars .eq-new { color: #8a5a00; font-weight: 700; }
.eq-vars .eq-warn { color: var(--warn); }
.eq-remove { color: var(--warn); border-color: #f1d4d4; padding: 7px 11px; flex: none; }
.eq-remove:hover { background: #fdecec; }
.tree-children { padding: 4px 10px 8px 22px; }
.tree-children:empty::before { content: "비어 있음 — 여기로 끌어다 놓거나 ＋요소"; color: var(--muted); font-size: 12px; display: block; padding: 6px 2px; }

/* 잎 열 머리글 — 폴더 안 '표'의 헤더 (기호 / 설명 / 추정값 …) */
.leaf-head {
  display: grid; grid-template-columns: var(--leaf-cols); gap: 6px 8px;
  align-items: end; padding: 2px 0 5px; margin-bottom: 3px; border-bottom: 1px solid var(--line);
  font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: .02em;
}
.leaf-head span { padding-left: 2px; }

/* 잎 = 표 행: 개별 테두리 없이 구분선으로 정렬감 강조 */
.component-row.leaf-row { border: none; border-radius: 6px; background: transparent; padding: 6px 0; margin: 0; }
.leaf-row + .leaf-row { border-top: 1px solid var(--line); }
.leaf-row:hover { background: #f3f6fc; }
.row-main { display: grid; grid-template-columns: var(--leaf-cols); gap: 6px 8px; align-items: center; }
.row-main input, .row-main select { width: 100%; min-width: 0; padding: 6px 7px; }
.row-main .g-grip { justify-self: center; }
.l-actions { display: flex; gap: 6px; justify-content: flex-end; }
.l-actions button { padding: 5px 8px; font-size: 12px; }
.leaf-row .l-subdiv { padding: 5px 8px; font-size: 12px; color: var(--accent); border-color: var(--accent-line); white-space: nowrap; }
.leaf-row .l-subdiv:hover { background: var(--accent-soft); }
.leaf-row .l-calc { padding: 5px 7px; font-size: 12px; font-style: italic; color: var(--accent); border-color: var(--accent-line); white-space: nowrap; }
.leaf-row .l-calc:hover { background: var(--accent-soft); }
.leaf-row .l-calc.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 좁은 화면: 8열 표가 안 들어가므로 줄바꿈 레이아웃으로 폴백(가로 스크롤 방지) */
@media (max-width: 640px) {
  .leaf-head { display: none; }
  .row-main { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .row-main input, .row-main select { width: auto; }
  .row-main .c-symbol { flex: 1 1 88px; }
  .row-main .c-desc { flex: 2 1 140px; }
  .row-main .c-estimate, .row-main .c-type, .row-main .c-ci, .row-main .c-unit { flex: 1 1 72px; }
  .l-actions { margin-left: auto; }
  .row-detail { margin-left: 0; }
  .row-detail textarea { min-width: 0; width: 100%; }
  /* 분류 헤더도 줄바꿈 + 메타 숨김으로 폭 절약 */
  .group-head { flex-wrap: wrap; }
  .group-head .g-name { width: auto; flex: 1 1 110px; }
  .group-head .g-meta { display: none; }
  .group-head .g-actions { margin-left: 0; }
}

/* 드래그앤드롭 표시 */
.leaf-row[draggable="true"], .group-head[draggable="true"] { }
.dragging { opacity: 0.45; }
.drop-into { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.drop-after { box-shadow: 0 3px 0 0 var(--accent); }

/* 이름 입력 팝업 */
.name-dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; min-width: 300px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.name-dialog::backdrop { background: rgba(20,25,35,.35); }
.name-dialog h3 { margin: 0 0 12px; font-size: 16px; }
.name-dialog input { width: 100%; }
.name-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.name-dialog .dialog-actions button { margin: 0; }
/* DOM은 확인(첫 submit)이 먼저라 Enter=확인. 보이기는 취소 왼쪽·확인 오른쪽 */
.name-dialog .dlg-cancel { order: 1; }
.name-dialog .dlg-ok { order: 2; }
.row-detail {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  margin: 8px 0 2px; margin-left: calc(2.1em + 14px + 16px); /* 기호 열 아래로 정렬 */
  padding: 8px 12px; background: #f4f7fc; border-radius: 6px;
}
.row-detail label { font-size: 12px; }
.row-detail input, .row-detail select, .row-detail textarea { padding: 5px 7px; }
.row-detail input:disabled { background: #eef0f4; color: var(--muted); cursor: not-allowed; }

/* 검량선 안내·실시간 미리보기 */
.cal-help { flex-basis: 100%; font-size: 12px; line-height: 1.55; color: var(--muted); background: #eef2f9; border-radius: 7px; padding: 8px 11px; }
.cal-help b { color: var(--ink); }
.cal-live { flex-basis: 100%; font-size: 13px; line-height: 1.6; color: #15602b; background: #eaf6ec; border: 1px solid #c9e6cf; border-radius: 7px; padding: 8px 11px; }
.cal-live.cal-live-err { color: #9a6a2f; background: #fff7ed; border-color: #fde4c7; }
.cal-live .muted { color: var(--muted); }

/* 요소 계산식 — 우측 슬라이드 패널 */
.calc-panel {
  position: fixed; top: 0; right: 0; z-index: 60;
  width: 480px; max-width: 94vw; height: 100vh; height: 100dvh;
  background: #fff; border-left: 1px solid var(--line);
  box-shadow: -10px 0 34px rgba(20, 25, 35, .14);
  display: flex; flex-direction: column;
  transform: translateX(102%); visibility: hidden;
  transition: transform .2s ease, visibility .2s;
}
.calc-panel.open { transform: translateX(0); visibility: visible; }
/* 패널이 열리면 본문을 왼쪽으로 밀어 우측 입력 GUI가 안 가려지게 (넓은 화면에서만) */
body { transition: padding-right .2s ease; }
@media (min-width: 1280px) { body.panel-open { padding-right: 480px; } }
.calc-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line); background: #f3f6fc;
}
.calc-panel-head h3 { margin: 0; font-size: 15px; }
#calc-panel-close { border: none; background: none; font-size: 16px; color: var(--muted); padding: 4px 8px; }
#calc-panel-close:hover { color: var(--ink); }
#calc-panel-body { padding: 14px 16px 28px; overflow-y: auto; }

.cp-type {
  display: inline-block; font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 6px; padding: 3px 9px; margin-bottom: 12px;
}
.cp-section { margin-bottom: 14px; }
.cp-h { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.cp-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.cp-kv dt { color: var(--muted); }
.cp-kv dd { margin: 0; color: var(--ink); word-break: break-all; }
.cp-step { margin: 8px 0; }
.cp-step-label { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.cp-math { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.cp-math .katex { font-size: 0.92em; }
.cp-note { font-size: 12.5px; color: var(--muted); background: #f7f9fc; border-radius: 7px; padding: 9px 11px; margin: 4px 0 14px; }
.cp-err { color: var(--warn); font-weight: 600; }
.cp-result { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cp-result th, .cp-result td { border: 1px solid var(--line); padding: 6px 7px; text-align: center; }
.cp-result thead { background: #f0f2f6; }
.cp-result td:first-child { font-weight: 700; }
.c-remove { color: var(--warn); border-color: #f1d4d4; }

/* 계층 결과 cascade */
.node-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: #fff; }
.node-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.node-card-head .nc-sym { font-size: 15px; font-weight: 700; }
.node-card-head .nc-meta { margin-left: auto; font-size: 12px; color: var(--muted); }
.nc-mode { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 1px 7px; }
.nc-mode-r { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.nc-mode-s { color: #854f0b; background: #faeeda; border: 1px solid #f3d9a6; }
.node-card .budget-table { margin-top: 4px; }
.node-children { margin-top: 10px; }
.nc-eqs { margin: 2px 0 8px; border: 1px dashed var(--line); border-radius: 8px; background: #fafbfe; padding: 2px 10px 6px; }
.nc-eqs > summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 5px 0; user-select: none; }
.nc-eqs > summary:hover { color: var(--accent); }
.nc-eq { overflow-x: auto; overflow-y: hidden; margin: 4px 0 2px 4px; }
.nc-eq .katex-display { margin: 4px 0; text-align: left; }
.nc-eq .katex { font-size: 1.0em; }
.budget-table tr.bt-foot td { font-weight: 600; background: #f0f4fa; }

.budget-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.budget-table th, .budget-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: right; }
.budget-table th:nth-child(-n+2), .budget-table td:nth-child(-n+2) { text-align: left; }
.budget-table thead { background: #f0f2f6; }
.budget-table tfoot { font-weight: 600; background: #fafbfc; }

#result-summary { display: grid; gap: 4px; font-size: 15px; }
.result-final { margin-top: 8px; font-size: 17px; }
.result-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.formula { margin: 14px 0; overflow-x: auto; overflow-y: hidden; }
.result-warn { background: #fff7ed; border: 1px solid #fde4c7; color: #9a6a2f; border-radius: 7px; padding: 9px 12px; font-size: 13px; line-height: 1.6; }

.cal-figure { display: inline-block; margin: 12px 16px 0 0; vertical-align: top; }
.cal-figure figcaption { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.cal-svg { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.cal-svg .axis { stroke: #9aa3b2; stroke-width: 1; }
.cal-svg .fit-line { stroke: var(--accent); stroke-width: 1.5; }
.cal-svg .fit-dot { fill: #ef4444; }
.cal-svg .cal-eq { font-size: 11px; fill: var(--ink); }
.cal-stats { font-size: 13px; margin-top: 4px; }

.error-banner { background: #fef2f2; color: var(--warn); border: 1px solid #f3c9c9; border-radius: 8px; padding: 10px 14px; }
.hidden { display: none !important; }

/* 특성요인도(피쉬본) */
.row-main .c-branch { width: 110px; }
#fishbone { overflow-x: auto; }
.fishbone { width: 100%; height: auto; display: block; }
.fishbone .fb-spine { stroke: var(--ink); stroke-width: 2.5; }
.fishbone .fb-arrow { fill: var(--ink); }
.fishbone .fb-bone { stroke: var(--muted); stroke-width: 2; }
.fishbone .fb-bone-arrow { fill: var(--muted); stroke: none; }
.fishbone .fb-handle {
  fill: #fff; stroke: var(--accent); stroke-width: 2;
  cursor: grab; touch-action: none; opacity: 0.9;
}
.fishbone .fb-handle:hover { fill: var(--accent); opacity: 1; }
.fishbone .fb-handle:active { cursor: grabbing; }
.fishbone .fb-twig { stroke: var(--line); stroke-width: 1.3; }
.fishbone .fb-head { fill: none; stroke: var(--ink); stroke-width: 2; }
.fishbone .fb-head-t1 { font-size: 15px; font-weight: 700; fill: var(--ink); }
.fishbone .fb-head-t2 { font-size: 12px; fill: var(--muted); }
.fishbone .fb-branch { font-size: 13px; font-weight: 700; fill: var(--ink); }
.fishbone .fb-branch-sub { font-size: 11.5px; font-weight: 600; fill: var(--muted); }
.fishbone .fb-item { font-size: 11px; fill: var(--muted); }
.fishbone .fb-dot { fill: #fff; stroke: var(--muted); stroke-width: 1.6; }
.fishbone .fb-dot-major { fill: #fdecec; stroke: var(--warn); stroke-width: 2.4; }
.fishbone text { pointer-events: none; } /* 라벨 아래의 원(노드)을 드래그할 수 있게 */
.fishbone .fb-drag { cursor: grab; touch-action: none; }
.fishbone .fb-drag:hover { stroke: var(--accent); stroke-width: 2.6; }
.fishbone .fb-drag:active { cursor: grabbing; }
/* 중심선 위 부착점 이동(작은 네모) · 중심 화살표 길이 조절(끝점 원) */
.fishbone .fb-attach { fill: var(--accent); stroke: #fff; stroke-width: 1.5; cursor: ew-resize; touch-action: none; }
.fishbone .fb-attach:hover { fill: var(--accent-dark); }
.fishbone .fb-spine-handle { fill: #fff; stroke: var(--ink-strong); stroke-width: 2.4; cursor: ew-resize; touch-action: none; }
.fishbone .fb-spine-handle:hover { fill: var(--ink-strong); }

.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ── 보고서(PDF) 화면 오버레이 ── */
#report { display: none; }
body.report-mode { overflow: hidden; }
body.report-mode #report { display: block; position: fixed; inset: 0; z-index: 100; background: #e7ebee; overflow: auto; }
.rpt-toolbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; background: var(--slate); border-bottom: 3px solid var(--accent); color: #fff;
}
.rpt-toolbar-title { font-weight: 700; margin-right: auto; letter-spacing: .3px; }
.rpt-toolbar button { margin: 0; background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.rpt-toolbar button:hover { background: rgba(255,255,255,.2); }
.rpt-toolbar button.primary { background: var(--accent); border-color: var(--accent); box-shadow: none; }
.rpt-toolbar button.primary:hover { background: var(--accent-dark); }
/* AI 서술 생성 상태 칩 */
.rpt-ai-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.12); color: #dff3e8; }
.rpt-ai-chip .spin { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: rpt-spin .7s linear infinite; }
.rpt-ai-chip.done { background: var(--accent); color: #fff; }
.rpt-ai-chip.err { background: #7a2530; color: #ffdede; }
.rpt-ai-chip.hidden { display: none; }
@keyframes rpt-spin { to { transform: rotate(360deg); } }

/* KOLAS 보고서 문서 — 브로셔 스타일 */
.rpt {
  max-width: 820px; margin: 22px auto 40px; background: #fff; padding: 0 0 20px;
  box-shadow: 0 8px 34px rgba(21,43,60,.16); color: #222; line-height: 1.62;
  font-family: system-ui, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-variant-numeric: tabular-nums;
}
/* 표지 헤더 밴드 (다크 슬레이트 + 그린 악센트) */
.rpt-head {
  background: linear-gradient(135deg, var(--slate) 0%, var(--slate-2) 100%);
  color: #fff; padding: 30px 44px 26px; border-bottom: 4px solid var(--accent);
}
.rpt-eyebrow { margin: 0 0 10px; font-size: 11.5px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: #7fdcac; }
.rpt-title { font-size: 27px; font-weight: 800; letter-spacing: -.3px; margin: 0; color: #fff; }
.rpt-subject { margin: 12px 0 0; font-size: 14px; color: #cdd8e0; }
.rpt-subject b { color: #fff; font-weight: 700; }
.rpt-body { padding: 8px 44px 0; }
/* 메타 정보 카드 */
.rpt-meta { width: 100%; border-collapse: separate; border-spacing: 0; margin: 22px 0 8px; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rpt-meta th, .rpt-meta td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line); }
.rpt-meta tr:last-child th, .rpt-meta tr:last-child td { border-bottom: none; }
.rpt-meta th { background: var(--slate-soft); width: 92px; white-space: nowrap; color: var(--ink-strong); font-weight: 700; }
.rpt-meta td { border-left: 1px solid var(--line); }
/* 섹션 제목: 그린 밑줄 악센트 */
.rpt-h2 {
  font-size: 17px; font-weight: 800; color: var(--ink-strong); letter-spacing: -.2px;
  margin: 30px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); position: relative;
}
.rpt-h2::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 46px; height: 3px; background: var(--accent); border-radius: 2px; }
.rpt-h3 { font-size: 14.5px; font-weight: 700; color: var(--ink-strong); margin: 18px 0 7px; }
.rpt-mode { font-weight: 500; font-size: 12px; color: var(--muted); }
.rpt-sec { break-inside: avoid; }
.rpt-narr { font-size: 13.7px; line-height: 1.8; color: #2a2f37; margin: 6px 0 10px; text-align: justify; }
.rpt-narr b { font-weight: 700; color: var(--ink-strong); }
.rpt-narr.rpt-narr-ai { border-left: 3px solid var(--accent-line); padding-left: 13px; }
.rpt-leaf { margin-left: 4px; padding: 2px 0 2px 16px; border-left: 3px solid var(--accent-line); }
.rpt-leaf .rpt-h3 { font-size: 14px; color: var(--ink-strong); }
.rpt-combine .rpt-h3 { padding-bottom: 5px; border-bottom: 1px dotted var(--line); }
.rpt-summary { break-inside: auto; }
.rpt-sum-block { margin-bottom: 16px; }
.rpt-sum-block .rpt-h3 { background: var(--accent-soft); padding: 7px 11px; border-left: 4px solid var(--accent); border-radius: 0 6px 6px 0; }
.rpt-sum-block .rpt-tbl { margin: 8px 0 4px; }
.sym-up { font-style: normal; }
.rpt sub { font-size: .72em; }
.rpt-eq { margin: 8px 0 12px 6px; overflow-x: auto; overflow-y: hidden; }
.rpt-eq .katex-display { margin: 4px 0; text-align: left; }
.rpt-eq .katex { font-size: 1.02em; }
.rpt-fish { text-align: center; margin: 12px 0; padding: 14px; background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.rpt-fish svg { max-width: 100%; height: auto; }
/* 표: 얇은 선 + 슬레이트 헤더 + 제브라 */
.rpt-tbl { border-collapse: collapse; width: 100%; margin: 10px 0 18px; font-size: 13px; }
.rpt-tbl th, .rpt-tbl td { padding: 7px 10px; text-align: center; border-bottom: 1px solid var(--line); }
.rpt-tbl thead th { background: var(--slate); color: #fff; font-weight: 600; border-bottom: none; letter-spacing: .01em; }
.rpt-tbl tbody tr:nth-child(even) { background: #f7f9fa; }
.rpt-tbl .rsym { font-style: normal; }
.rpt-tbl .rfoot td { font-weight: 700; background: var(--accent-soft) !important; color: var(--ink-strong); border-top: 2px solid var(--accent-line); }
.rpt-rep { max-width: 320px; }
.rpt-rep th, .rpt-rep td { text-align: center; }
.rpt-final { max-width: 440px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rpt-final th, .rpt-final td { border-bottom: 1px solid var(--line); }
.rpt-final tr:last-child th, .rpt-final tr:last-child td { border-bottom: none; }
.rpt-final th { background: var(--slate-soft); text-align: left; width: 210px; color: var(--ink-strong); }
.rpt-final td { text-align: right; }
/* 최종 결과 콜아웃 밴드 (브로셔 하단 밴드 스타일) */
.rpt-result {
  margin-top: 18px; padding: 16px 20px; border: none; border-radius: 12px; font-size: 15px;
  background: linear-gradient(135deg, var(--slate) 0%, var(--slate-2) 100%); color: #eaf2ee;
  box-shadow: 0 6px 20px rgba(21,43,60,.2);
}
.rpt-result .rpt-eqn { font-weight: 800; color: #fff; }
.rpt-result .katex { color: #fff; }
/* 인쇄 푸터 (반복) */
.rpt-foot { display: none; }

@media print {
  body.report-mode { overflow: visible; }
  body.report-mode .container, body.report-mode .rpt-toolbar, body.report-mode > *:not(#report) { display: none !important; }
  body.report-mode #report { position: static; background: #fff; overflow: visible; }
  .rpt { max-width: none; margin: 0; padding: 0 0 12mm; box-shadow: none; }
  .rpt-head { padding: 20mm 16mm 12mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rpt-body { padding: 0 16mm; }
  .rpt-tbl thead th, .rpt-result, .rpt-sum-block .rpt-h3, .rpt-tbl .rfoot td, .rpt-meta th, .rpt-final th {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .rpt-sec { break-inside: avoid; }
  .rpt-foot { display: flex; position: fixed; bottom: 6mm; left: 16mm; right: 16mm;
    justify-content: space-between; font-size: 9.5px; color: var(--muted);
    border-top: 1px solid var(--line); padding-top: 4px; }
  @page { margin: 16mm; }
  @page { @bottom-right { content: counter(page) " / " counter(pages); } }
}
/* 보고서 모드가 아닐 때의 일반 인쇄 */
@media print {
  body:not(.report-mode) { background: #fff; }
  body:not(.report-mode) .no-print { display: none !important; }
  body:not(.report-mode) .container { max-width: none; padding: 0; }
  body:not(.report-mode) .card { border: none; padding: 0; margin: 0 0 16px; }
  body:not(.report-mode) .budget-table th, body:not(.report-mode) .budget-table td { border: 1px solid #000; }
  body:not(.report-mode) .calc-panel { display: none !important; }
}
