:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --text: #15201b;
  --muted: #5d6a64;
  --line: #e1e7e4;
  --brand: #0f9d6b;
  --brand-strong: #0a7350;
  --brand-soft: #e2f5ec;
  --on-brand: #ffffff;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --info: #1d5fd6;
  --info-soft: #e8f0fe;
  --accent: #ffd34d;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.06), 0 4px 16px rgba(16, 24, 20, 0.05);
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1311;
    --surface: #161e1a;
    --surface-2: #1b2520;
    --text: #e6eeea;
    --muted: #9aa9a2;
    --line: #27332d;
    --brand: #2fc58f;
    --brand-strong: #5dd8ab;
    --brand-soft: #123628;
    --on-brand: #06231a;
    --danger: #ff7a7a;
    --danger-soft: #3a1717;
    --warn: #f5b04a;
    --warn-soft: #36270f;
    --info: #7aa7ff;
    --info-soft: #14223d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1311; --surface: #161e1a; --surface-2: #1b2520; --text: #e6eeea; --muted: #9aa9a2; --line: #27332d;
  --brand: #2fc58f; --brand-strong: #5dd8ab; --brand-soft: #123628; --on-brand: #06231a;
  --danger: #ff7a7a; --danger-soft: #3a1717; --warn: #f5b04a; --warn-soft: #36270f; --info: #7aa7ff; --info-soft: #14223d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--brand-strong); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 8px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden, [hidden] { display: none !important; }

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand img { border-radius: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
@media (max-width: 420px) { .brand span { display: none; } }

/* 탭: 모바일은 하단, PC는 상단 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabs a span { font-size: 20px; line-height: 1; }
.tabs a.active { color: var(--brand-strong); }
.tabs .badge { position: absolute; top: 6px; left: calc(50% + 8px); }
@media (min-width: 840px) {
  body { padding-bottom: 32px; }
  .tabs {
    position: sticky; top: 57px; bottom: auto; height: auto; padding: 0 16px;
    display: flex; gap: 4px; justify-content: center;
    border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 15;
  }
  .tabs a { flex-direction: row; gap: 6px; padding: 12px 16px; font-size: 14px; border-bottom: 2px solid transparent; }
  .tabs a span { font-size: 16px; }
  .tabs a.active { border-bottom-color: var(--brand); }
  .tabs .badge { position: static; }
}

main { max-width: 960px; margin: 0 auto; padding: 16px; outline: none; overflow-x: clip; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.view-head p { margin: 0; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-small { min-height: 34px; padding: 5px 11px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-strong); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }

.pill {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.pill.ok { color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.pill.err { color: var(--danger); }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; font-style: normal;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.chip.brand { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* 카드 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid-2 { display: grid; gap: 14px; }
.grid-2 > * { min-width: 0; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.kpi.hero { background: linear-gradient(135deg, var(--brand), var(--brand-strong)); color: var(--on-brand); border: 0; }
.kpi.hero .label, .kpi.hero .sub { color: color-mix(in srgb, var(--on-brand) 82%, transparent); }

/* 시작 화면 */
.hero { text-align: center; padding: 28px 16px 8px; }
.hero h1 { font-size: 24px; }
.hero p { color: var(--muted); max-width: 520px; margin: 0 auto 16px; }
.dropzone {
  display: block; border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: var(--radius);
  background: var(--surface); padding: 28px 16px; text-align: center; cursor: pointer; margin-bottom: 14px;
}
.dropzone:hover { background: var(--brand-soft); }
.dropzone .big { font-size: 36px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.steps li::before {
  content: counter(step); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; font-size: 13px;
}

/* 입력 방법 선택 */
.choices { display: grid; gap: 12px; margin: 10px 0 14px; }
@media (min-width: 640px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.05s;
}
.choice:hover { border-color: var(--brand); }
.choice:active { transform: scale(0.99); }
.choice .big { font-size: 30px; line-height: 1; }
.choice-title { font-weight: 800; font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.segmented button {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 6px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 800; cursor: pointer;
}
.segmented button small { font-weight: 600; font-size: 11px; }
.segmented button.active { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow); }
input[type="date"] { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }

/* 목표 */
.goal-track { height: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.goal-track > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-strong)); border-radius: 999px; min-width: 2px; }

