:root {
  color-scheme: dark;
  --bg: #08101e;
  --surface: rgba(19, 31, 51, .78);
  --surface-solid: #121d30;
  --surface-2: #1a2940;
  --line: rgba(160, 190, 225, .15);
  --text: #eef5ff;
  --muted: #96a8bd;
  --blue: #5da9ff;
  --blue-strong: #2688ff;
  --mint: #63dfbd;
  --amber: #ffca68;
  --danger: #ff7c8a;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
  --radius: 24px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eff4fa;
  --surface: rgba(255, 255, 255, .82);
  --surface-solid: #fff;
  --surface-2: #e9f0f8;
  --line: rgba(24, 55, 88, .13);
  --text: #13243a;
  --muted: #61748a;
  --shadow: 0 24px 60px rgba(57, 80, 110, .16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(93, 169, 255, .32); outline-offset: 2px; }

.ambient { position: fixed; z-index: 0; width: 440px; height: 440px; border-radius: 50%; filter: blur(110px); opacity: .16; pointer-events: none; }
.ambient-a { background: #197dff; top: -180px; left: -120px; }
.ambient-b { background: #38d6ae; right: -180px; bottom: -220px; }
.glass { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(24px); }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }

.login-shell { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 430px); padding: 42px; border-radius: 32px; }
.brand-mark { width: 56px; height: 56px; margin-bottom: 28px; }
.login-card h1 { margin: 0 0 12px; font-size: clamp(2.3rem, 9vw, 3.6rem); line-height: 1.05; letter-spacing: -.06em; }
.security-note { margin: 24px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1240px) / 2)); background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-weight: 800; line-height: 1.05; }
.brand img { width: 38px; height: 38px; }
.brand small { display: block; margin-bottom: 4px; color: var(--blue); font-size: .57rem; letter-spacing: .13em; }
.desktop-nav { display: flex; align-items: center; gap: 5px; }
.desktop-nav button { padding: 9px 13px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 750; }
.desktop-nav button.active { background: rgba(93, 169, 255, .12); color: var(--blue); }
.top-actions { display: flex; gap: 8px; }
.icon-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 120px; }
.page { display: none; animation: page-in .24s ease; }
.page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.hero-grid { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 40px; margin-bottom: 34px; }
.hero-grid h1, .page-title h1 { margin: 0; font-size: clamp(2.7rem, 6vw, 5.4rem); line-height: .98; letter-spacing: -.065em; }
.hero-grid h1 span { color: var(--blue); }
.lead { max-width: 600px; margin: 20px 0 0; color: var(--muted); font-size: 1.06rem; }
.month-control { display: flex; align-items: end; gap: 12px; padding: 16px; border-radius: 18px; }

.home-grid { display: grid; grid-template-columns: minmax(360px, .88fr) minmax(430px, 1.12fr); gap: 22px; align-items: start; }
.content-grid { display: grid; grid-template-columns: minmax(330px, .72fr) minmax(450px, 1.28fr); gap: 24px; align-items: start; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface-solid) 78%, transparent); }
.panel.glass { background: var(--surface); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-heading h2, .section-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.035em; }
.status-dot { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px var(--mint); }

