/* 딸깍 계산기 — calculator.css (v1.0.0) · 다크 테마 (지도·차트 딸깍과 통일) */
:root {
  /* 색 토큰은 shared/theme.css 가 공급(라이트 기본+다크 선택). 비색상 토큰만 유지 */
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', '맑은 고딕', sans-serif;
  line-height: 1.6; font-size: 15px;
}

/* topbar (지도 딸깍과 동일 구조·색) */
.topbar { display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2); border-bottom: 1px solid var(--border); padding: 10px 18px; position: sticky; top: 0; z-index: 20; }
.tb-left { display: flex; align-items: center; gap: 12px; }
.home-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text3); text-decoration: none; font-size: 13px; }
.home-link:hover { color: var(--accent); }
.sep { width: 1px; height: 20px; background: var(--border); }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.logo svg { color: var(--accent); }
.tb-right { display: flex; align-items: center; gap: 6px; }
.tbtn { display: inline-flex; align-items: center; gap: 5px; background: none; border: none; cursor: pointer;
  color: var(--text2); padding: 5px 9px; border-radius: 7px; font-size: 12px; text-decoration: none; white-space: nowrap; font-family: inherit; }
.tbtn:hover { background: var(--bg); color: var(--accent); }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 18px 60px; }
.intro { color: var(--text2); font-size: 14px; margin-bottom: 18px; line-height: 1.7; }
.intro b { color: var(--text); }

.calc-layout { display: grid; grid-template-columns: 184px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .calc-layout { grid-template-columns: 1fr; } }

/* 좌측 메뉴 */
.calc-menu { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; position: sticky; top: 64px; }
@media (max-width: 760px) { .calc-menu { position: static; } }
.menu-group { font-size: 11px; color: var(--text3); font-weight: 700; letter-spacing: .02em; padding: 10px 10px 5px; text-transform: none; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 13.5px; padding: 8px 10px; border-radius: 8px; font-family: inherit; line-height: 1.3; }
.menu-item:hover { background: var(--bg); color: var(--text); }
.menu-item.active { background: var(--accent-dim); color: var(--accent2); font-weight: 600; }
.menu-item .mi-ico { font-size: 15px; width: 18px; text-align: center; flex: none; }

