:root {
  color-scheme: light;
  --page: #edf2f3;
  --surface: #ffffff;
  --surface-soft: #f5f8f8;
  --ink: #1a3039;
  --ink-strong: #132831;
  --muted: #62757c;
  --muted-soft: #86969b;
  --line: #dfe7e8;
  --line-strong: #d3dfe0;
  --teal: #286d63;
  --teal-bright: #60ad9c;
  --teal-soft: #e5f2ee;
  --navy: #163942;
  --navy-deep: #102d35;
  --navy-muted: #aac3c3;
  --gold: #ecd68e;
  --gold-soft: #fbf5df;
  --orange: #ae633f;
  --orange-soft: #fff0e4;
  --red: #a94c4e;
  --red-soft: #fbeaea;
  --shadow: 0 12px 32px rgba(29, 59, 68, .055);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111e25;
  --surface: #1a2a32;
  --surface-soft: #20343c;
  --ink: #e1e9e9;
  --ink-strong: #f1f6f5;
  --muted: #a2b1b4;
  --muted-soft: #7d9095;
  --line: #30434a;
  --line-strong: #40565e;
  --teal: #74b6a6;
  --teal-bright: #87c7b6;
  --teal-soft: #243f3e;
  --navy: #102d35;
  --navy-deep: #0e252d;
  --navy-muted: #b5ccca;
  --gold: #ecd68e;
  --gold-soft: #453f2c;
  --orange: #efa477;
  --orange-soft: #493429;
  --red: #ef8c8d;
  --red-soft: #4b2e33;
  --shadow: 0 12px 32px rgba(0, 0, 0, .14);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--page); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { touch-action: manipulation; }
a { color: inherit; }
svg { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[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; }
:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 3px; }

