:root {
  /* ===== SubTrack palette — native DARK (finance·trust, neutral + amber warn) ===== */
  --bg: #0f1714;
  --bg-2: #14201c;
  --panel: #16221e;
  --panel-2: #1c2b26;
  --line: #2a3a34;
  --ink: #e8f0eb;
  --ink-soft: #93a8a0;
  --ink-faint: #5e7269;
  --accent: #4fd1a6;
  --accent-deep: #2ea880;
  --accent-soft: rgba(79, 209, 166, 0.16);
  --accent-ink: #06231b;
  --warn: #f0b450;
  --warn-soft: rgba(240, 180, 80, 0.16);
  --danger: #ef6b6b;
  --cat-streaming: #4f8cff;
  --cat-music: #b06bf0;
  --cat-cloud: #4fd1a6;
  --cat-software: #f0b450;
  --cat-news: #ef6b6b;
  --cat-fitness: #ff8a5b;
  --cat-education: #5bd0e0;
  --cat-gaming: #c77dff;
  --cat-productivity: #8fd14f;
  --cat-shopping: #f06b9c;
  --cat-other: #93a8a0;
  --radius: 14px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.28), 0 0 0 1px var(--line);
  --shadow-lift: 0 14px 36px -20px rgba(0,0,0,.6);
  --font-body: "Inter", "Pretendard", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}

/* ===== 3-way theme — Light override (finance paper: warm paper + ink charcoal) ===== */
:root[data-theme="light"] {
  --bg: #f6f5f1;
  --bg-2: #efeee8;
  --panel: #ffffff;
  --panel-2: #f6f5f1;
  --line: #e2ddd3;
  --ink: #1c2622;
  --ink-soft: #5d6b64;
  --ink-faint: #8a958e;
  --accent: #1f8f6b;
  --accent-deep: #166e53;
  --accent-soft: rgba(31, 143, 107, 0.12);
  --accent-ink: #ffffff;
  --warn: #b9791a;
  --warn-soft: rgba(185, 121, 26, 0.14);
  --danger: #d23b3b;
  --cat-streaming: #2563eb;
  --cat-music: #8b3fd0;
  --cat-cloud: #1f8f6b;
  --cat-software: #b9791a;
  --cat-news: #c53030;
  --cat-fitness: #d9663a;
  --cat-education: #2a8e9e;
  --cat-gaming: #9a4ddb;
  --cat-productivity: #5b9a2f;
  --cat-shopping: #c5457e;
  --cat-other: #6b766f;
  --shadow-card: 0 1px 2px rgba(28,38,34,.06), 0 0 0 1px var(--line);
  --shadow-lift: 0 14px 36px -22px rgba(28,38,34,.28);
}

:root[data-theme="light"] body {
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(31,143,107,.06) 0%, transparent 55%),
    radial-gradient(720px 460px at -5% 110%, rgba(185,121,26,.05) 0%, transparent 50%),
    var(--bg);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(79,209,166,.07) 0%, transparent 55%),
    radial-gradient(720px 460px at -5% 110%, rgba(240,180,80,.05) 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
b, h1, h2, h3 { font-weight: 700; }

/* i18n switch + theme switch token bridge */
.i18n-switch {
  --i18n-switch-bg: var(--panel-2);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent-soft);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--panel-2);
  --i18n-switch-menu-border: var(--line);
}
.theme-switch {
  --theme-switch-bg: var(--panel); --theme-switch-border: var(--line); --theme-switch-fg: var(--ink);
  --theme-switch-active-bg: var(--accent); --theme-switch-active-fg: var(--accent-ink); --theme-switch-radius: 10px;
}

.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 50; font-weight: 600; }
.skip-link:focus { left: 12px; }

/* ===== topbar ===== */
.topbar { max-width: 820px; margin: 0 auto; padding: 22px clamp(16px,5vw,32px) 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; font-weight: 800; color: var(--accent-ink);
  background: linear-gradient(150deg, var(--accent), var(--accent-deep)); box-shadow: 0 10px 24px -12px var(--accent); }
