/* 디자인 기준: 세컨픽셀(2NDPX) 견적서 템플릿 (harness/견적서/!template/estimate_template.html)
   - 브랜드 블루 #0E53E9 계열, 남색 잉크 #0A1833, 회청색 면 #F1F4F9
   - 표지: 블루 그라데이션 + 하늘색 픽셀 사각형 / 섹션 머리: 회청색 띠 + 블루 번호 칩
   - Pretendard, 모서리 7~10px, 픽셀(작은 사각형) 마커 */

/* 테마: data-theme="light" | "dark" | 없음(시스템 설정 따름) */
:root {
  color-scheme: light;
  --brand: #0E53E9;
  --brand-hi: #1B87FE;
  --brand-deep: #0E3DE9;
  --ink: #0A1833;
  --text: #2B3445;
  --mute: #6B7588;
  --line: #E3E7EE;
  --page: #F5F7FA;
  --surface: #FFFFFF;
  --head: #F1F4F9;
  --tint: #EEF4FF;
  --tint-line: #CFE0FF;
  --amber: #B45309;
  --amber-bg: #FFF4E0;
  --negative: #D03238;
  --track: #E3E7EE;
  --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --pill: 999px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #3D7BFF; --brand-hi: #5FA2FF; --brand-deep: #2A5CF0;
    --ink: #E8EEF8; --text: #C3CCDB; --mute: #8592AA; --line: #26324A;
    --page: #0B1220; --surface: #121A2B; --head: #1A2438;
    --tint: #16254A; --tint-line: #2A4380; --amber: #F2B25C; --amber-bg: #3A2A12; --negative: #FF7B7F; --track: #26324A;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #3D7BFF; --brand-hi: #5FA2FF; --brand-deep: #2A5CF0;
  --ink: #E8EEF8; --text: #C3CCDB; --mute: #8592AA; --line: #26324A;
  --page: #0B1220; --surface: #121A2B; --head: #1A2438;
  --tint: #16254A; --tint-line: #2A4380; --amber: #F2B25C; --amber-bg: #3A2A12; --negative: #FF7B7F; --track: #26324A;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--text);
  font: 15px/1.6 Pretendard, "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  font-variant-numeric: tabular-nums; word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; color: var(--ink); }
h2 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; line-height: 1.35; margin-bottom: 14px; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--mute); }