/* 막대 그래프 */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 34%) 1fr 76px; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar-row .fill { height: 100%; background: var(--brand); border-radius: 999px; }
.bar-row .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.months { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 8px; }
.months .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.months .stack { width: 100%; max-width: 56px; display: flex; flex-direction: column-reverse; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.months .stack .fixed { background: var(--brand); }
.months .stack .var { background: color-mix(in srgb, var(--brand) 25%, var(--surface-2)); }
.months .lbl { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* 점검 결과 */
.section-title { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; font-size: 16px; }
.section-title .count { color: var(--muted); font-weight: 600; font-size: 14px; }
.finding {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 14px 18px; margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.finding::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line); }
.finding.high::before { background: var(--danger); }
.finding.medium::before { background: var(--warn); }
.finding.low::before { background: var(--brand); }
.finding.is-hidden { opacity: 0.65; }
.finding-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.finding h3 { font-size: 15px; margin: 0 0 4px; }
.finding p { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.saving { text-align: right; white-space: nowrap; font-weight: 800; color: var(--brand-strong); font-variant-numeric: tabular-nums; }
.saving small { display: block; font-weight: 600; font-size: 11px; color: var(--muted); }
.members { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.member { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; background: var(--surface-2); }
.guide { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.guide ol { margin: 4px 0 0; padding-left: 18px; }

/* 목록 */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; }
.row .icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 18px; flex: none; }
.row .main { flex: 1; min-width: 0; display: block; }
.row .title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row .right { text-align: right; flex: none; }
.row .amount { font-weight: 800; font-variant-numeric: tabular-nums; }
.row.clickable { cursor: pointer; }
.detail { padding: 0 2px 14px 48px; }
.detail table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail td { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.detail td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.strike .title, .strike .amount { text-decoration: line-through; color: var(--muted); }

/* 폼 */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
select.inline { width: auto; min-height: 30px; padding: 2px 8px; font-size: 12px; border-radius: 8px; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
@media (min-width: 640px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* 배너, 토스트, 모달 */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  max-width: 960px; margin: 12px auto 0; padding: 12px 14px; border-radius: 14px;
  background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 30%, var(--line));
  width: calc(100% - 32px);
}
.banner.notice { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(20px);
  background: #1d2723; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50; width: max-content; max-width: calc(100% - 32px);
  display: flex; gap: 12px; align-items: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast button { white-space: nowrap; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 800; cursor: pointer; }
@media (min-width: 840px) { #toast { bottom: 24px; } }
dialog {
  border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 48px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(10, 16, 13, 0.5); }
.modal-body { padding: 20px; overflow: auto; max-height: calc(100vh - 140px); }
.modal-foot { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.preview { overflow: auto; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; max-height: 220px; }
.preview table { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.preview td, .preview th { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.preview th { background: var(--surface-2); position: sticky; top: 0; }
#drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 22%, transparent); backdrop-filter: blur(2px);
}
#drop-overlay > div { background: var(--surface); padding: 22px 28px; border-radius: 18px; font-weight: 800; border: 2px dashed var(--brand); }
.ad-slot { margin: 14px 0; text-align: center; }
.partner { display: inline-flex; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big { font-size: 40px; }
details.faq { border-top: 1px solid var(--line); padding: 10px 0; }
details.faq summary { cursor: pointer; font-weight: 700; }
details.faq div { color: var(--muted); font-size: 14px; padding-top: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
@media print {
  .topbar, .tabs, #toast, .btn, .banner { display: none !important; }
  body { padding: 0; background: #fff; }
}
