:root {
  color-scheme: light;
  --page: #f6f6f4;
  --surface: #ffffff;
  --border: #e4e4e0;
  --text: #191919;
  --muted: #666666;
  --accent: #257de0;
  --track: #ececea;
  --series-net: #257de0;
  --series-housing: #f47230;
  --series-goal: #8a8a8a;
  --critical: #c8322f;
  --good: #1b7a2c;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #111111;
    --surface: #191919;
    --border: #2c2c2c;
    --text: #efefef;
    --muted: #9c9c9c;
    --accent: #338ced;
    --track: #2a2a2a;
    --series-net: #338ced;
    --series-housing: #e76624;
    --series-goal: #8a8a8a;
    --critical: #eb6263;
    --good: #0aac23;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
h1, h2, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
h2 { font-size: 1rem; margin-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: .8125rem; font-weight: 400; }
.num, .big, td, dd { font-variant-numeric: tabular-nums; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.top-row { display: flex; align-items: center; justify-content: space-between; max-width: 720px; margin: 0 auto; height: 48px; }
.brand { font-weight: 700; font-size: 1.0625rem; color: var(--text); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.account { display: flex; align-items: center; gap: 4px; font-size: .875rem; }
.account a, .account .link { color: var(--muted); text-decoration: none; padding: 10px 8px; }
.account a[aria-current] { color: var(--text); font-weight: 600; }
.account form { margin: 0; }
button.link { background: none; border: 0; font: inherit; cursor: pointer; }
.tabs { display: flex; max-width: 720px; margin: 0 auto; }
.tabs a {
  flex: 1; text-align: center; padding: 10px 0 9px; min-height: 44px;
  color: var(--muted); text-decoration: none; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--text); }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
main.gate { min-height: 100dvh; align-content: center; max-width: 420px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; min-width: 0; }
.page { font-size: 1.25rem; margin: 6px 2px 2px; }

.month { display: flex; align-items: center; justify-content: space-between; }
.month h1 { font-size: 1.25rem; }
.month a {
  display: grid; place-items: center; width: 44px; height: 44px;
  font-size: 1.5rem; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface);
}
.tag {
  display: inline-block; font-size: .6875rem; font-weight: 600; line-height: 1;
  padding: 4px 7px; border-radius: 999px; vertical-align: 2px;
  background: var(--track); color: var(--muted);
}

.label { color: var(--muted); font-size: .875rem; }
.big { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.hero .muted { margin-top: 10px; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.chips div { background: var(--page); border-radius: 10px; padding: 10px 12px; }
.chips dt { font-size: .75rem; color: var(--muted); }
.chips dd { font-weight: 600; }

.meter { margin-top: 16px; }
.meter:first-of-type { margin-top: 0; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meter-head .name { font-weight: 600; }
.meter-head .num { color: var(--muted); font-size: .875rem; text-align: right; }
.meter-head strong { color: var(--text); font-size: 1rem; }
.bar { display: block; width: 100%; height: 8px; margin-top: 6px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar .fill { fill: var(--accent); }
.meter.over .bar .fill { fill: var(--critical); }
.meter-foot { font-size: .8125rem; color: var(--muted); margin-top: 4px; }
.status { color: var(--critical); font-weight: 600; }
.meter.total { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.meter.total .bar { height: 10px; border-radius: 5px; }

.fund { padding: 14px 0; border-top: 1px solid var(--border); }
.fund:first-of-type { border-top: 0; padding-top: 0; }
.fund-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fund-head .name { font-weight: 600; }
.pairs { display: grid; gap: 4px; margin-top: 8px; font-size: .875rem; }
.pairs div { display: flex; justify-content: space-between; gap: 12px; }
.pairs dt { color: var(--muted); }
.pairs.wide { font-size: 1rem; gap: 10px; margin-top: 0; }
.fund + .muted { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

details summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "펼치기"; color: var(--accent); font-size: .875rem; }
details[open] summary::after { content: "접기"; }
details summary h2 { margin: 0; }
.items { margin-top: 12px; }
.items li { display: grid; grid-template-columns: 3.2em 1fr auto; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); align-items: baseline; }
.items .when { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.items .what .muted { display: block; }
.items .num { font-weight: 600; white-space: nowrap; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tile .big { font-size: 1.75rem; }
.delta { font-size: .875rem; font-weight: 600; margin: 2px 0 6px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .8125rem; color: var(--muted); margin-bottom: 8px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 0; border-top: 3px solid; border-radius: 2px; }
.swatch.net { border-color: var(--series-net); }
.swatch.housing { border-color: var(--series-housing); }
.swatch.goal { border-color: var(--series-goal); border-top-style: dashed; border-top-width: 2px; }
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg [hidden] { display: none; }
.grid { stroke: var(--border); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 11px; }
.end { fill: var(--text); font-size: 11px; font-weight: 600; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.net { stroke: var(--series-net); }
.line.housing { stroke: var(--series-housing); }
.line.goal { stroke: var(--series-goal); stroke-dasharray: 5 4; stroke-width: 1.5; }
.cross { stroke: var(--muted); stroke-width: 1; }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.net { fill: var(--series-net); }
.dot.housing { fill: var(--series-housing); }
.tip {
  position: absolute; top: 0; pointer-events: none; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: .8125rem; box-shadow: 0 4px 16px rgb(0 0 0 / .12);
  font-variant-numeric: tabular-nums;
}
.tip b { display: block; margin-bottom: 2px; }
.tip span { display: flex; align-items: center; gap: 6px; }
.tip i { width: 10px; border-top: 3px solid; border-radius: 2px; }
.tip i.net { border-color: var(--series-net); }
.tip i.housing { border-color: var(--series-housing); }
.tip i.goal { border-color: var(--series-goal); }
.chart + .muted { margin-top: 10px; }

.scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: .8125rem; white-space: nowrap; }
td small { display: block; color: var(--muted); font-size: .75rem; }
th, td { padding: 9px 0 9px 10px; vertical-align: top; text-align: right; border-top: 1px solid var(--border); font-weight: 400; }
th:first-child { text-align: left; padding-left: 0; }
thead th { color: var(--muted); font-size: .75rem; border-top: 0; }

.note .tag { margin-bottom: 8px; }
.note .body { white-space: pre-line; }
.note .muted { margin-top: 8px; }

.device { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.device .name { font-weight: 600; }
.device form { margin: 0; }

.login h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login form { display: grid; gap: 8px; margin-top: 18px; }
.login label { font-size: .875rem; font-weight: 600; }
.login .small { margin-top: 16px; }
input[type=email], input[type=text] {
  font: inherit; color: inherit; width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--page);
}
input.code { font-size: 1.5rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, button.danger {
  font: inherit; font-weight: 600; height: 48px; padding: 0 18px; border-radius: 10px; cursor: pointer;
}
button.primary { margin-top: 8px; border: 0; background: var(--text); color: var(--surface); }
button.danger { height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--critical); white-space: nowrap; }
.alert { margin-top: 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--critical); color: var(--critical); font-size: .875rem; }

@media (min-width: 560px) {
  .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .big { font-size: 2.25rem; }
}

/* 리포트 보관함 */
main.wide { max-width: 1100px; }
.report-search { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.report-search input[type=text] { flex: 1 1 200px; margin: 0; }
.report-search select { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; }
.report-search button { margin: 0; }
a.report-card { display: block; color: inherit; text-decoration: none; }
a.report-card:hover .name { text-decoration: underline; }
.report-card .name { font-weight: 600; }
.report-more { text-align: center; margin: 16px 0; }
.report-head { margin: 0 0 12px; }
.report-head .page { margin-bottom: 4px; overflow-wrap: anywhere; }
.report-actions { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: baseline; margin-top: 8px; }
.report-actions > a, .report-actions > button.link { font-size: 14px; }
.report-history { font-size: 14px; }
.report-history ul { list-style: none; padding: 0; margin: 8px 0 0; }
.report-history li { padding: 4px 0; }
.report-history a[aria-current] { font-weight: 600; }
.report-history form { margin-top: 8px; }
.report-link { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; overflow-wrap: anywhere; font-size: 14px; }
.report-frame { display: block; width: 100%; height: calc(100vh - 150px); min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.report-form label { display: block; margin: 12px 0; }
.report-form input[type=file] { display: block; margin-top: 6px; }
.report-form h2 { margin-top: 18px; }
.report-form code { overflow-wrap: anywhere; }
.consent { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }

/* 사업 손익 */
.notice { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .875rem; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); text-decoration: none; font-size: .875rem; font-weight: 600; }
.pills a[aria-current] { background: var(--text); border-color: var(--text); color: var(--surface); }
.chips.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pos { color: var(--good); }
.neg { color: var(--critical); }
tr.sum th, tr.sum td { font-weight: 600; }
th small { display: block; font-size: .75rem; }
table.fit th:first-child { white-space: normal; min-width: 5.5em; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); align-items: baseline; }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li > span:first-child { min-width: 0; }
.rows small { display: block; font-size: .8125rem; }
.rows .wrap { overflow-wrap: anywhere; }
.rows .num { font-weight: 600; white-space: nowrap; text-align: right; }
.rows .num small { font-weight: 400; }
.more { margin-top: 12px; }
.form { display: grid; gap: 12px; margin-top: 12px; }
.form.filter { margin-top: 0; }
.form label { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; min-width: 0; }
.form .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form .actions { display: flex; align-items: center; gap: 14px; font-size: .875rem; }
input[type=date], input[type=month], select {
  font: inherit; color: inherit; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; height: 48px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--page);
}
input[type=date], input[type=month] { -webkit-appearance: none; appearance: none; }
button.plain { font: inherit; font-weight: 600; height: 40px; padding: 0 18px; border-radius: 10px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
