:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #3457d5;
  --accent-soft: #e9edff;
  --danger: #b42318;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.06);
}
* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, .button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 10px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:hover, .button:hover { filter: brightness(0.98); text-decoration: none; }
button.primary, .primary { background: var(--accent); color: white; border-color: var(--accent); }
button.secondary, .secondary { background: var(--surface); }
button.danger, .danger { color: var(--danger); }
button.small { padding: 7px 10px; font-size: 13px; }
.link-button { background: transparent; border: 0; color: var(--muted); padding: 6px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--surface); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
label { display: grid; gap: 7px; font-size: 14px; font-weight: 600; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.04em; }
h2 { font-size: 18px; margin-bottom: 16px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 14px max(20px, calc((100vw - 1240px)/2)); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.brand { color: var(--text); font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; }
.nav { display: flex; gap: 18px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); font-size: 14px; white-space: nowrap; }
.container { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; font-weight: 800; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; display: block; }
.compact { margin: 7px 0 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-card, .panel, .goal-card, .review-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card { padding: 18px; min-width: 0; overflow: hidden; }
.metric-header, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.metric-header h2 { margin: 8px 0 0; }
.metric-header strong { font-size: 18px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent); padding: 4px 8px; font-size: 11px; font-weight: 700; }
.progress { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.quick-form { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.quick-form input { min-width: 0; }
.quick-form select { max-width: 150px; }
.mini-chart { height: 86px; margin: 14px -8px -8px; }
.chart-large { height: 380px; margin-top: 20px; }
.chart-error { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-column.wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr); }
.panel { padding: 22px; min-width: 0; }
.sticky-panel { position: sticky; top: 84px; align-self: start; }
.list, .goal-list, .review-list { display: grid; gap: 10px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.goal-row { padding: 10px 0; }
.goal-row > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.goal-card, .review-card { padding: 18px; box-shadow: none; }
.review-card h4 { margin: 16px 0 5px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.review-card p { white-space: pre-wrap; margin-bottom: 0; line-height: 1.55; }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filter-row { display: flex; align-items: flex-end; gap: 12px; }
.filter-row label { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.alert { padding: 11px 12px; background: #fee4e2; color: #912018; border-radius: 10px; margin-bottom: 14px; }
.login-shell { min-height: calc(100vh - 72px); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px; box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 10px; }
@media (max-width: 1050px) { .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
  .brand { flex: 1; }
  .nav { order: 3; width: 100%; }
  .container { width: min(100% - 20px, 1240px); padding-top: 24px; }
  .metric-grid, .two-column, .two-column.wide-left { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; }
  .sticky-panel { position: static; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .quick-form, .filter-row { align-items: stretch; flex-direction: column; }
  .quick-form select { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .panel, .metric-card { border-radius: 14px; padding: 16px; }
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --surface: #171d2b; --surface-2: #20283a; --text: #f3f5f8; --muted: #98a2b3; --line: #2b3447; --accent: #8098ff; --accent-soft: #242e57; --shadow: none; }
  .alert { background: #4a1f22; color: #ffb4ac; }
}
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.summary-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 7px; }
.summary-card span, .summary-card small { color: var(--muted); }
.summary-card strong { font-size: clamp(20px, 3vw, 28px); letter-spacing: -0.03em; }
.positive { color: #067647; }
.negative { color: var(--danger); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.chart-grid > .panel:last-child { grid-column: 1 / -1; }
.finance-chart { min-height: 320px; }
.chart-xl { height: 520px; margin-top: 20px; }
.analytics-controls { display: grid; grid-template-columns: minmax(240px, 2fr) 1fr 1fr auto; gap: 12px; align-items: end; }
.month-filter { display: flex; gap: 10px; align-items: end; }
.month-filter label { min-width: 170px; }
.top-gap { margin-top: 20px; }
.budget-list { display: grid; gap: 14px; }
.budget-row > div:first-child { display: flex; justify-content: space-between; gap: 10px; }
.calculator-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.calculator-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface-2); display: grid; gap: 12px; }
.calculator-card h3 { margin: 0; font-size: 16px; }
.calculator-result { display: block; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); line-height: 1.45; }
.finance-entry-layout { align-items: start; }
@media (max-width: 1150px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calculator-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .summary-grid, .chart-grid, .calculator-grid { grid-template-columns: 1fr; }
  .chart-grid > .panel:last-child { grid-column: auto; }
  .analytics-controls { grid-template-columns: 1fr; }
  .month-filter { width: 100%; align-items: stretch; }
  .month-filter label { flex: 1; min-width: 0; }
  .page-heading:has(.month-filter) { flex-direction: column; }
  .finance-chart { min-height: 280px; }
  .chart-xl { height: 420px; }
}
@media (prefers-color-scheme: dark) {
  .positive { color: #75e0a7; }
}