.skip-link { position: fixed; z-index: 200; top: 12px; left: 12px; padding: 10px 14px; border-radius: 8px; transform: translateY(-160%); background: var(--ink-strong); color: white; }
.skip-link:focus { transform: translateY(0); }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 232px; flex-direction: column; padding: 27px 18px 18px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 10px; width: fit-content; text-decoration: none; color: var(--ink-strong); font-size: 24px; font-weight: 720; letter-spacing: -.075em; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px 11px 11px 4px; background: var(--teal); color: white; font-family: Georgia, serif; font-size: 25px; font-weight: 500; line-height: 1; }
.brand--large { font-size: 30px; }
.brand--large .brand-mark { width: 42px; height: 42px; font-size: 30px; }
.nav-caption { margin: 48px 10px 13px; color: var(--muted-soft); font-size: 12px; font-weight: 650; }
.primary-nav { display: grid; gap: 6px; }
.nav-add { display: none; }
.nav-item { display: flex; min-height: 48px; align-items: center; gap: 13px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; transition: background-color .16s ease, color .16s ease; }
.nav-item:hover { background: var(--surface-soft); color: var(--ink); }
.nav-item.is-active { background: var(--teal-soft); color: var(--teal); font-weight: 650; }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.sidebar-bottom { display: grid; gap: 16px; margin-top: auto; padding: 15px 9px 5px; }
.privacy-note { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.privacy-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--teal-bright); box-shadow: 0 0 0 4px var(--teal-soft); }
.text-button { width: fit-content; border: 0; padding: 6px 0; background: none; color: var(--muted); text-align: left; cursor: pointer; }
.text-button:hover { color: var(--ink-strong); }
.workspace { min-height: 100vh; margin-left: 232px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; min-height: 92px; align-items: center; justify-content: space-between; gap: 16px; padding: 18px clamp(24px, 4vw, 56px); border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent); background: color-mix(in srgb, var(--page) 92%, transparent); backdrop-filter: blur(14px); }
.topbar-title h1 { margin: 3px 0 0; color: var(--ink-strong); font-size: 23px; font-weight: 670; letter-spacing: -.035em; }
.topbar-title { min-width: 0; flex: 1; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--ink-strong); border-color: var(--line-strong); }
.icon-button svg { width: 19px; height: 19px; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 630; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, transform .16s ease; }
.button:active { transform: scale(.985); }
.button--primary { background: var(--teal); color: #fff; }
.button--primary:hover { background: #205d55; }
:root[data-theme="dark"] .button--primary:hover { background: #90cdbd; color: #102d35; }
:root[data-theme="dark"] .button--primary { background: #2b6c62; color: #f1f6f5; }
.button--secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button--secondary:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.button--danger { border-color: transparent; background: var(--red-soft); color: var(--red); }
.button--small { min-height: 35px; padding: 0 11px; border-radius: 9px; font-size: 13px; }
.button--full { width: 100%; }
.plus-mark { display: grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 18px; font-weight: 400; line-height: 1; }
.main-content { width: min(100%, 1440px); margin: 0 auto; padding: 30px clamp(24px, 4vw, 56px) 64px; }
.loading-state { display: flex; min-height: 42vh; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 3px 0 23px; }
.view-heading h2 { margin: 0; color: var(--ink-strong); font-size: clamp(23px, 2.4vw, 31px); font-weight: 650; letter-spacing: -.045em; }
.view-heading p { max-width: 560px; margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 14px; }
.section-title-row h2, .section-title-row h3 { margin: 0; color: var(--ink-strong); font-size: 17px; font-weight: 650; letter-spacing: -.025em; }
.section-title-row p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.text-link { border: 0; padding: 7px 0; background: none; color: var(--teal); font-size: 13px; font-weight: 650; text-decoration: none; cursor: pointer; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.dashboard-intro { margin-bottom: 18px; color: var(--muted); font-size: 13px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .85fr); align-items: start; gap: 20px; }
.dashboard-main, .dashboard-side { display: grid; gap: 20px; min-width: 0; }
.available-card { position: relative; overflow: hidden; min-height: 292px; padding: 28px 30px 24px; border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius-lg); background: var(--navy); color: #f4f8f7; box-shadow: var(--shadow); }
.available-card::after { position: absolute; right: -51px; bottom: -129px; width: 272px; height: 272px; border: 1px solid rgba(134,199,184,.22); border-radius: 50%; content: ""; box-shadow: 0 0 0 31px rgba(134,199,184,.045), 0 0 0 64px rgba(134,199,184,.035); pointer-events: none; }
.available-card-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--navy-muted); font-size: 13px; }
.available-card-top > span:first-child { display: inline-flex; align-items: center; gap: 9px; }
.available-card-top svg { width: 18px; height: 18px; color: var(--teal-bright); }
.status-pill { display: inline-flex; min-height: 26px; align-items: center; gap: 6px; padding: 0 9px; border-radius: 99px; background: rgba(116, 196, 172, .16); color: #b6e1d4; font-size: 11px; font-weight: 600; }
.status-pill--watch { background: rgba(237, 199, 111, .15); color: #f0d590; }
.status-pill--risk { background: rgba(239, 140, 141, .15); color: #f3aeae; }
.available-amount { position: relative; z-index: 1; margin: 28px 0 1px; font-size: clamp(40px, 5vw, 58px); font-weight: 600; letter-spacing: -.065em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.available-amount.is-negative { color: #f4b3a5; }
.available-caption { position: relative; z-index: 1; margin: 9px 0 22px; color: var(--navy-muted); font-size: 14px; }
.available-separator { position: relative; z-index: 1; height: 1px; background: rgba(212,236,230,.14); }
.available-footer { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 17px; }
.daily-guidance { display: grid; gap: 4px; color: var(--navy-muted); font-size: 12px; }
.daily-guidance strong { color: #eef8f3; font-size: 16px; font-weight: 640; }
.explain-button { min-height: 36px; border: 1px solid rgba(210,235,229,.25); border-radius: 9px; padding: 0 11px; background: transparent; color: #e2f0eb; font-size: 12px; cursor: pointer; }
.explain-button:hover { background: rgba(255,255,255,.08); }
.calculation-details { position: relative; z-index: 2; margin-top: 12px; padding: 12px 13px; border: 1px solid rgba(210,235,229,.17); border-radius: 10px; background: var(--navy-deep); color: #d9e8e5; font-size: 12px; }
.calculation-details p { margin: 0 0 9px; color: var(--navy-muted); }
.calculation-line { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.calculation-line strong { color: #f2f7f5; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calculation-line--total { margin-top: 4px; border-top: 1px solid rgba(210,235,229,.14); font-weight: 700; }
.calculation-details--open { margin: 0 0 16px; font-size: 14px; }
.calculation-details--open p { margin: 8px 0 0; font-size: 12px; }
.calculation-details--open .calculation-line--total strong { font-size: 16px; }
.metrics-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.metric-card, .base-card, .panel, .setting-panel { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 4px 16px rgba(29,59,68,.025); }
.metric-card { min-height: 120px; padding: 17px 19px; }
.metric-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.metric-icon { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: var(--surface-soft); color: var(--teal); }
.metric-icon svg { width: 15px; height: 15px; }
.metric-value { margin-top: 13px; color: var(--ink-strong); font-size: 24px; font-weight: 640; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-note { margin-top: 3px; color: var(--muted-soft); font-size: 11px; }
.panel { padding: 20px; }
.category-list { display: grid; gap: 4px; }
.category-row { display: grid; grid-template-columns: minmax(100px, .85fr) minmax(120px, 1.5fr) minmax(90px, .7fr); align-items: center; gap: 14px; min-height: 59px; border-bottom: 1px solid var(--line); }
.category-row:last-child { border-bottom: 0; }
.category-name { display: flex; min-width: 0; align-items: center; gap: 9px; color: var(--ink); font-size: 13px; font-weight: 560; }
.category-swatch { width: 9px; height: 9px; flex: none; border-radius: 3px; background: var(--cat-color, var(--teal)); }
.category-bar-wrap { display: grid; gap: 7px; }
.category-bar { overflow: hidden; height: 6px; border-radius: 99px; background: var(--surface-soft); }
.category-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--cat-color, var(--teal)); }
.category-bar-label { display: flex; justify-content: space-between; gap: 8px; color: var(--muted-soft); font-size: 11px; }
.category-remaining { color: var(--ink-strong); text-align: right; font-size: 13px; font-weight: 640; font-variant-numeric: tabular-nums; }
.category-remaining small { display: block; margin-top: 3px; color: var(--muted-soft); font-size: 10px; font-weight: 450; }
.bill-list, .transaction-list, .recurrence-list, .manage-category-list { display: grid; }
.bill-row, .transaction-row, .recurrence-row, .manage-category-row { display: flex; min-width: 0; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.bill-row:last-child, .transaction-row:last-child, .recurrence-row:last-child, .manage-category-row:last-child { border-bottom: 0; }
.row-icon { display: grid; width: 36px; height: 36px; flex: none; place-items: center; border-radius: 11px; background: var(--surface-soft); color: var(--teal); }
.row-icon svg { width: 17px; height: 17px; }
.row-copy { min-width: 0; flex: 1; }
.row-title { overflow: hidden; color: var(--ink-strong); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { margin-top: 4px; color: var(--muted); font-size: 11px; }
.row-amount { flex: none; color: var(--ink-strong); font-size: 13px; font-weight: 640; text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex: none; align-items: center; gap: 4px; }
.compact-icon { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.compact-icon:hover { background: var(--surface-soft); color: var(--ink-strong); }
.compact-icon svg { width: 16px; height: 16px; }
.outline-action { min-height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 9px; background: var(--surface); color: var(--teal); font-size: 11px; font-weight: 620; cursor: pointer; }
.outline-action:hover { background: var(--teal-soft); }
.callout { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 13px; line-height: 1.45; }
.callout strong { color: var(--ink-strong); }
.callout--warning { border-color: color-mix(in srgb, var(--orange) 23%, var(--line)); background: var(--orange-soft); color: var(--ink); }
.callout--danger { border-color: color-mix(in srgb, var(--red) 20%, var(--line)); background: var(--red-soft); color: var(--ink); }
.callout-icon { width: 18px; height: 18px; flex: none; color: var(--orange); }
.dashboard-callout { margin-bottom: 20px; }
.next-income-card { padding: 21px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.next-income-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.next-income-top p { margin: 0; color: var(--muted); font-size: 12px; }
.next-income-amount { margin-top: 15px; color: var(--ink-strong); font-size: 27px; font-weight: 640; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.next-income-name { margin-top: 3px; color: var(--muted); font-size: 12px; }
.income-date { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.income-date strong { color: var(--ink); font-weight: 620; }
.income-source-list { display: grid; gap: 8px; margin-top: 12px; }
.income-source-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.income-source-copy { display: grid; min-width: 0; gap: 2px; }
.income-source-copy strong { overflow: hidden; color: var(--ink-strong); font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.income-source-copy span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.income-presets { display: grid; gap: 7px; }
.income-presets > span { color: var(--muted); font-size: 11px; }
.income-presets > div { display: flex; flex-wrap: wrap; gap: 7px; }
.preset-button { min-height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface-soft); color: var(--teal); font-size: 11px; font-weight: 620; cursor: pointer; }
.preset-button:hover { border-color: var(--teal); background: var(--teal-soft); }
.income-presets p { margin: 0; color: var(--muted-soft); font-size: 10px; line-height: 1.4; }
.empty-state { display: grid; justify-items: start; gap: 8px; padding: 18px 0 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty-state strong { color: var(--ink); }
.empty-mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); color: var(--teal); }
.empty-mark svg { width: 18px; height: 18px; }
.empty-inline { padding: 22px 12px; border: 1px dashed var(--line-strong); border-radius: 11px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.5; }

.page-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); align-items: start; gap: 18px; }
.page-stack { display: grid; gap: 18px; }
.filter-bar { display: flex; align-items: center; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.filter-bar input, .filter-bar select { min-height: 40px; }
.filter-bar .search-control { flex: 1; }
.form-control { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 11px; background: var(--surface); color: var(--ink-strong); }
.form-control::placeholder { color: var(--muted-soft); }
.form-control:focus { border-color: var(--teal); outline: 2px solid color-mix(in srgb, var(--teal) 20%, transparent); }
.select-control { padding-right: 30px; }
.transaction-row { min-height: 64px; }
.transaction-row .row-icon.expense-icon { background: var(--orange-soft); color: var(--orange); }
.transaction-row .row-icon.income-icon { background: var(--teal-soft); color: var(--teal); }
.transaction-row .row-icon.bill-icon { background: var(--surface-soft); color: var(--muted); }
.transaction-total { display: flex; justify-content: space-between; gap: 15px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.transaction-total strong { color: var(--ink-strong); font-size: 14px; }
.chart-list { display: grid; gap: 14px; padding-top: 5px; }
.chart-item { display: grid; gap: 6px; }
.chart-item-head { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); font-size: 12px; }
.chart-item-head strong { font-weight: 620; font-variant-numeric: tabular-nums; }
.chart-track { height: 7px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.chart-track span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: var(--chart-color, var(--teal)); }
.manager-section + .manager-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.manager-actions { display: flex; align-items: center; gap: 7px; }
.recurrence-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.recurrence-row.is-inactive { opacity: .58; }
.manage-category-row .row-copy { display: flex; align-items: center; gap: 8px; }
.manage-category-row .category-name { flex: 1; }
.manage-category-row .row-amount { min-width: 84px; }
.reserved-badge { color: var(--teal); font-size: 10px; font-weight: 620; }
.settings-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
.setting-panel { padding: 21px; }
.setting-panel--wide { grid-column: 1 / -1; }
.settings-form { display: grid; gap: 15px; margin-top: 20px; }
.admin-signup { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 6px; color: var(--muted); font-size: 13px; }
.admin-signup strong { color: var(--ink-strong); }
.admin-account-row { flex-wrap: wrap; }
.admin-account-row .row-copy { min-width: 10rem; }
.admin-account-row .row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
/* Pastilles sur fond clair : la .status-pill est faite pour la carte sombre de la Vue d'ensemble. */
.account-badge { display: inline-flex; min-height: 22px; align-items: center; padding: 0 8px; border-radius: 99px; background: var(--teal-soft); color: var(--teal); font-size: 11px; font-weight: 650; }
.admin-screen { min-height: 100dvh; padding: 24px 16px 48px; background: var(--page); }
.admin-shell { display: grid; gap: 16px; width: min(100%, 760px); margin: 0 auto; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-shell h1 { margin: 12px 0 0; color: var(--ink-strong); font-size: 28px; letter-spacing: -.045em; }
.admin-intro { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.viewing-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--teal-soft); color: var(--ink-strong); font-size: 14px; }
/* Lecture seule : le serveur refuse déjà toute modification, on retire aussi les boutons qui en proposent. */
.is-readonly [data-action^="add-"], .is-readonly [data-action="settle"], .is-readonly [data-action="postpone"],
.is-readonly [data-action="occurrence-status"], .is-readonly [data-action="undo-occurrence"], .is-readonly [data-action="income-preset"],
.is-readonly [data-action="archive-category"], .is-readonly [data-action="restore-category"], .is-readonly [data-action="toggle-recurrence"],
.is-readonly [data-edit-expense], .is-readonly [data-edit-category], .is-readonly [data-edit-recurrence],
.is-readonly .settings-form button[type="submit"] { display: none !important; }
.data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.settings-form--separated { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.field { display: grid; min-width: 0; gap: 7px; }
.field label { color: var(--ink); font-size: 12px; font-weight: 620; }
.field-hint { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.field-error { min-height: 16px; margin: 0; color: var(--red); font-size: 12px; }
.check-field { display: flex; align-items: flex-start; gap: 9px; color: var(--ink); font-size: 12px; line-height: 1.45; }
.check-field input { width: 18px; height: 18px; margin: 0; accent-color: var(--teal); }
.settings-note { display: flex; align-items: flex-start; gap: 11px; padding: 14px; border-radius: 11px; background: var(--surface-soft); color: var(--muted); font-size: 12px; line-height: 1.5; }
.settings-note svg { width: 17px; height: 17px; flex: none; color: var(--teal); }
.footer-caption { margin-top: 20px; color: var(--muted-soft); font-size: 11px; line-height: 1.5; }

.auth-screen { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: radial-gradient(ellipse at 76% 17%, rgba(89,163,144,.12), transparent 32%), var(--page); }
.auth-card { width: min(100%, 420px); padding: 35px; border: 1px solid var(--line); border-radius: 21px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card h1 { margin: 37px 0 9px; color: var(--ink-strong); font-size: 28px; letter-spacing: -.045em; }
.auth-card > p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.stack-form { display: grid; gap: 10px; margin-top: 28px; }
.stack-form label { font-size: 13px; font-weight: 620; }
.stack-form .field-hint { margin-top: -4px; }
.auth-switch { margin: 6px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.link-button { padding: 0; border: 0; background: none; color: var(--teal); font: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.stack-form input { min-height: 46px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 10px 12px; background: var(--surface); color: var(--ink); }
.app-dialog { width: min(calc(100% - 28px), 530px); max-height: min(88dvh, 750px); overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 28px 80px rgba(12,29,36,.2); }
.app-dialog::backdrop { background: rgba(16, 35, 41, .48); backdrop-filter: blur(3px); }
.dialog-inner { padding: 24px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-header h2 { margin: 0; color: var(--ink-strong); font-size: 21px; letter-spacing: -.035em; }
.dialog-header p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.dialog-form { display: grid; gap: 14px; }
.expense-entry-form #form-amount { min-height: 60px; font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 9px; padding-top: 15px; border-top: 1px solid var(--line); }
.optional-details { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.optional-details summary { display: flex; min-height: 46px; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--ink); font-size: 13px; font-weight: 560; cursor: pointer; list-style: none; }
.optional-details summary::-webkit-details-marker { display: none; }
.optional-details summary::after { color: var(--teal); content: "+"; font-size: 18px; line-height: 1; }
.optional-details[open] summary::after { content: "−"; }
.optional-details summary span:last-of-type { overflow: hidden; margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 450; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.optional-details .field { padding: 0 12px 12px; }
.dialog-close { display: grid; width: 38px; height: 38px; flex: none; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.dialog-close:hover { background: var(--surface-soft); }
.dialog-close svg { width: 18px; height: 18px; }
.dialog-tip { padding: 11px 12px; border-radius: 9px; background: var(--surface-soft); color: var(--muted); font-size: 11px; line-height: 1.45; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; width: min(calc(100% - 32px), 390px); }
.toast { padding: 13px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); box-shadow: 0 12px 32px rgba(12,29,36,.15); font-size: 13px; animation: toast-in .2s ease-out both; }
.toast.is-error { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); background: var(--red-soft); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1120px) {
  .sidebar { width: 205px; }
  .workspace { margin-left: 205px; }
  .main-content { padding-right: 28px; padding-left: 28px; }
  .topbar { padding-right: 28px; padding-left: 28px; }
  .dashboard-grid { grid-template-columns: minmax(0,1.35fr) minmax(245px,.85fr); gap: 15px; }
  .dashboard-main, .dashboard-side { gap: 15px; }
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: minmax(0,1fr); }
  .dashboard-side { grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
  .dashboard-side .panel { min-height: 100%; }
  .page-grid { grid-template-columns: minmax(0,1fr); }
  .settings-grid { grid-template-columns: minmax(0,1fr); }
  .setting-panel--wide { grid-column: auto; }
}
@media (max-width: 650px) {
  .admin-actions { width: 100%; margin-left: 0; }
  .sidebar { position: fixed; inset: auto 0 0; width: auto; height: auto; min-height: 67px; padding: 5px 9px calc(5px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-right: 0; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(14px); }
  .sidebar > .brand, .sidebar > .nav-caption, .sidebar-bottom { display: none; }
  .primary-nav { display: grid; width: 100%; grid-template-columns: repeat(5,minmax(0,1fr)); align-items: center; gap: 3px; }
  .nav-item { min-height: 54px; flex-direction: column; justify-content: center; gap: 3px; padding: 3px 2px; border-radius: 10px; font-size: 10px; }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-add { display: grid; min-width: 0; min-height: 54px; justify-items: center; align-content: center; gap: 1px; border: 0; border-radius: 10px; padding: 2px; background: transparent; color: var(--teal); font-size: 9px; font-weight: 650; cursor: pointer; touch-action: manipulation; }
  .nav-add-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: var(--teal); color: #fff; box-shadow: 0 4px 10px color-mix(in srgb, var(--teal) 24%, transparent); font-size: 25px; font-weight: 400; line-height: 1; }
  :root[data-theme="dark"] .nav-add-icon { color: #102d35; }
  .workspace { margin-left: 0; padding-bottom: calc(77px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 75px; padding: 11px 16px; }
  .topbar-title h1 { font-size: 17px; white-space: nowrap; }
  .eyebrow { font-size: 11px; }
  .topbar-actions { gap: 7px; }
  .topbar-actions .icon-button { width: 39px; height: 39px; }
  .add-expense-top { display: none; }
  .main-content { padding: 22px 16px 34px; }
  .view-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 19px; }
  .view-heading h2 { font-size: 25px; }
  .view-heading p { font-size: 13px; }
  .dashboard-intro { margin-top: -6px; }
  .available-card { min-height: 276px; padding: 22px 20px 19px; border-radius: 17px; }
  .available-amount { margin-top: 29px; font-size: clamp(38px, 11vw, 49px); }
  .available-caption { margin-bottom: 18px; font-size: 12px; }
  .available-card-top { align-items: flex-start; font-size: 11px; }
  .status-pill { min-height: 24px; font-size: 10px; }
  .available-footer { align-items: flex-start; }
  .explain-button { padding: 0 8px; font-size: 11px; }
  .metrics-row { gap: 9px; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metrics-row > .metric-card:last-child { grid-column: 1 / -1; }
  .metric-card { min-height: 108px; padding: 13px; }
  .metric-label { align-items: flex-start; font-size: 10px; line-height: 1.35; }
  .metric-icon { width: 22px; height: 22px; flex: none; }
  .metric-value { margin-top: 12px; font-size: 20px; }
  .metric-note { font-size: 10px; }
  .panel { padding: 16px; }
  .dashboard-side { grid-template-columns: minmax(0,1fr); }
  .dashboard-side .panel { min-height: initial; }
  .category-row { grid-template-columns: minmax(0,1fr) auto; gap: 7px 12px; min-height: 0; padding: 12px 0; }
  .category-name { grid-column: 1; grid-row: 1; gap: 8px; font-size: 12px; }
  .category-bar-wrap { grid-column: 1 / -1; grid-row: 2; gap: 7px; }
  .category-remaining { grid-column: 2; grid-row: 1; align-self: center; font-size: 13px; }
  .category-remaining small { font-size: 10px; }
  .category-bar-label { font-size: 11px; }
  .row-icon { width: 33px; height: 33px; }
  .row-title { font-size: 13px; }
  .row-meta { font-size: 11px; }
  .row-amount { font-size: 12px; }
  .outline-action { min-height: 31px; padding: 0 7px; font-size: 10px; }
  .filter-bar { flex-wrap: wrap; padding: 10px; }
  .filter-bar .search-control { flex-basis: 100%; }
  .filter-bar select { flex: 1; }
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .setting-panel { padding: 17px; }
  .app-dialog { width: 100%; max-width: none; max-height: min(92dvh, 900px); margin: auto 0 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 22px 22px 0 0; }
  .dialog-inner { padding: 20px 18px 0; }
  .dialog-header { margin-bottom: 15px; }
  .dialog-header h2 { font-size: 20px; }
  .dialog-form { gap: 12px; }
  .field label { font-size: 13px; }
  .form-control { min-height: 50px; font-size: 16px; }
  .expense-entry-form #form-amount { min-height: 66px; font-size: 29px; }
  .optional-details summary { min-height: 48px; }
  .dialog-footer { position: sticky; bottom: 0; z-index: 3; margin: 0 -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); }
  .dialog-footer .button { min-height: 50px; }
  .dialog-footer .button--primary { flex: 1; }
  .toast-region { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); }
}
@media (max-width: 375px) {
  .topbar { padding-right: 11px; padding-left: 11px; }
  .topbar-title h1 { font-size: 15px; }
  .nav-item { font-size: 9px; }
  .main-content { padding-right: 12px; padding-left: 12px; }
  .available-card { padding-right: 16px; padding-left: 16px; }
  .category-row { grid-template-columns: minmax(0,1fr) auto; gap: 7px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
