:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e1e0dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e8e7e3;
  --good: #0a7d0a;
  --good-bg: #e3f4e3;
  --warn: #8a5a00;
  --warn-bg: #fdf1d6;
  --bad: #b42f2f;
  --bad-bg: #fbe5e5;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #34342f;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2b2b28;
    --good: #5fd35f;
    --good-bg: #173117;
    --warn: #f0c060;
    --warn-bg: #3a2e12;
    --bad: #f08a8a;
    --bad-bg: #3c1c1c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #34342f; --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #3987e5; --series-1: #3987e5; --series-2: #d95926; --grid: #2b2b28;
  --good: #5fd35f; --good-bg: #173117; --warn: #f0c060; --warn-bg: #3a2e12; --bad: #f08a8a; --bad-bg: #3c1c1c; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 16px; }
.top nav { display: flex; align-items: center; gap: 8px; }
.usage { font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.usage.low { color: var(--bad); border-color: currentColor; }
.iconbtn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-size: 18px; }
.iconbtn:hover { background: var(--surface-2); }

main { max-width: 980px; margin: 0 auto; padding: 16px 16px 80px; }
h1 { font-size: 22px; margin: 4px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.sub { color: var(--text-2); font-size: 14px; }
.center { text-align: center; }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card .hint { font-size: 13px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn .cost { font-weight: 500; font-size: 12px; opacity: 0.8; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.watch { display: block; color: inherit; text-decoration: none; transition: border-color 0.15s; }
.watch:hover { border-color: var(--accent); }
.watch.off { opacity: 0.6; }
.watch .route { font-weight: 700; font-size: 16px; }
.price { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price small { font-size: 14px; font-weight: 600; color: var(--text-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.badge.good { color: var(--good); background: var(--good-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.plain { color: var(--text-2); background: var(--surface-2); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 4px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat .label { font-size: 12.5px; color: var(--text-2); }
.stat .value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.best td { background: color-mix(in srgb, var(--good-bg) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
.diff.down { color: var(--good); font-weight: 700; }
.diff.up { color: var(--bad); }

.bar { position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; min-width: 60px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--series-1); }

form .field { display: grid; gap: 4px; margin-bottom: 12px; align-content: start; }
form label, .label-like { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
input[type=text], input[type=password], input[type=date], input[type=number], select { width: 100%; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.four { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
@media (max-width: 560px) { .two, .three { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13.5px; cursor: pointer; background: var(--surface); }
.chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.help { font-size: 12.5px; color: var(--muted); }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }

.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 4px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--surface-2); color: var(--muted); font-weight: 700; }
.check.done .dot { background: var(--good-bg); color: var(--good); }

.progress { display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 8px 0; }
.progress.error { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; color: var(--accent); flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 그래프 */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .band { fill: var(--surface-2); }
.chart .ref { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref.goal { stroke: var(--good); }
.chart .reflabel { font-size: 11px; fill: var(--text-2); font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.chart .reflabel.goal { fill: var(--good); }
.chart .s1 { stroke: var(--series-1); }
.chart .s2 { stroke: var(--series-2); }
.chart path.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart circle.pt { stroke: var(--surface); stroke-width: 2; }
.chart .f1 { fill: var(--series-1); }
.chart .f2 { fill: var(--series-2); }
.chart .cross { stroke: var(--text-2); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); padding: 8px 10px; font-size: 13px; min-width: 150px; z-index: 3; }
.tip .t { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r b { font-variant-numeric: tabular-nums; }
.tip .k { display: inline-block; width: 14px; height: 0; border-top: 2px solid; margin-right: 6px; vertical-align: middle; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin: 4px 0 6px; }
.legend .k { display: inline-block; width: 16px; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend .k.dash { border-top-style: dashed; border-color: var(--text-2); }
.spark { display: block; width: 100%; height: 36px; }
.spark path { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.spark .base { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }

/* 한 달 달력 */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 8px 0; }
.cal-h { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 58px; padding: 4px 6px; border-radius: 8px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 12px; min-width: 0; }
.cal-cell.blank { background: transparent; }
.cal-cell.past { opacity: 0.35; }
.cal-cell.has { background: color-mix(in srgb, var(--series-1) var(--mix), var(--surface)); border: 1px solid color-mix(in srgb, var(--series-1) 30%, transparent); }
.cal-cell.has:hover { outline: 2px solid var(--accent); }
.cal-cell.min { outline: 2px solid var(--good); }
.cal-cell .d { font-size: 11.5px; color: var(--text-2); }
.cal-cell .p { font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.cal-cell .n { font-size: 10.5px; color: var(--text-2); }
@media (max-width: 480px) { .cal-cell { padding: 3px; min-height: 52px; } .cal-cell .p { font-size: 12px; } }

details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 0; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; margin: 8px 0; }
.empty { text-align: center; padding: 28px 16px; }
.empty .big { font-size: 40px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: 0.2s; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px); pointer-events: none; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.login { max-width: 380px; margin: 40px auto; }