.stack { display: grid; gap: 16px; }
label, .field-label { display: grid; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: color-mix(in srgb, var(--surface-solid) 70%, transparent); color: var(--text); }
textarea { min-height: 76px; padding-top: 12px; resize: vertical; }
select option { color: #111827; background: white; }
.form-grid { display: grid; gap: 14px; margin-bottom: 15px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.recommend-panel > label { margin-bottom: 15px; }
.field-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.field-action button { padding: 0 13px; border: 1px solid rgba(93, 169, 255, .35); border-radius: 13px; background: rgba(93, 169, 255, .10); color: var(--blue); font-weight: 800; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 8px 0 20px; }
.check-row label { display: flex; align-items: center; gap: 7px; }
.check-row input { width: 17px; min-height: 17px; accent-color: var(--blue-strong); }
.button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 13px; font-weight: 800; }
.button.primary { background: linear-gradient(135deg, var(--blue-strong), #55b5ff); color: white; box-shadow: 0 12px 28px rgba(38, 136, 255, .25); }
.button.ghost { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.button.danger { color: var(--danger); border: 1px solid rgba(255, 124, 138, .3); background: transparent; }
.button.large { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.form-message { min-height: 18px; margin: 12px 0 0; color: var(--mint); font-size: .82rem; }
.form-message.error, .error { color: var(--danger); }

.result-panel { min-height: 520px; }
.empty-state { min-height: 380px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-orbit { width: 94px; height: 94px; display: grid; place-items: center; margin-bottom: 18px; border: 1px solid rgba(93, 169, 255, .36); border-radius: 50%; color: var(--blue); font-size: 2.3rem; box-shadow: inset 0 0 30px rgba(93, 169, 255, .10), 0 0 40px rgba(93, 169, 255, .08); }
.result-list { display: grid; gap: 12px; }
.result-card { position: relative; padding: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.result-card.recommended { border-color: rgba(99, 223, 189, .5); background: linear-gradient(135deg, rgba(43, 161, 132, .16), var(--surface)); }
.result-card .rank { position: absolute; top: 0; right: 0; padding: 6px 11px; border-radius: 0 0 0 12px; background: var(--mint); color: #08241d; font-size: .7rem; font-weight: 900; }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.result-card h3 { margin: 0; font-size: 1.03rem; }
.benefit-amount { color: var(--mint); font-size: 1.28rem; font-weight: 900; white-space: nowrap; }
.result-card p { margin: 9px 0 0; color: var(--muted); font-size: .83rem; line-height: 1.5; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge, .pill { padding: 5px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 800; }
.badge.good { color: var(--mint); }
.badge.warn { color: var(--amber); }

.section-block { margin-top: 58px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-title { align-items: start; margin-bottom: 36px; }
.page-title h1 { font-size: clamp(2.5rem, 5vw, 4.6rem); }
.page-title .muted { margin: 14px 0 0; }
.card-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-height: 205px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.metric-card::before { content: ""; display: block; width: 34px; height: 4px; margin-bottom: 24px; border-radius: 99px; background: var(--accent, var(--blue)); }
.metric-card:nth-child(2) { --accent: #7f8cff; }
.metric-card:nth-child(3) { --accent: #ffb55e; }
.metric-card:nth-child(4) { --accent: #63dfbd; }
.metric-card:nth-child(5) { --accent: #ef7fd1; }
.metric-card h3 { min-height: 42px; margin: 0 0 16px; font-size: .95rem; }
.metric { margin-top: 11px; }
.metric span { display: block; color: var(--muted); font-size: .72rem; }
.metric strong { display: block; margin-top: 3px; font-size: 1.2rem; }
.progress { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.progress progress { display: block; width: 100%; height: 5px; border: 0; appearance: none; }
.progress progress::-webkit-progress-bar { background: var(--surface-2); }
.progress progress::-webkit-progress-value { background: var(--accent, var(--blue)); }
.progress progress::-moz-progress-bar { background: var(--accent, var(--blue)); }
.retry-link { display: inline-grid; place-items: center; margin-top: 14px; text-decoration: none; }

.sticky-panel { position: static; }
.filter-heading { align-items: center; }
.filter-heading input { width: 160px; }
.transaction-list { display: grid; gap: 10px; }
.transaction-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.transaction-date { color: var(--muted); font-size: .74rem; }
.transaction-main strong { display: block; }
.transaction-main span { color: var(--muted); font-size: .75rem; }
.transaction-money { text-align: right; }
.transaction-money strong, .transaction-money span { display: block; }
.transaction-money span { margin-top: 3px; color: var(--mint); font-size: .72rem; }
.row-actions { display: flex; gap: 6px; }
.edit-button, .delete-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--muted); }
.delete-button { color: var(--danger); }

.wide-form { display: grid; gap: 20px; }
.bucket-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.callout { display: flex; gap: 10px 18px; padding: 16px; border-left: 3px solid var(--blue); border-radius: 8px 14px 14px 8px; background: rgba(93, 169, 255, .08); }
.callout span { color: var(--muted); }
.compact-grid { grid-template-columns: repeat(3, 1fr); margin-top: 24px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.full-width { grid-column: 1 / -1; }
.settings-list { display: grid; gap: 10px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong, .setting-row small { display: block; }
.setting-row small { margin-top: 4px; color: var(--muted); }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-2); transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .2s; }
.switch input:checked + i { background: var(--blue-strong); }
.switch input:checked + i::after { transform: translateX(20px); }
.timeline { display: grid; gap: 12px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.timeline-item { position: relative; padding-left: 18px; color: var(--muted); font-size: .82rem; }
.timeline-item::before { content: ""; position: absolute; left: 0; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }

.bottom-nav { display: none; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 12px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-solid); box-shadow: var(--shadow); color: var(--text); opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { padding: 0; border: 0; border-radius: 22px; background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(5px); }
.dialog-card { max-width: 380px; padding: 26px; }
.dialog-card h2 { margin: 0; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 1020px) {
  .home-grid, .content-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  main { width: min(100% - 24px, 1240px); padding: 36px 0 105px; }
  .topbar { height: 62px; padding: 0 12px; }
  .brand span { display: none; }
  .brand img { width: 36px; }
  .desktop-nav { display: none; }
  .top-actions .icon-button { padding: 0 10px; font-size: .76rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 22px; }
  .hero-grid h1 { font-size: clamp(2.6rem, 14vw, 4.1rem); }
  .month-control { width: 100%; }
  .month-control label { flex: 1; }
  .panel { padding: 20px; border-radius: 20px; }
  .form-grid.two, .form-grid.three, .settings-grid { grid-template-columns: 1fr; }
  .card-grid, .compact-grid { grid-template-columns: 1fr 1fr; }
  .bucket-grid { grid-template-columns: 1fr 1fr; }
  .transaction-item { grid-template-columns: auto 1fr auto; }
  .transaction-money { grid-column: 2; text-align: left; }
  .row-actions { grid-column: 3; grid-row: 1 / span 2; }
  .bottom-nav { position: fixed; z-index: 30; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px; border: 1px solid var(--line); border-radius: 20px; background: color-mix(in srgb, var(--surface-solid) 90%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
  .bottom-nav button { display: grid; place-items: center; gap: 2px; padding: 6px 2px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-size: .65rem; }
  .bottom-nav button span { font-size: 1.08rem; }
  .bottom-nav button.active { background: rgba(93, 169, 255, .13); color: var(--blue); }
  .full-width { grid-column: auto; }
  .callout { display: grid; }
  .login-card { padding: 30px 24px; }
}

@media (max-width: 430px) {
  .card-grid, .compact-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 170px; }
  .bucket-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