/* 본문 패널 */
.calc-body { min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.panel-h { font-size: 18px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.panel-desc { color: var(--text3); font-size: 13px; margin-bottom: 16px; line-height: 1.6; }
.panel-desc code { background: var(--bg); padding: 1px 5px; border-radius: 4px; color: var(--accent2); font-size: 12px; }

/* 입력/옵션 */
.row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 14px; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld > label { font-size: 12px; font-weight: 600; color: var(--text3); }
.fld input[type=text], .fld input[type=number], .fld select, .num-in {
  height: 36px; background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; color: var(--text);
  padding: 0 11px; font-size: 14px; font-family: inherit; }
.fld input:focus, .fld select:focus, .num-in:focus { outline: none; border-color: var(--accent); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: none; color: var(--text2); padding: 7px 12px; font-size: 13px; cursor: pointer; font-family: inherit; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); cursor: pointer; }
.chk input { accent-color: var(--accent); }

/* 붙여넣기 영역 */
.paste { width: 100%; min-height: 120px; background: var(--bg); border: 1.5px dashed var(--border2); border-radius: 9px;
  color: var(--text); padding: 11px 13px; font-size: 13px; font-family: 'Consolas','D2Coding',monospace; resize: vertical; line-height: 1.5; }
.paste:focus { outline: none; border-color: var(--accent); border-style: solid; }
.paste.drag { border-color: var(--accent); background: var(--accent-dim); }

/* 버튼 */
.btn { display: inline-flex; align-items: center; gap: 6px; border: none; cursor: pointer; font-family: inherit;
  border-radius: 8px; padding: 9px 15px; font-size: 13.5px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-sec { background: var(--panel2); color: var(--text2); border: 1px solid var(--border2); }
.btn-sec:hover { color: var(--text); border-color: var(--accent); }
.btn-ghost { background: none; color: var(--text3); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
/* 추가(+) 버튼 — 눈에 잘 띄게: 강조색 채움 + 점선 테두리 */
.btn-add { background: var(--accent-dim); color: var(--accent2); border: 1px dashed var(--accent); font-weight: 600; }
.btn-add:hover { background: var(--accent); color: #fff; border-style: solid; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

/* 결과 표 */
.result-wrap { margin-top: 16px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.result-head .rh-info { font-size: 12.5px; color: var(--text3); }
.tbl-scroll { overflow: auto; border: 1px solid var(--border); border-radius: 8px; max-height: 460px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
table.grid th, table.grid td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
table.grid thead th { background: var(--panel2); color: var(--text); font-weight: 700; position: sticky; top: 0; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:nth-child(even) td { background: rgba(255,255,255,0.015); }

/* 단일 값 결과 */
.bigval { font-size: 32px; font-weight: 800; color: var(--accent2); font-variant-numeric: tabular-nums; }
.bigval-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.formula { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 13px; font-size: 13px;
  color: var(--text2); font-family: 'Consolas','D2Coding',monospace; margin-top: 8px; }

/* 예산 그리드 */
.bud-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
.bud-tbl th, .bud-tbl td { border: 1px solid var(--border); padding: 6px 10px; }
.bud-tbl th { background: var(--panel2); font-size: 12px; color: var(--text3); font-weight: 600; }
.bud-tbl td.r, .bud-tbl th.r { text-align: right; }
.bud-tbl input.num-in { height: 32px; width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.bud-tbl input.name-in { height: 32px; width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); padding: 0 6px; font-family: inherit; font-size: 13.5px; }
.bud-tbl input.name-in:focus { background: var(--bg); border-color: var(--accent); outline: none; }
.bud-tbl tfoot td, .bud-tbl tr.sum td { font-weight: 700; background: var(--bg2); }
.bud-del { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; }
.bud-del:hover { color: var(--danger); }
.bud-tbl th.fac-h { font-size: 11px; color: var(--text3); font-weight: 500; min-width: 62px; }
.bud-tbl input.fac-in { height: 30px; width: 100%; min-width: 56px; background: var(--bg); border: 1px solid var(--border2); border-radius: 6px; color: var(--text); padding: 0 6px; font-family: inherit; font-size: 12.5px; text-align: center; }
.bud-tbl input.fac-in:focus { outline: none; border-color: var(--accent); }
.bud-tbl input.fac-in::placeholder { color: var(--border2); }
.bud-tbl td.mv { padding: 2px; text-align: center; }
.drag-h { cursor: grab; color: var(--text3); font-size: 14px; user-select: none; line-height: 1; display: inline-block; padding: 4px 2px; }
.drag-h:hover { color: var(--accent); }
.drag-h:active { cursor: grabbing; }
.bud-tbl tr.item.dragging { opacity: .4; }
.bud-tbl tr.item.drop-target td { border-top: 2px solid var(--accent); }
/* 카테고리(비목군) 머리행 */
.bud-tbl tr.grp td { background: var(--panel2); }
.bud-tbl input.grp-name { height: 30px; width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); padding: 0 6px; font-family: inherit; font-size: 13.5px; font-weight: 700; }
.bud-tbl input.grp-name:focus { background: var(--bg); border-color: var(--accent); outline: none; }
.bud-tbl input.grp-name::placeholder { color: var(--text3); font-weight: 400; }
.bud-tbl tr.grp .grp-amt { font-weight: 700; }
.bud-tbl tr.grp .grp-pct { font-size: 11px; }
.bud-tbl .grp-add { background: var(--accent-dim); border: 1px dashed var(--accent); border-radius: 6px; color: var(--accent2); cursor: pointer; font-size: 12.5px; font-weight: 600; padding: 4px 10px; white-space: nowrap; }
.bud-tbl .grp-add:hover { background: var(--accent); border-style: solid; color: #fff; }
.bud-tbl tr.item input.it-name { padding-left: 16px; }   /* 세부 항목 들여쓰기 */
.bud-tbl tr.grp.dragging { opacity: .4; }
.bud-tbl tr.grp.drop-target td { border-top: 2px solid var(--accent); }
.bud-tbl td.pct-cell, .bud-tbl td.grp-pct { font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.bud-tbl tr.foot td { background: var(--bg2); }
.bud-tbl tr.foot.sum td { font-weight: 700; }
.bud-tbl input.bud-amt-in { height: 30px; width: 100%; background: var(--bg); border: 1px solid var(--accent); border-radius: 6px; color: var(--text); padding: 0 8px; font-family: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.bud-tbl input.bud-amt-in:focus { outline: none; border-color: var(--accent2); }
.bud-tbl input.bud-amt-in::placeholder { color: var(--text3); font-size: 11px; }
.dim { color: var(--text3); }
.inl { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text2); }
.num-in.sm { height: 30px; width: 52px; text-align: right; padding: 0 6px; }
.bud-meta { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0; }
.bud-stat { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 14px; }
.bud-stat .bs-k { font-size: 11px; color: var(--text3); }
.bud-stat .bs-v { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bud-stat.over .bs-v { color: var(--danger); }
.bud-stat.ok .bs-v { color: var(--success); }

/* AHP 응답 도우미 */
.ahp-items { width: 320px; max-width: 100%; background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; color: var(--text); padding: 8px 10px; font-family: inherit; font-size: 13.5px; resize: vertical; }
.ahp-items:focus { outline: none; border-color: var(--accent); }
.ahp-crrow { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); margin: 6px 0 14px; }
.ahp-crrow.ahp-c-ok { border-color: #3aa757; background: rgba(58,167,87,.10); }
.ahp-crrow.ahp-c-warn { border-color: #c79a16; background: rgba(199,154,22,.10); }
.ahp-crrow.ahp-c-bad { border-color: #d05a52; background: rgba(208,90,82,.10); }
.ahp-cr-big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ahp-crmsg { font-size: 13px; color: var(--text2); line-height: 1.5; }
.ahp-pair { padding: 9px 0; border-bottom: 1px solid var(--border); }
.ahp-pair-h { font-size: 13px; margin-bottom: 5px; }
.ahp-scale { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.ahp-side { font-size: 11px; padding: 0 4px; white-space: nowrap; }
.ahp-btn { min-width: 30px; height: 30px; padding: 0 4px; border: 1px solid var(--border2); border-radius: 6px; background: var(--bg); color: var(--text2); cursor: pointer; font-size: 12px; font-variant-numeric: tabular-nums; position: relative; }
.ahp-btn:hover { border-color: var(--accent); }
.ahp-btn.eq { font-weight: 700; }
.ahp-btn.sel { outline: 2px solid var(--accent); outline-offset: 0; color: var(--text); font-weight: 800; }
.ahp-btn.ahp-c-ok { border-color: #3aa757; background: rgba(58,167,87,.16); color: var(--text); }
.ahp-btn.ahp-c-warn { border-color: #c79a16; background: rgba(199,154,22,.16); }
.ahp-btn.ahp-c-bad { border-color: #d05a52; background: rgba(208,90,82,.12); }
.ahp-btn.ahp-best::after { content: '★'; position: absolute; top: -8px; right: -3px; font-size: 11px; color: var(--accent); }
.ahp-wrow { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.ahp-wn { width: 130px; font-size: 13px; }
.ahp-wbar { flex: 1; height: 14px; background: var(--bg2); border-radius: 7px; overflow: hidden; }
.ahp-wbar > span { display: block; height: 100%; background: var(--accent); }
.ahp-wv { width: 56px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; }

/* 알림 */
.note { font-size: 12.5px; border-radius: 8px; padding: 9px 12px; margin: 10px 0; line-height: 1.55; }
.note.err { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--danger); }
.note.ok { background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.3); color: var(--success); }
.note.info { background: var(--bg); border: 1px solid var(--border); color: var(--text3); }
.flash { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff;
  padding: 10px 18px; border-radius: 9px; font-size: 13.5px; font-weight: 600; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }

/* 모달 */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border2); border-radius: 12px; width: 100%; max-width: 440px; max-height: 80vh; display: flex; flex-direction: column; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-x { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 14px 18px; overflow: auto; }
.save-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.save-item .si-main { flex: 1; min-width: 0; cursor: pointer; }
.save-item .si-name { font-size: 14px; font-weight: 600; color: var(--text); }
.save-item .si-meta { font-size: 11.5px; color: var(--text3); }
.save-item:hover { border-color: var(--accent); }
.empty { color: var(--text3); font-size: 13px; text-align: center; padding: 20px 0; }

/* ════════ 목적 홈 (무엇을 하고 싶으세요?) ════════ */
.calc-home { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 26px 28px; }
.home-hero h2 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.home-hero p { font-size: 13.5px; color: var(--text2); line-height: 1.6; }
.home-group { margin-top: 22px; }
.home-ghead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.home-ghead .hg-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); flex: none; }
.home-ghead .hg-name { font-size: 14.5px; font-weight: 700; color: var(--text); }
.home-ghead .hg-sub { font-size: 12.5px; color: var(--text3); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tool-tile { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 11px; padding: 13px 15px; cursor: pointer; font-family: inherit; transition: border-color .12s, background .12s, transform .12s; }
.tool-tile:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-1px); }
.tool-tile .tt-ico { font-size: 22px; width: 26px; text-align: center; flex: none; }
.tool-tile .tt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool-tile .tt-name { font-size: 14px; font-weight: 600; color: var(--text); }
.tool-tile .tt-tag { font-size: 11.5px; color: var(--text3); line-height: 1.35; }

/* 도구 화면 백버튼 + 메뉴 '처음' */
.calc-back { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 13px; font-family: inherit; padding: 2px 6px 8px 0; }
.calc-back:hover { color: var(--accent); }
.menu-item.menu-home { font-weight: 600; margin-bottom: 2px; }
