:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #edf1ec;
  --text: #17201a;
  --muted: #657068;
  --line: #dce2dc;
  --green: #216b4b;
  --green-dark: #154c35;
  --mint: #dbeee4;
  --yellow: #f3ca52;
  --orange: #d97732;
  --red: #b8423e;
  --blue: #2f67a2;
  --shadow: 0 12px 30px rgba(24, 45, 32, .08);
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.45; letter-spacing: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(47,103,162,.25); outline-offset: 2px; }
[hidden] { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #edf2ec 0 50%, #e4ece7 50% 100%); }
.login-panel { width: min(390px, 100%); background: var(--surface); border: 1px solid var(--line); padding: 36px; box-shadow: var(--shadow); border-radius: var(--radius); }
.login-panel h1 { margin: 20px 0 4px; font-size: 2rem; }
.login-panel p { color: var(--muted); margin: 0 0 28px; }
.login-panel label, dialog label { display: grid; gap: 7px; color: #39443d; font-size: .9rem; font-weight: 650; }
input, select { width: 100%; min-height: 46px; border: 1px solid #cdd5cf; border-radius: 6px; background: #fff; color: var(--text); padding: 10px 12px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 6px; font-weight: 800; font-family: Georgia, serif; font-size: 1.5rem; }
.brand-mark.small { width: 34px; height: 34px; font-size: 1.1rem; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { background: #17241d; color: white; padding: 24px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 28px; font-weight: 720; font-size: 1.05rem; }
.sidebar nav { display: grid; gap: 4px; }
.nav-button { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; border-radius: 6px; color: #cad5ce; background: transparent; text-align: left; }
.nav-button:hover, .nav-button.active { color: white; background: #2a3b31; }
.nav-icon { width: 20px; text-align: center; font-size: 1.1rem; }
.sidebar-bottom { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #35453b; color: #9fb0a6; font-size: .78rem; }
.quiet { border: 0; background: none; color: inherit; padding: 5px 0; }
.workspace { min-width: 0; padding: 32px clamp(22px, 4vw, 56px) 64px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.75rem, 2.5vw, 2.25rem); line-height: 1.15; }
.eyebrow { margin: 0; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.primary, .secondary { border: 0; border-radius: 6px; min-height: 44px; padding: 10px 16px; font-weight: 720; }
.primary { background: var(--green); color: white; }
.primary:hover { background: var(--green-dark); }
.add-button { display: inline-flex; align-items: center; gap: 8px; }
.add-button span { font-size: 1.3rem; line-height: 1; }
.secondary { background: var(--surface-2); color: var(--text); }
.wide { width: 100%; margin-top: 16px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.metric { grid-column: span 3; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-height: 135px; }
.metric.safe { background: var(--green); color: white; border-color: var(--green); }
.metric.safe .metric-label, .metric.safe .metric-note { color: #d6eee2; }
.metric.protected { border-top: 4px solid var(--yellow); }
.metric-label { color: var(--muted); font-size: .84rem; font-weight: 700; }
.metric-value { margin-top: 14px; font-size: clamp(1.35rem, 2.3vw, 2rem); font-weight: 780; line-height: 1.1; white-space: nowrap; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: .76rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.panel h2, .page-section h2 { margin: 0; font-size: 1.05rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head button { border: 0; background: none; color: var(--green); font-weight: 700; }
.welcome-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 4px 0; }
.welcome-row h2 { margin: 0; font-size: 1.22rem; }
.welcome-row p { margin: 4px 0 0; color: var(--muted); }
.safe-panel { grid-column: span 8; }
.day-panel { grid-column: span 4; }
.calculation { display: grid; }
.calculation-row { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; padding: 11px 0; border-top: 1px solid var(--line); }
.calculation-row:first-child { border-top: 0; padding-top: 0; }
.calculation-row span { color: var(--muted); }
.calculation-row.total { margin-top: 5px; padding-top: 15px; border-top: 2px solid var(--text); font-size: 1.08rem; }
.calculation-row.total span { color: var(--text); font-weight: 750; }
.protected-note { margin: 14px 0 0; padding: 11px 12px; background: #fff5d8; color: #5f4b14; border-radius: 6px; font-size: .84rem; }
.today-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 18px; }
.today-numbers div { padding: 14px; background: var(--surface-2); border-radius: 6px; }
.today-numbers span { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 5px; }
.today-numbers strong { font-size: 1.05rem; }
.align-right { text-align: right; }
.spending-panel { grid-column: span 7; }
.upcoming-panel { grid-column: span 5; }
.attention-panel, .recent-panel { grid-column: span 6; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2.2fr auto; gap: 12px; align-items: center; margin: 14px 0; font-size: .86rem; }
.bar-track { height: 8px; background: #e7ebe7; border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); }
.money { font-variant-numeric: tabular-nums; font-weight: 720; white-space: nowrap; }
.list { display: grid; }
.list-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; padding-top: 0; }
.list-row:last-child { padding-bottom: 0; }
.item-icon { width: 38px; height: 38px; display: grid; place-items: center; background: var(--surface-2); border-radius: 6px; color: var(--green); font-weight: 800; }
.item-title { font-weight: 700; }
.item-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.attention-row { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.attention-row:first-child { border-top: 0; padding-top: 0; }
.page-section { display: grid; gap: 18px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.segmented { display: flex; gap: 4px; padding: 4px; background: #e9ede9; border-radius: 7px; }
.segmented button { border: 0; border-radius: 5px; padding: 8px 12px; background: transparent; color: var(--muted); font-weight: 700; }
.segmented button.active { background: white; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.table-panel { overflow-x: auto; }
.remove-button, .small-button { border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--green); padding: 6px 9px; font-size: .76rem; font-weight: 750; white-space: nowrap; }
.remove-button:hover, .small-button:hover { background: var(--surface-2); }
.amount-expense { color: var(--red); }
.amount-income { color: var(--green); }
.tag { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 4px; background: var(--surface-2); color: #455047; font-size: .72rem; font-weight: 700; }
.tag.review { background: #fff0d1; color: #875919; }
.two-column { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.education-hero { background: #173d2d; color: white; padding: 26px; border-radius: var(--radius); display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: end; }
.education-hero h2 { font-size: 1.45rem; margin: 4px 0; }
.education-hero p { color: #cfe0d6; margin: 0; }
.progress-track { height: 12px; background: #365b49; margin-top: 20px; }
.progress-fill { height: 100%; background: var(--yellow); }
.education-number { text-align: right; }
.education-number strong { display: block; font-size: 2rem; }
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.account-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: white; }
.account-card.credit { border-left: 4px solid var(--orange); }
.account-card.savings { border-left: 4px solid var(--blue); }
.account-card h3 { margin: 0; font-size: .95rem; }
.account-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.account-balance { margin: 16px 0 6px; font-size: 1.35rem; font-weight: 780; }
.loan-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 15px; padding: 16px 0; border-top: 1px solid var(--line); }
.loan-row:first-child { border-top: 0; }
.loan-meta { color: var(--muted); font-size: .8rem; margin-top: 5px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.settings-form label { display: grid; gap: 6px; font-size: .82rem; font-weight: 700; }
.backup-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.backup-actions a { text-decoration: none; display: inline-flex; align-items: center; }
.form-error { color: var(--red); min-height: 22px; font-size: .82rem; margin-top: 8px; }
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(600px, calc(100% - 28px)); box-shadow: 0 24px 80px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(13, 24, 17, .62); }
dialog form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 20px; }
.dialog-head h2 { margin: 3px 0 0; }
.icon-button { width: 38px; height: 38px; border: 0; background: var(--surface-2); border-radius: 50%; font-size: 1.5rem; line-height: 1; }
.amount-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; margin-bottom: 16px; }
.amount-row input { min-height: 64px; font-size: 2rem; font-weight: 750; }
.entry-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-2); border-radius: 7px; }
.entry-modes button { min-height: 40px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-weight: 750; }
.entry-modes button.active { background: white; color: var(--green-dark); box-shadow: 0 1px 5px rgba(0,0,0,.09); }
.check-row { display: flex; grid-template-columns: none; align-items: center; gap: 9px; margin-top: 14px; }
.check-row input { width: 19px; min-height: 19px; height: 19px; margin: 0; }
.dialog-note { color: var(--muted); font-size: .84rem; margin: 4px 0 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.mobile-nav { display: none; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
@media (max-width: 980px) {
  .metric { grid-column: span 6; }
  .spending-panel, .upcoming-panel, .attention-panel, .recent-panel { grid-column: span 12; }
  .two-column { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .safe-panel, .day-panel { grid-column: span 12; }
  .settings-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { padding: 20px 16px 92px; }
  .topbar { margin-bottom: 20px; }
  .topbar .primary { width: 46px; height: 46px; padding: 0; font-size: 0; border-radius: 50%; }
  .topbar .primary span { font-size: 1.6rem; }
  .welcome-row { align-items: start; }
  .welcome-row .secondary { display: none; }
  .metric { grid-column: span 6; min-height: 120px; padding: 16px; }
  .metric-value { font-size: clamp(1.15rem, 5vw, 1.55rem); white-space: normal; }
  .metric-note { font-size: .72rem; }
  .panel { padding: 17px; }
  .bar-row { grid-template-columns: 90px 1fr auto; gap: 8px; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); background: white; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 24px rgba(0,0,0,.06); }
  .mobile-nav .nav-button { min-height: 64px; justify-content: center; display: grid; gap: 2px; padding: 7px 2px; text-align: center; color: var(--muted); font-size: .68rem; }
  .mobile-nav .nav-button.active { background: var(--mint); color: var(--green-dark); }
  .mobile-nav .nav-icon { margin: auto; }
  .data-table th:nth-child(3), .data-table td:nth-child(3), .data-table th:nth-child(5), .data-table td:nth-child(5) { display: none; }
  .data-table td { padding: 12px 6px; }
  .account-grid { grid-template-columns: 1fr; }
  .education-hero { grid-template-columns: 1fr; }
  .education-number { text-align: left; }
  .settings-form { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar .primary { align-self: flex-end; }
  .segmented { overflow-x: auto; }
}
@media (max-width: 430px) {
  .metric { grid-column: span 12; min-height: 108px; }
  .field-grid { grid-template-columns: 1fr; }
  dialog form { padding: 20px; }
  .list-row { grid-template-columns: 38px minmax(0, 1fr) auto; }
}