/* 픽셀 마커 (견적서 표지의 두 사각형) */
.mark { position: relative; display: inline-block; width: 11px; height: 11px; flex: none; }
.mark i { position: absolute; width: 5px; height: 5px; }
.mark i:first-child { left: 0; bottom: 0; background: #8CCBFF; }
.mark i:last-child { right: 0; top: 0; background: #fff; }

/* ---------- 상단 바 ---------- */
.nav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.nav-in { max-width: 1600px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brandmark { display: flex; align-items: center; gap: 12px; margin-right: auto; color: var(--ink); }
.brandmark img { height: 22px; width: auto; display: block; }
.brandmark .logo-w { display: none; }
.brandmark .divider { width: 1px; height: 16px; background: var(--line); }
.wordmark { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
:root[data-theme="dark"] .brandmark .logo-c { display: none; }
:root[data-theme="dark"] .brandmark .logo-w { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brandmark .logo-c { display: none; }
  :root:not([data-theme="light"]) .brandmark .logo-w { display: block; }
}

/* ---------- 히어로 (견적서 표지 띠) ---------- */
.hero { position: relative; overflow: hidden; color: #fff; background: linear-gradient(160deg, #0E3DE9 0%, #0E53E9 60%, #1463F0 100%); }
.hero .pix { position: absolute; pointer-events: none; }
/* 픽셀 사각형은 제목과 환율 카드 사이 빈 곳에 — 글자 뒤로 겹치지 않게 */
.hero .pix.hi { left: calc(50% + 40px); top: -70px; width: 220px; height: 220px; background: linear-gradient(45deg, #8CCBFF 0%, #4AA8FF 55%, #2A95FF 100%); }
.hero .pix.lo { left: calc(50% - 90px); top: 150px; width: 130px; height: 130px; background: linear-gradient(45deg, #4AA8FF 0%, #2A95FF 55%, #1B87FE 100%); opacity: .9; }
.hero-in { position: relative; max-width: 1600px; margin: 0 auto; padding: 44px 24px 36px; display: grid; grid-template-columns: 1fr 380px; gap: 32px; align-items: end; }
.hero .doc { font-size: 14px; font-weight: 700; color: #BFE0FF; margin-bottom: 10px; }
.hero h1 { font-size: 40px; line-height: 1.3; font-weight: 800; letter-spacing: -.025em; color: #fff; }
.hero .lead { font-size: 15px; color: #DCEBFF; margin: 14px 0 6px; max-width: 620px; }
.hero .sub { font-size: 13px; color: #BFD9FF; margin: 0; }
.fx-card { position: relative; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .28); border-radius: var(--r-xl); padding: 18px 20px; display: grid; gap: 6px; backdrop-filter: blur(2px); }
.fx-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: #fff; }
.fx-label em { font-style: normal; font-weight: 500; color: #BFD9FF; }
.fx-rate strong { font-size: 30px; font-weight: 700; letter-spacing: -.035em; line-height: 1.15; color: #fff; }
.fx-meta { font-size: 14px; font-weight: 600; color: #DCEBFF; }
.fx-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .25); }
.fx-card .seg { background: rgba(255, 255, 255, .14); }
.fx-card .seg button { color: #DCEBFF; }
.fx-card .seg button.on { background: #fff; color: var(--brand-deep); }
.fx-card .link { color: #fff; }
.fx-card.manual .fx-rate strong { color: #FFD7A8; }

/* ---------- 공통 컨트롤 ---------- */
.seg { display: inline-flex; background: var(--head); border-radius: var(--r-md); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: var(--r-sm); cursor: pointer; color: var(--mute); font-size: 13.5px; font-weight: 600; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--brand); color: #fff; }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font-size: 13.5px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn { border: 0; background: var(--brand); color: #fff; border-radius: var(--r-md); padding: 12px 20px; cursor: pointer; font-weight: 700; font-size: 15px; }
.btn:hover { background: var(--brand-deep); }
.btn-secondary { background: var(--head); color: var(--ink); }
.btn-secondary:hover { background: var(--line); }
.btn:disabled { opacity: .6; cursor: wait; }
input[type=number], select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); font-size: 14.5px; color: var(--ink);
}
input[type=number]:focus, select:focus { outline: 2px solid var(--tint-line); border-color: var(--brand); }
input[type=checkbox] { accent-color: var(--brand); width: 16px; height: 16px; }
summary { cursor: pointer; font-weight: 600; color: var(--ink); }

.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px; font-weight: 700; white-space: nowrap; }
.badge.good { background: var(--tint); color: var(--brand); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--amber-bg); color: var(--negative); }

/* 섹션 머리 (견적서와 같은 띠 + 번호 칩 + 오른쪽 알약) */
.sec-head { display: flex; align-items: center; gap: 10px; background: var(--head); border-radius: 9px; padding: 10px 13px; margin-bottom: 16px; }
.sec-head h2 { margin: 0; }
.sec-no { display: inline-flex; align-items: center; justify-content: center; min-width: 27px; height: 27px; padding: 0 7px; border-radius: 7px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 800; flex: none; }
.sec-badge { margin-left: auto; background: var(--surface); color: var(--brand); font-size: 11.5px; font-weight: 600; padding: 4px 12px; border-radius: var(--pill); white-space: nowrap; }

/* ---------- 전문가 모드 ---------- */
.tabs { max-width: 1600px; margin: 0 auto; padding: 18px 24px 0; display: flex; gap: 6px; }
.tabs button { border: 0; background: none; padding: 9px 16px; cursor: pointer; color: var(--mute); font-weight: 700; border-radius: var(--r-md); }
.tabs button.on { background: var(--ink); color: var(--surface); }

main { max-width: 1600px; margin: 0 auto; padding: 16px 24px 48px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 20px 22px; }
.layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.layout > * { min-width: 0; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; align-items: start; }
.cfg-grid .block { margin: 0; }
.prov-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.prov-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.providers { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.disabled { opacity: .4; cursor: not-allowed; }

.block { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); margin: 0 0 10px; padding: 13px 15px 15px; }
.block legend { float: left; width: 100%; padding: 0; margin-bottom: 12px; font-weight: 800; color: var(--ink); }
.block.off { padding-bottom: 13px; background: var(--page); }
.block.off legend { margin-bottom: 0; color: var(--mute); }
.block.off .body { display: none; }
.switch { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.body { display: grid; gap: 12px; clear: both; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--mute); }
.field.check { display: flex; align-items: center; gap: 8px; padding-top: 22px; font-size: 13.5px; font-weight: 600; color: var(--ink); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { font-size: 12px; color: var(--mute); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }

.cmp { table-layout: fixed; min-width: 900px; }
.cmp th:first-child { width: 150px; }
.cmp th, .cmp td { padding: 16px 18px; overflow-wrap: anywhere; white-space: normal; }
.cmp thead th { border-bottom: 1.5px solid var(--ink); }
.cmp th.prov .name { color: var(--ink); font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.01em; }
.cmp th.prov .info { font-weight: 400; margin-top: 4px; color: var(--mute); }
.cmp td.label { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.cmp td.label .muted { font-weight: 400; font-size: 12.5px; display: block; margin-top: 2px; }
.cmp .badge { white-space: normal; }
.cell .amt { font-weight: 800; font-size: 20px; letter-spacing: -.02em; line-height: 1.25; color: var(--ink); }
.cell .per { display: block; font-size: 12px; font-weight: 400; color: var(--mute); letter-spacing: 0; }
.cell .prod { margin-top: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.cell .pick, .cell .pick-static { font-weight: 600; font-size: 13.5px; }
.cell select.pick {
  width: auto; max-width: 100%; border: 0; border-radius: 0; padding: 0 18px 2px 0; background: transparent; cursor: pointer;
  appearance: none; -webkit-appearance: none; text-overflow: ellipsis; border-bottom: 1px dashed var(--mute);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7588' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 2px center;
}
.cell select.pick:hover { border-bottom-color: var(--brand); }
.cell select.pick:focus { outline: none; }
.cell .spec { margin-top: 2px; }
.cell .clamp { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }
.cell .sub-line { font-size: 12px; color: var(--mute); margin-top: 6px; }
.cell .sub-line .sep { margin: 0 6px; }
.cell .sub-line a { color: var(--mute); text-decoration: underline; text-underline-offset: 2px; }
.cell .sub-line a:hover { color: var(--brand); }
.cell .orig, .cell .spec { font-size: 12px; color: var(--mute); }
.cell.none { color: var(--mute); font-size: 13.5px; }
tr.total td { border-bottom: 0; border-top: 1.5px solid var(--ink); padding-top: 16px; }
tr.total .amt { font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
td.best { background: var(--tint); }
td.best .amt { color: var(--brand); }

.bars { margin-top: 22px; display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 96px 1fr 180px; gap: 12px; align-items: center; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.track { background: var(--track); border-radius: 3px; height: 10px; overflow: hidden; }
.fill { height: 100%; border-radius: 3px; background: #9DB5E8; }
.fill.best { background: var(--brand); }
.bar.partial { color: var(--mute); }
.bar.partial .fill { background: var(--line); }
.bar .v small { font-size: 12px; font-weight: 600; color: var(--mute); }
.bar .v { text-align: right; font-weight: 800; }

.notes { margin-top: 20px; font-size: 12.5px; color: var(--mute); display: grid; gap: 5px; background: var(--page); border-radius: var(--r-lg); padding: 13px 16px; line-height: 1.7; }
.notes .warn { color: var(--amber); }
.empty { padding: 48px; text-align: center; color: var(--mute); background: var(--page); border-radius: var(--r-lg); }

.browse-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.browse-filters { display: flex; gap: 16px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.browse-filters .field { min-width: 140px; }
.meta { font-size: 13px; color: var(--mute); margin-bottom: 12px; display: grid; gap: 4px; }
.browse th { cursor: pointer; border-bottom: 1.5px solid var(--ink); }
.browse th.sorted { color: var(--brand); }
.browse th.sorted::after { content: " ↓"; }
.browse th.sorted.asc::after { content: " ↑"; }
.table-wrap h2 { margin-top: 8px; }

/* ---------- 쉬운 모드 ---------- */
.easy { padding-top: 22px; }
.easy-grid { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 24px; align-items: start; }
.q { margin-top: 28px; }
.q:first-child { margin-top: 0; }
.q h2 { display: flex; align-items: center; gap: 10px; background: var(--head); border-radius: 9px; padding: 10px 13px; margin-bottom: 12px; }
.q h2 .num { display: inline-flex; align-items: center; justify-content: center; min-width: 27px; height: 27px; padding: 0 7px; border-radius: 7px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 800; flex: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.card { position: relative; display: grid; gap: 6px; align-content: start; text-align: left; padding: 18px 18px 16px; border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; }
.card:hover { border-color: var(--tint-line); }
.card.on { border-color: var(--brand); background: var(--tint); }
.card.on::after { content: ""; position: absolute; top: 12px; right: 12px; width: 6px; height: 6px; background: var(--brand); box-shadow: -6px 6px 0 #8CCBFF; }
.card .t { font-weight: 800; font-size: 16px; color: var(--ink); letter-spacing: -.01em; }
.card .d { color: var(--text); font-size: 13.5px; line-height: 1.55; }
.card .x { font-size: 12px; color: var(--mute); padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line); }
.card.on .x { border-top-color: var(--tint-line); }

.result-q { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 20px; scrollbar-width: none; }
.result-q::-webkit-scrollbar { display: none; }
.result-q h2 { display: flex; align-items: center; gap: 10px; background: var(--head); border-radius: 9px; padding: 10px 13px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; padding: 5px 12px; border: 1px solid var(--line); border-radius: var(--pill); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--mute); background: var(--surface); }
.chip input { display: none; }
.chip.on { color: var(--brand); background: var(--tint); border-color: var(--tint-line); }

.rank { display: grid; gap: 8px; }
.rank-item { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 8px; background: var(--surface); }
.rank-item.first { position: relative; overflow: hidden; border: 0; color: #fff; background: linear-gradient(160deg, #0E3DE9 0%, #0E53E9 60%, #1463F0 100%); }
.rank-item.first::before { content: ""; position: absolute; right: -30px; bottom: -34px; width: 72px; height: 72px; background: linear-gradient(45deg, #8CCBFF 0%, #4AA8FF 55%, #2A95FF 100%); opacity: .55; }
.rank-item.first > * { position: relative; }
.rank-item.first .pname, .rank-item.first .pos, .rank-item.first .ptotal { color: #fff; }
.rank-item.first .ptotal small, .rank-item.first .rank-sub, .rank-item.first .diff { color: #DCEBFF; }
.rank-item.first .track { background: rgba(255, 255, 255, .22); }
.rank-item.first .fill { background: #fff; }
.rank-item.first .badge.good { background: #fff; color: var(--brand-deep); }
.rank-item.first .rank-sub .warn { color: #FFD7A8; }
.rank-item.off { opacity: .55; }
.rank-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rank-head .pos { font-weight: 800; font-size: 15px; width: 18px; color: var(--mute); }
.rank-head .pname { font-weight: 800; font-size: 16px; color: var(--ink); }
.rank-head .diff { font-size: 12.5px; color: var(--mute); font-weight: 600; }
.rank-head .ptotal { margin-left: auto; font-weight: 800; font-size: 22px; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.rank-head .ptotal small { font-size: 13px; font-weight: 600; color: var(--mute); letter-spacing: 0; }
.rank-sub { font-size: 12.5px; color: var(--mute); }
.rank-sub .warn { color: var(--amber); }
.rank-note { font-size: 12.5px; line-height: 1.6; color: var(--text); background: var(--page); border-radius: var(--r-md); padding: 9px 12px; margin: 0 0 12px; }
.rank-note b { color: var(--brand); font-weight: 700; }
.easy-foot { font-size: 12px; margin: 14px 0 12px; color: var(--mute); }
.result-q .btn { width: 100%; }
.result-q .btn + .btn { margin-top: 8px; }
.scroll-thumb { position: absolute; right: 5px; width: 4px; border-radius: 4px; background: var(--ink); opacity: 0; transition: opacity .35s; pointer-events: none; }
.scroll-thumb.show { opacity: .3; transition: opacity .1s; }

.result-head { display: flex; align-items: center; gap: 12px; }
.result-head .sec-head { flex: 1; margin: 0; }
.result-head .btn { padding: 8px 16px; font-size: 13.5px; }
.result > .result-head { margin-bottom: 16px; }

/* ---------- 전문가 모드: 상단 고정 월 합계 ---------- */
.live-bar {
  position: sticky; top: calc(var(--nav-h, 56px) + 8px); z-index: 9; margin: 0 0 16px;
  padding: 14px 16px 10px; /* 위쪽 여백: 증감 칩이 살짝 떠 있을 자리 */
  display: flex; align-items: center; gap: 8px; overflow-x: auto; cursor: pointer;
  background: #0A1833; color: #fff; border-radius: var(--r-lg);
}
.live-bar:empty { display: none; }
.live-label { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: #BFD9FF; margin-right: 4px; white-space: nowrap; }
.live-item { position: relative; display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: var(--r-md); white-space: nowrap; }
.live-item .ln { font-size: 12.5px; font-weight: 600; color: #BFD9FF; }
.live-item .lv { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.live-item.best { background: var(--brand); }
.live-item.best .ln { color: #fff; }
.live-item.partial { opacity: .45; }
.live-item .lb, .live-item .lp { font-size: 11px; font-weight: 700; }
/* 증감 칩은 금액 오른쪽 위에 떠서 표시 — 자리를 차지하지 않아 금액이 흔들리지 않는다 */
.live-item .ld { position: absolute; top: -9px; right: 4px; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px; pointer-events: none; animation: live-flash 2.4s ease-out forwards; }
.live-item .ld.up { background: #FFE1E1; color: #A7000D; }
.live-item .ld.down { background: #DDF0FF; color: #0E3DE9; }
@keyframes live-flash { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

.cmp tr.sla-row td { border-top: 1px solid var(--line); }
.sla-lines { font-size: 13px; display: grid; gap: 2px; }
.sla-lines b { font-weight: 800; color: var(--ink); }

/* ---------- 바닥글 (견적서 하단 표기) ---------- */
footer { border-top: 1px solid var(--line); background: var(--surface); }
.foot-in { max-width: 1600px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--mute); }
.foot-in img { height: 14px; width: auto; }
.foot-in .logo-w { display: none; }
:root[data-theme="dark"] .foot-in .logo-c { display: none; }
:root[data-theme="dark"] .foot-in .logo-w { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .foot-in .logo-c { display: none; }
  :root:not([data-theme="light"]) .foot-in .logo-w { display: block; }
}
.foot-in .sp { margin-left: auto; }

@media (max-width: 1279px) {
  .hero .pix.lo { display: none; }
  .hero .pix.hi { left: auto; right: -60px; top: -110px; width: 200px; height: 200px; opacity: .55; }
}
@media (max-width: 1023px) {
  .easy-grid { grid-template-columns: 1fr; }
  .result-q { position: static; max-height: none; }
  .hero-in { grid-template-columns: 1fr; padding-top: 32px; }
}
@media (max-width: 767px) {
  .nav-in, .hero-in, .tabs, main, .foot-in { padding-left: 16px; padding-right: 16px; }
  .hero h1 { font-size: 30px; }
  .hero .pix.hi { width: 180px; height: 180px; top: -70px; right: -50px; }
  .rank-head .ptotal { font-size: 22px; width: 100%; margin-left: 0; }
  .brandmark { width: 100%; }
  /* 휴대폰: 상단 바를 고정하지 않고, 두 전환 버튼을 한 줄에 작게 */
  .nav { position: static; }
  .nav-in { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .nav-in .seg button { padding: 5px 9px; font-size: 12.5px; }
  .live-bar { top: 8px; }
}

/* ---------- 보고서 (PDF/인쇄) — 테마와 상관없이 흰 종이, 견적서와 같은 형식 ---------- */
.report { display: none; }
body.report-mode { background: #fff; }
body.report-mode > *:not(#report) { display: none !important; }
body.report-mode .report { display: block; }
@media print {
  @page { size: A4; margin: 14mm 12mm 16mm; }
  body { background: #fff !important; }
  body > *:not(#report) { display: none !important; }
  .report { display: block !important; }
}
.rpt { color: #2B3445; font-family: Pretendard, "Noto Sans KR", sans-serif; font-size: 11px; line-height: 1.55; max-width: 186mm; margin: 0 auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; word-break: keep-all; }
.rpt-head { position: relative; overflow: hidden; background: linear-gradient(160deg, #0E3DE9 0%, #0E53E9 60%, #1463F0 100%); color: #fff; border-radius: 10px; padding: 18px 22px 16px; margin-bottom: 14px; }
.rpt-head::before { content: ""; position: absolute; right: -30px; top: -50px; width: 150px; height: 150px; background: linear-gradient(45deg, #8CCBFF 0%, #4AA8FF 55%, #2A95FF 100%); }
.rpt-head::after { content: ""; position: absolute; right: 120px; top: 60px; width: 70px; height: 70px; background: linear-gradient(45deg, #4AA8FF 0%, #2A95FF 55%, #1B87FE 100%); }
.rpt-head > * { position: relative; z-index: 1; }
.rpt-logo { height: 16px; width: auto; display: block; margin-bottom: 14px; }
.rpt-kicker { color: #BFE0FF; font-weight: 700; font-size: 11px; }
.rpt h1 { font-size: 22px; font-weight: 800; letter-spacing: -.025em; line-height: 1.3; margin: 4px 0 10px; color: #fff; }
.rpt-meta { display: grid; gap: 2px; font-size: 10px; color: #DCEBFF; }
.rpt h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; color: #0A1833; margin: 16px 0 8px; padding: 7px 10px; background: #F1F4F9; border-radius: 7px; letter-spacing: -.02em; }
.rpt h2 .no { display: inline-flex; align-items: center; justify-content: center; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 5px; background: #0E53E9; color: #fff; font-size: 10.5px; font-weight: 800; }
.rpt h3 { font-size: 12px; font-weight: 800; color: #0A1833; margin: 12px 0 6px; }
.rpt .sm { font-size: 9px; font-weight: 400; color: #6B7588; }
.rpt table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rpt th, .rpt td { padding: 4px 6px; border-bottom: 1px solid #E3E7EE; text-align: left; vertical-align: top; font-size: 10px; white-space: normal; overflow-wrap: anywhere; }
.rpt thead th { background: none; border-bottom: 1.5px solid #0A1833; font-weight: 600; color: #6B7588; }
.rpt .r { text-align: right; }
.rpt .na { color: #6B7588; }
.rpt table.kv { margin-bottom: 8px; }
.rpt table.kv th { width: 22%; color: #6B7588; font-weight: 500; background: none; }
.rpt table.kv td { color: #0A1833; }
.rpt .amt { font-weight: 800; font-size: 11px; color: #0A1833; }
.rpt .pn { font-size: 9px; color: #2B3445; }
.rpt .tag { display: inline-block; font-size: 8px; padding: 0 5px; border-radius: 3px; background: #FFF4E0; color: #B45309; font-weight: 700; }
.rpt tr.win td, .rpt td.win { background: #EEF4FF; }
.rpt td.win .amt, .rpt tr.win td b { color: #0E53E9; }
.rpt tr.inc td { color: #6B7588; }
.rpt .bar { height: 7px; background: #E3E7EE; border-radius: 2px; overflow: hidden; margin-top: 4px; }
.rpt .bar i { display: block; height: 100%; background: #9DB5E8; border-radius: 2px; }
.rpt tr.win .bar i { background: #0E53E9; }
.rpt .cmp-t tbody th { font-weight: 700; color: #0A1833; }
.rpt .cmp-t tr.tot th, .rpt .cmp-t tr.tot td { border-top: 1.5px solid #0A1833; border-bottom: 0; }
.rpt .cmp-t tr.tot .amt { font-size: 12px; font-weight: 800; }
.rpt .prov-detail, .rpt .keep { break-inside: avoid; }
.rpt h2, .rpt h3 { break-after: avoid; }
.rpt td.src { font-size: 8px; color: #6B7588; }
.rpt td.src a { color: #0E53E9; font-weight: 700; text-decoration: none; }
.rpt .notes-l { margin: 0; padding: 0; list-style: none; font-size: 9.5px; color: #4A5468; display: grid; gap: 3px; }
.rpt .notes-l li { position: relative; padding-left: 12px; }
.rpt .notes-l li::before { content: ""; position: absolute; left: 1px; top: .6em; width: 4px; height: 4px; background: #0E53E9; }
.rpt .notes-l.fine { font-size: 8.5px; color: #6B7588; }
.rpt .cmp-t { break-inside: avoid; }
.rpt tr { break-inside: avoid; }
.report-alt { text-align: center; margin-top: 10px; }
.report-alt .link { font-size: 12.5px; color: var(--mute); }
#report-slot { display: flex; gap: 8px; }
.rpt-client { font-size: 11.5px; }
.rpt-client th, .rpt-client td { font-size: 11px; padding: 6px 8px; }
.rpt-client table.kv th { width: 18%; }
.rpt-note { margin-top: 16px; background: #F5F7FA; border-radius: 8px; padding: 10px 14px; font-size: 9.5px; color: #4A5468; line-height: 1.7; }
.rpt-client .rpt-head { padding: 16px 20px 14px; margin-bottom: 10px; }
.rpt-client h2 { margin: 12px 0 6px; }
.rpt-client th, .rpt-client td { padding: 5px 8px; }
.rpt-client .sm { margin-top: 1px; }
.rpt-client .rpt-head { padding: 14px 20px 12px; }
.rpt-client .rpt-logo { margin-bottom: 10px; }
.rpt-client h1 { font-size: 20px; margin: 2px 0 6px; }
.rpt-client .rpt-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.rpt-client h2 { margin: 10px 0 4px; padding: 6px 10px; }
.rpt-client th, .rpt-client td { padding: 4px 8px; }
.rpt-client .rpt-note { margin-top: 10px; padding: 8px 12px; }
.rpt-client table, .rpt-client .rpt-note { break-inside: avoid; }
.tabs { align-items: center; }
.tabs-actions { margin-left: auto; display: flex; gap: 8px; }
.tabs-actions .btn { padding: 8px 14px; font-size: 13.5px; }
@media (max-width: 767px) { .tabs { flex-wrap: wrap; } .tabs-actions { width: 100%; margin-left: 0; } .tabs-actions .btn { flex: 1; } }
.tabs .tabs-actions .btn { background: var(--brand); color: #fff; border-radius: var(--r-md); font-weight: 700; }
.tabs .tabs-actions .btn:hover { background: var(--brand-deep); }
.tabs .tabs-actions .btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.tabs .tabs-actions .btn-secondary:hover { background: var(--head); }
.rpt-client .rpt-meta { max-width: 74%; }
#refresh-slot { display: inline-flex; align-items: center; gap: 8px; }
#refresh-slot .link { font-size: 12px; }
#refresh-slot .link:disabled { color: var(--mute); text-decoration: none; cursor: wait; }
.refresh-msg { font-size: 12px; color: var(--brand); }
.xls-actions { margin-left: auto; display: flex; gap: 6px; }
.xls-actions .btn { padding: 6px 12px; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); }
.xls-actions .btn:hover { border-color: var(--brand); color: var(--brand); }
.xls-actions + .sec-badge { margin-left: 0; }
.xls-msg { margin: -6px 0 14px; padding: 9px 12px; border-radius: var(--r-md); font-size: 13px; background: var(--tint); color: var(--ink); }
.xls-msg.warn { background: var(--amber-bg); color: var(--amber); }
.xls-msg.err { background: #FFE9E9; color: var(--negative); }
@media (max-width: 767px) { .xls-actions { width: 100%; order: 3; } .xls-actions .btn { flex: 1; } }

/* ---------- 저장한 구성 ---------- */
.presets { background: var(--surface); border-bottom: 1px solid var(--line); }
.presets-in { max-width: 1600px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.presets-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.presets-label .mark i:first-child { background: #8CCBFF; }
.presets-label .mark i:last-child { background: var(--brand); }
.preset-chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.preset-chip { border: 1px solid var(--tint-line); background: var(--tint); color: var(--brand); border-radius: var(--pill); padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-chip:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.preset-empty { font-size: 12.5px; }
.presets-in .link { font-size: 13px; white-space: nowrap; }
.presets-in .btn { margin-left: auto; padding: 7px 14px; font-size: 13px; }
.preset-toast { font-size: 12.5px; color: var(--brand); font-weight: 600; }
.dlg { border: 0; border-radius: var(--r-xl); padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(10, 24, 51, .25); }
.dlg-wide { width: min(860px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(10, 24, 51, .45); }
.dlg-body { padding: 20px 22px; display: grid; gap: 12px; }
.dlg h3 { font-size: 17px; font-weight: 800; color: var(--ink); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-hint { margin: 0; font-size: 12.5px; color: var(--mute); }
.dlg input[type=text], .preset-name { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; }
.preset-name { border-color: transparent; font-weight: 700; }
.preset-name:hover { border-color: var(--line); }
.preset-name:focus { border-color: var(--brand); outline: 2px solid var(--tint-line); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.preset-table td { vertical-align: middle; font-size: 13px; }
.preset-table .btn { padding: 6px 12px; font-size: 12.5px; }
.preset-table .nowrap { white-space: nowrap; }
.link.danger { color: var(--negative); }
#preset-list { max-height: 60vh; overflow: auto; }
@media (max-width: 767px) { .presets-in { padding: 10px 16px; } .presets-in .btn { margin-left: 0; } .preset-table th:nth-child(2), .preset-table td:nth-child(2) { display: none; } }

/* ---------- 감당 규모 추정 ---------- */
.cap { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); display: grid; gap: 12px; }
.cap-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cap-head h3 { font-size: 15px; font-weight: 800; color: var(--ink); margin: 0; }
.cap-assume { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; font-size: 13px; }
.cap-page { display: inline-flex; align-items: center; gap: 6px; color: var(--mute); }
.cap-page input { width: 70px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; }
.cap-desc { font-size: 12.5px; }
.cap-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cap-nums > div { background: var(--tint); border-radius: var(--r-md); padding: 10px 12px; display: grid; gap: 2px; }
.cap-nums .k { font-size: 12px; color: var(--mute); }
.cap-nums b { font-size: 17px; font-weight: 800; color: var(--brand); letter-spacing: -.02em; }
.cap-scale { padding: 4px 4px 0; }
.cap-track { position: relative; height: 8px; border-radius: 4px; background: var(--head, #F1F4F9); }
.cap-track i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, #1B87FE, #0E53E9); }
.cap-ticks { position: relative; height: 34px; margin-top: 4px; }
.cap-ticks span { position: absolute; transform: translateX(-50%); display: grid; text-align: center; line-height: 1.25; white-space: nowrap; }
.cap-ticks span::before { content: ''; position: absolute; top: -10px; left: 50%; width: 1px; height: 6px; background: var(--line-strong, #C9D2E0); }
.cap-ticks b { font-size: 11px; color: var(--ink); font-weight: 700; }
.cap-ticks small { font-size: 10.5px; color: var(--mute); }
.cap-limit { margin: 0; font-size: 13px; color: var(--ink); }
.cap-foot { margin: 0; font-size: 12px; }
.cap-basis summary { cursor: pointer; font-size: 12.5px; color: var(--mute); }
.cap-basis ul, .cap-basis-l { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--mute); display: grid; gap: 2px; }
.result-q .cap { margin: 14px 0 10px; padding: 14px; }
.result-q .cap-nums { grid-template-columns: 1fr 1fr; }
.result-q .cap-nums > div:last-child { display: none; }
.result-q .cap-nums b { font-size: 15px; }
.result-q .cap-ticks small { display: none; }
.result-q .cap-ticks { height: 18px; }
@media (max-width: 767px) { .cap-nums { grid-template-columns: 1fr; } .cap-ticks small { display: none; } .cap-ticks { height: 18px; } }
/* 보고서 */
.rpt .cap-report { margin: 0; padding: 10px 12px; gap: 8px; border-color: #E2E8F0; background: #fff; }
.rpt .cap-nums > div { background: #F1F4F9; padding: 7px 10px; }
.rpt .cap-nums b { font-size: 14px; color: #0E53E9; }
.rpt .cap-nums .k, .rpt .cap-limit { font-size: 11px; }
.rpt .cap-limit { color: #0A1833; }
.rpt .cap-basis-l { font-size: 10px; color: #5B6B85; margin-top: 0; }
.rpt .cap-track { background: #F1F4F9; }
.rpt .cap-ticks b { font-size: 9.5px; color: #0A1833; }
.rpt .cap-ticks small { font-size: 9px; color: #5B6B85; }
.rpt h2 small { font-size: 10.5px; font-weight: 600; color: #5B6B85; }
.cap-track em { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--amber, #D97706); }
.cap-dot { display: inline-block; width: 4px; height: 12px; border-radius: 2px; background: var(--amber, #D97706); margin-right: 6px; vertical-align: -1px; }
.cap-traffic { color: var(--mute); font-size: 12.5px; }
.rpt .cap-traffic { color: #5B6B85; font-size: 10.5px; }
.presets-dyn { display: contents; }
.project-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.project-field input { width: 300px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; font-size: 13px; }
.project-field input:focus { border-color: var(--brand); outline: 2px solid var(--tint-line); }
.presets-sep { width: 1px; height: 20px; background: var(--line); }
@media (max-width: 767px) { .project-field { width: 100%; } .project-field input { flex: 1; width: auto; } .presets-sep { display: none; } }
