:root {
  --ink: #102a43;
  --ink-2: #243b53;
  --muted: #718096;
  --line: #e3e9ef;
  --surface: #ffffff;
  --canvas: #f4f7f9;
  --brand: #2d8f7b;
  --brand-dark: #1e6a5c;
  --brand-soft: #e9f6f2;
  --positive: #16866d;
  --negative: #c75454;
  --warning: #c48b25;
  --shadow: 0 16px 45px rgba(30, 53, 73, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: "DM Sans", sans-serif; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: white; padding: 28px 18px 20px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; font-family: Manrope, sans-serif; font-size: 22px; font-weight: 800; padding: 0 9px 28px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--brand); font-size: 17px; }
.main-nav { display: grid; gap: 7px; }
.nav-item { border: 0; color: #b9c9d8; background: transparent; display: flex; align-items: center; gap: 13px; border-radius: 12px; padding: 12px 13px; text-align: left; font-weight: 600; transition: .2s ease; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.1); }
.nav-icon { width: 20px; text-align: center; font-size: 18px; }
.sidebar-card { margin-top: auto; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); padding: 15px; border-radius: 15px; }
.sidebar-card-top { display: flex; justify-content: space-between; font-size: 13px; }
.capacity-track { height: 6px; background: rgba(255,255,255,.12); border-radius: 999px; margin: 11px 0; overflow: hidden; }
.capacity-track span { display: block; height: 100%; background: #70d4bb; border-radius: inherit; transition: width .3s ease; }
.sidebar-card p { margin: 0; color: #b9c9d8; font-size: 11px; line-height: 1.45; }
.profile-card { margin-top: 14px; padding: 10px 8px; border: 0; background: transparent; color: white; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; text-align: left; border-radius: 12px; }
.profile-card:hover { background: rgba(255,255,255,.08); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #e6f4ef; color: var(--brand-dark); font-weight: 800; font-size: 12px; }
.profile-copy { display: grid; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: #9eb2c4; font-size: 11px; margin-top: 2px; }

.main-content { min-width: 0; padding: 0 34px 44px; }
.topbar { min-height: 106px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow, .panel-kicker { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 800; color: var(--muted); }
h1, h2 { font-family: Manrope, sans-serif; margin: 0; }
h1 { font-size: clamp(24px, 2.3vw, 32px); letter-spacing: -.04em; }
h2 { font-size: 19px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.demo-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted); }
.demo-pill span { width: 7px; height: 7px; background: var(--brand); border-radius: 50%; box-shadow: 0 0 0 4px var(--brand-soft); }
.button { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 700; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--brand); box-shadow: 0 8px 18px rgba(45,143,123,.2); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { background: white; border: 1px solid var(--line); color: var(--ink-2); }
.button.danger-outline { background: transparent; border: 1px solid #e2b5b5; color: var(--negative); }
.mobile-menu { display: none; border: 0; background: white; width: 40px; height: 40px; border-radius: 10px; }

.view { display: none; }
.view.active { display: block; animation: viewIn .3s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.notice-banner { background: #edf7f4; border: 1px solid #cce8df; color: var(--brand-dark); border-radius: 13px; padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; font-size: 13px; }
.notice-banner strong { margin-right: 8px; }
.notice-banner button { border: 0; background: transparent; font-size: 20px; color: inherit; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.metric-card, .panel { background: var(--surface); border: 1px solid rgba(219,228,235,.9); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card { padding: 18px; }
.metric-card.featured { background: linear-gradient(145deg, #102a43, #1d4664); color: white; border: 0; }
.metric-heading { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; font-weight: 700; }
.featured .metric-heading, .featured p { color: #c7d8e6; }
.metric-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.12); color: white; font-weight: 800; }
.positive-soft { background: #e8f6f1; color: var(--positive); }
.warning-soft { background: #fff4df; color: var(--warning); }
.blue-soft { background: #eaf1f7; color: #3d6d92; }
.metric-card strong { display: block; font-family: Manrope, sans-serif; font-size: 25px; margin: 15px 0 7px; letter-spacing: -.035em; }
.metric-card p { margin: 0; color: var(--muted); font-size: 11px; }
.positive { color: var(--positive); font-weight: 700; }
.negative { color: var(--negative); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .95fr); gap: 16px; margin-top: 16px; }
.lower-grid { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); }
.panel { padding: 20px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.panel-header select, .page-toolbar select { border: 1px solid var(--line); background: white; border-radius: 9px; padding: 8px 10px; color: var(--ink-2); font-size: 12px; }
.text-button { background: none; border: 0; padding: 5px 0; color: var(--brand-dark); font-weight: 700; font-size: 12px; }
.icon-button { border: 1px solid var(--line); background: white; width: 31px; height: 31px; border-radius: 9px; font-size: 18px; color: var(--brand-dark); }
.chart-legend { display: flex; gap: 18px; justify-content: flex-end; font-size: 11px; color: var(--muted); margin-top: 14px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 3px; }
.legend-income { background: var(--brand); }
.legend-spending { background: #d5e0e7; }
.cashflow-chart { height: 220px; margin-top: 5px; display: grid; grid-template-columns: repeat(6, 1fr); align-items: end; gap: 14px; padding: 10px 4px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent 43px, #eff3f6 44px); }
.chart-group { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 4px; height: 100%; position: relative; }
.chart-bar { border-radius: 7px 7px 2px 2px; min-height: 8px; position: relative; transition: height .3s ease; }
.chart-bar.income { background: var(--brand); }
.chart-bar.spending { background: #d5e0e7; }
.chart-label { position: absolute; bottom: -25px; width: 100%; text-align: center; font-size: 10px; color: var(--muted); }
.spending-content { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 20px; min-height: 260px; }
.donut-chart { width: 125px; height: 125px; border-radius: 50%; background: conic-gradient(#193f5f 0 34%, #2d8f7b 34% 49%, #d9a441 49% 61%, #9a6ac9 61% 70%, #d56a6a 70% 100%); display: grid; place-items: center; }
.donut-chart::before { content: ""; width: 80px; height: 80px; border-radius: 50%; background: white; position: absolute; }
.donut-chart div { position: relative; z-index: 1; display: grid; text-align: center; }
.donut-chart strong { font-family: Manrope, sans-serif; font-size: 18px; }
.donut-chart span { color: var(--muted); font-size: 9px; }
.category-list { display: grid; gap: 12px; }
.category-list div { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.category-list span { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.category-list i { width: 8px; height: 8px; border-radius: 3px; background: var(--dot); }
.transaction-list, .account-list { margin-top: 14px; }
.transaction-row { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #edf1f4; }
.transaction-row:last-child { border-bottom: 0; }
.transaction-icon { width: 35px; height: 35px; border-radius: 11px; display: grid; place-items: center; background: #eff4f7; font-weight: 800; color: var(--ink-2); }
.transaction-copy { min-width: 0; display: grid; }
.transaction-copy strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transaction-copy small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.transaction-amount { font-size: 12px; font-weight: 800; }
.account-row { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid #edf1f4; }
.account-logo { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--ink); color: white; font-weight: 800; }
.account-copy { display: grid; }
.account-copy strong { font-size: 12px; }
.account-copy small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.account-balance { text-align: right; }
.account-balance strong { display: block; font-size: 12px; }
.account-balance small { color: var(--muted); font-size: 9px; }
.net-worth-row { display: flex; justify-content: space-between; margin-top: 14px; background: var(--canvas); border-radius: 12px; padding: 12px; font-size: 12px; }

.page-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search-field { flex: 1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: white; border-radius: 11px; padding: 0 12px; }
.search-field input { width: 100%; border: 0; outline: 0; height: 42px; }
.table-panel { padding: 0; overflow: hidden; }
.table-summary { padding: 16px 18px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 13px 18px; border-bottom: 1px solid #edf1f4; font-size: 12px; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; background: #fbfcfd; }
.amount-cell { text-align: right; }
.category-chip { display: inline-block; padding: 6px 9px; border-radius: 999px; background: #eff4f7; color: var(--ink-2); font-size: 10px; }

.budget-hero { background: linear-gradient(135deg, var(--ink), #255475); color: white; border-radius: var(--radius); padding: 28px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow); }
.budget-hero .panel-kicker, .budget-hero p { color: #cbdbe7; }
.budget-hero h2 { font-size: 28px; margin-bottom: 7px; }
.budget-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-top: 16px; }
.budget-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 19px; box-shadow: var(--shadow); }
.budget-card-head { display: flex; justify-content: space-between; align-items: center; }
.budget-card-head span:first-child { font-weight: 700; }
.budget-card p { margin: 14px 0 7px; font-size: 12px; color: var(--muted); }
.progress { height: 8px; background: #edf1f4; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.progress.over span { background: var(--negative); }
.budget-meta { display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 10px; }
.accounts-view-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.account-detail-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.account-detail-top { display: flex; justify-content: space-between; gap: 14px; }
.account-detail-card .account-logo { width: 44px; height: 44px; }
.account-detail-card h3 { margin: 16px 0 2px; }
.account-detail-card p { margin: 0; color: var(--muted); font-size: 11px; }
.account-detail-card .big-balance { display: block; font-family: Manrope, sans-serif; font-size: 28px; margin-top: 22px; }
.account-actions { display: flex; gap: 8px; margin-top: 18px; }
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-panel h2 { margin-bottom: 20px; }
.settings-panel > label { display: grid; gap: 7px; margin: 14px 0; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.settings-panel input, .settings-panel select, .form-grid input, .form-grid select { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: 0; background: white; }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-row p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.switch { position: relative; }
.switch input { display: none; }
.switch span { display: block; width: 42px; height: 24px; border-radius: 999px; background: #cbd5df; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 2px 5px rgba(0,0,0,.16); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8,23,36,.58); z-index: 100; display: none; place-items: center; padding: 20px; backdrop-filter: blur(5px); }
.modal-backdrop.open { display: grid; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: white; border-radius: 22px; padding: 28px; position: relative; box-shadow: 0 28px 80px rgba(0,0,0,.25); animation: modalIn .22s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(9px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; right: 16px; top: 14px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.modal-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 14px; background: var(--brand-soft); color: var(--brand-dark); font-size: 22px; margin-bottom: 17px; }
.modal h2 { font-size: 25px; margin-bottom: 10px; }
.modal-copy { color: var(--muted); font-size: 13px; line-height: 1.55; }
.security-points { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.security-points span { background: #edf7f4; color: var(--brand-dark); border-radius: 999px; padding: 7px 9px; font-size: 10px; font-weight: 700; }
.institution-list { display: grid; gap: 8px; }
.institution { width: 100%; display: grid; grid-template-columns: 39px 1fr auto; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 10px; color: var(--ink); }
.institution:hover { border-color: #9fcfc2; background: #fbfefd; }
.institution span:nth-child(2) { display: grid; }
.institution small { color: var(--muted); margin-top: 2px; font-size: 10px; }
.bank-logo { width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); color: white; border-radius: 11px; font-weight: 800; }
.fine-print { color: var(--muted); font-size: 9px; line-height: 1.5; margin: 15px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.form-grid label { display: grid; gap: 7px; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.form-grid .full { grid-column: 1 / -1; }
.full-button { width: 100%; }
.toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(20px); opacity: 0; pointer-events: none; z-index: 150; background: var(--ink); color: white; border-radius: 12px; padding: 12px 16px; font-size: 12px; box-shadow: var(--shadow); transition: .25s ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .lower-grid { grid-template-columns: 1fr; }
  .budget-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 244px; transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 0 18px 34px; }
  .mobile-menu { display: grid; place-items: center; }
  .topbar { min-height: 96px; }
  .topbar-actions .demo-pill, .topbar-actions .secondary { display: none; }
  .page-toolbar { flex-wrap: wrap; }
  .search-field { min-width: 100%; }
  .settings-layout { grid-template-columns: 1fr; }
}
@media (max-width: 590px) {
  .metric-grid, .budget-grid, .accounts-view-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 22px; }
  .button { padding: 10px 12px; }
  .spending-content { grid-template-columns: 1fr; justify-items: center; }
  .category-list { width: 100%; }
  .cashflow-chart { gap: 7px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .budget-hero { align-items: flex-start; gap: 18px; flex-direction: column; }
}

/* Authentication and loading */
.hidden { display: none !important; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, .9fr) minmax(420px, 1.1fr); background: white; }
.auth-brand-panel { position: relative; overflow: hidden; min-height: 100vh; padding: 38px clamp(28px, 5vw, 72px); color: white; background: linear-gradient(145deg, #0b2235, #163f5d 58%, #237866); display: flex; flex-direction: column; }
.auth-brand-panel::after { content: ""; position: absolute; width: 460px; height: 460px; right: -170px; bottom: -180px; border-radius: 50%; border: 70px solid rgba(255,255,255,.055); box-shadow: 0 0 0 70px rgba(255,255,255,.035); }
.auth-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; font-family: Manrope, sans-serif; font-size: 23px; font-weight: 800; }
.auth-hero-copy { position: relative; z-index: 1; margin: auto 0; max-width: 540px; }
.auth-hero-copy .panel-kicker { color: #80d8c1; }
.auth-hero-copy h1 { font-size: clamp(40px, 5vw, 68px); line-height: 1.02; letter-spacing: -.055em; }
.auth-hero-copy > p:not(.panel-kicker) { max-width: 480px; color: #cfdee8; line-height: 1.65; font-size: 15px; }
.auth-points { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; }
.auth-points span { border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.08); border-radius: 999px; padding: 8px 10px; color: #e8f3f7; font-size: 11px; font-weight: 700; }
.auth-form-panel { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: var(--canvas); }
.auth-card { width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 24px; padding: 30px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 29px; margin-bottom: 7px; }
.auth-description { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; margin-bottom: 27px; border-radius: 13px; background: var(--canvas); }
.auth-tab { border: 0; border-radius: 9px; padding: 10px; background: transparent; color: var(--muted); font-weight: 800; font-size: 12px; }
.auth-tab.active { background: white; color: var(--ink); box-shadow: 0 5px 14px rgba(30,53,73,.08); }
.auth-card form { display: grid; gap: 13px; }
.auth-card form label { display: grid; gap: 7px; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; outline: 0; background: white; }
.auth-card input:focus, .settings-panel input:focus, .form-grid input:focus, .form-grid select:focus { border-color: #75b9a8; box-shadow: 0 0 0 3px rgba(45,143,123,.1); }
.auth-forgot { margin-top: 12px; }
.auth-status { min-height: 20px; margin-top: 12px; border-radius: 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.auth-status.error { padding: 10px; background: #fff0f0; color: var(--negative); }
.auth-status.success { padding: 10px; background: var(--brand-soft); color: var(--brand-dark); }
.loading-screen { position: fixed; inset: 0; z-index: 300; display: grid; place-content: center; justify-items: center; gap: 10px; background: var(--canvas); color: var(--muted); }
.loading-screen.hidden { display: none; }
.loading-mark { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; background: var(--brand); color: white; font-family: Manrope, sans-serif; font-weight: 800; font-size: 22px; box-shadow: 0 12px 30px rgba(45,143,123,.25); }
.empty-state { color: var(--muted); font-size: 12px; padding: 20px 0; text-align: center; }
.button[disabled] { opacity: .58; cursor: wait; transform: none; }

@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: auto; padding: 28px 24px 34px; }
  .auth-hero-copy { margin-top: 52px; }
  .auth-hero-copy h1 { font-size: 40px; }
  .auth-form-panel { min-height: auto; padding: 28px 18px 50px; }
}