.brand h1 { font-size: 21px; letter-spacing: -.01em; }
.brand p { font-size: 12.5px; color: var(--ink-soft); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.privacy-badge { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; font: 600 12.5px var(--font-body); cursor: pointer; transition: border-color .15s, background .15s; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn .icon-label { font-size: 12px; }
.icon-btn.close { padding: 0; width: 34px; justify-content: center; }

/* ===== main layout ===== */
main { max-width: 820px; margin: 0 auto; padding: 6px clamp(16px,5vw,32px) 60px; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-card); }
.stat.hero { grid-column: span 2; background: linear-gradient(150deg, var(--accent-deep), var(--panel)); border-color: var(--accent-deep); }
.stat.hero .stat-num { color: #fff; }
:root[data-theme="light"] .stat.hero .stat-num { color: #fff; }
.stat-num { font-family: var(--font-body); font-weight: 800; font-size: 22px; letter-spacing: -.01em; color: var(--ink); }
.stat.hero .stat-num { font-size: 30px; }
.stat-num.metric { font-variant-numeric: tabular-nums; }
.stat-num.alert { color: var(--warn); }
.stat-label { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }

/* ===== panels ===== */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 700; }
.list-tools { display: flex; align-items: center; gap: 8px; }
.sort-wrap select, .input { font: 500 14px var(--font-body); color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
.sort-wrap select { width: auto; }
.input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ===== buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font: 600 13.5px var(--font-body); cursor: pointer; transition: transform .12s, background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(239,107,107,.4); }
.btn.danger:hover { border-color: var(--danger); background: rgba(239,107,107,.1); }

/* ===== renewal list ===== */
.renewal-list, .sub-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.renewal-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-2); }
.renewal-row .dday { font-family: var(--font-mono); font-weight: 600; font-size: 13px; padding: 5px 9px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); min-width: 64px; text-align: center; }
.renewal-row .dday.soon { background: var(--warn-soft); color: var(--warn); }
.renewal-row .dday.over { background: rgba(239,107,107,.14); color: var(--danger); }
.renewal-row .r-name { font-weight: 600; font-size: 14px; }
.renewal-row .r-meta { font-size: 12px; color: var(--ink-soft); }
.renewal-row .r-amt { margin-left: auto; font-family: var(--font-mono); font-weight: 600; font-size: 14px; }

/* ===== subscription list ===== */
.sub-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.sub-row .cat-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.sub-row .s-main { flex: 1; min-width: 0; }
.sub-row .s-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-row .s-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.sub-row .s-amt { font-family: var(--font-mono); font-weight: 700; font-size: 15px; text-align: right; }
.sub-row .s-next { font-size: 11px; color: var(--ink-faint); text-align: right; margin-top: 2px; }
.sub-row .s-actions { display: flex; gap: 6px; }
.sub-row.inactive { opacity: .5; }
.toggle-active { width: 40px; height: 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); position: relative; cursor: pointer; padding: 0; flex: none; }
.toggle-active::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-faint); transition: transform .15s, background .15s; }
.toggle-active.on { background: var(--accent); border-color: var(--accent); }
.toggle-active.on::after { transform: translateX(18px); background: var(--accent-ink); }

/* ===== category donut ===== */
.cat-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.cat-wrap canvas { width: 160px; height: 160px; flex: none; }
.cat-legend { list-style: none; flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.cat-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cat-legend .lg-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cat-legend .lg-name { flex: 1; }
.cat-legend .lg-val { font-family: var(--font-mono); font-weight: 600; color: var(--ink-soft); }

/* ===== empty ===== */
.empty { text-align: center; padding: 26px 12px; }
.empty-emoji { font-size: 34px; margin-bottom: 8px; }
.empty-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.empty-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }

/* ===== footer ===== */
.foot { text-align: center; padding: 24px 0 0; color: var(--ink-soft); font-size: 12px; }
.foot a { color: var(--accent); text-decoration: none; }
.foot p { margin-top: 8px; }

/* ===== modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,12,10,.62); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 200; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lift); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 16px 18px 18px; }
.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.modal-actions .spacer { flex: 1; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.data-note { font-size: 13px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 14px; }
.data-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.help-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.help-list li { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; padding-left: 18px; position: relative; }
.help-list li::before { content: "•"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }
.help-foot { font-size: 12.5px; color: var(--ink-faint); }

/* ===== toast ===== */
.toast { position: fixed; left: 50%; bottom: 60px; transform: translate(-50%, 16px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font: 600 13px var(--font-body); box-shadow: var(--shadow-lift); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 300; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== responsive ===== */
@media (max-width: 600px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .stat.hero { grid-column: span 2; }
  .privacy-badge { display: none; }
  .field-row { grid-template-columns: 1fr; }
}
