:root {
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-6:24px; --space-8:32px;
  --touch:48px; --field:54px; --primary:56px;
  --radius-control:16px; --radius-card:20px; --radius-modal:24px;
  --text-title:28px; --text-balance:34px; --text-section:21px; --text-modal:23px;
  --text-body:16px; --text-label:14px; --text-meta:13px;
}
body { font-size:var(--text-body); line-height:1.5; font-variant-numeric:tabular-nums; padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px); }
*,*::before,*::after { box-sizing:border-box; }
body button, body [role="button"], body [onclick], body label:has(input[type="file"]) { min-width:var(--touch); min-height:var(--touch); touch-action:manipulation; }
body button[class], body [role="button"], body label:has(input[type="file"]) { font-size:var(--text-body); font-weight:600; border-radius:var(--radius-control); transition:filter .12s,box-shadow .12s,background-color .12s; }
body button:active:not(:disabled), body [role="button"]:active { filter:brightness(.94); }
@media (hover:hover) { body button:hover:not(:disabled), body [role="button"]:hover { filter:brightness(.97); } }
body :is(button,input,select,[role="button"],[tabindex]):focus-visible { outline:3px solid #93c5fd; outline-offset:2px; }
body button:disabled, body [aria-disabled="true"] { opacity:.45; cursor:not-allowed; filter:none; }
body input:not([type="hidden"]):not([type="file"]):not([type="checkbox"]), body select, body .custom-field { min-height:var(--field); font-size:var(--text-body); border-radius:var(--radius-control); padding:var(--space-3) var(--space-4); max-width:100%; min-width:0; }
body input[hidden] { display:none; }
body button[type="submit"], body #saveVariableBtn, body #saveFutureBtn, body #finalActionAccept { min-height:var(--primary); }
body .menu-trigger, body button[aria-label*="סגור"], body button[aria-label*="סגירה"], body button[aria-label*="קוד"], body button[aria-label*="הבא"] { flex-shrink:0; }
body h1[class] { font-size:var(--text-title); font-weight:700; }
body h2[class], body h3[class] { font-size:var(--text-section); font-weight:600; }
body label[class] { font-size:var(--text-label); }
body [class*="text-[10px]"], body [class*="text-[11px]"], body [class*="text-[12px]"], body .text-xs { font-size:var(--text-meta); }
body #balanceDisplay { font-size:var(--text-balance); }
body #balanceDisplay span { font-size:inherit; }
body main[class] { padding:var(--space-4); }
body .space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top:var(--space-6); }
body .gap-1, body .gap-2 { gap:var(--space-2); }
body .custom-field, body .frequency-option { font-size:var(--text-body); }
body .frequency-options { border-radius:var(--radius-control); padding:var(--space-1); }
body .frequency-option { min-height:var(--touch); border-radius:var(--radius-control); }
body #chartPeriodNav { grid-template-columns:var(--touch) minmax(0,1fr) var(--touch); }
body #nav-input,body #nav-explore { border-radius:0; }
body button.w-8,body button.menu-trigger { font-size:22px; }
body button.text-lg { font-size:22px; }
body button[onclick^="submitTransaction"], body button[onclick^="saveEditTransaction"], body button[onclick^="saveFutureTransaction"] { min-height:var(--primary); }
body [id$="Modal"] { padding: max(var(--space-2),env(safe-area-inset-top,0px)) var(--space-2) max(var(--space-2),env(safe-area-inset-bottom,0px)); }
body [id$="Modal"] > div { border-radius:var(--radius-modal); max-width:min(100%,512px); max-height:calc(100dvh - max(8px,env(safe-area-inset-top,0px)) - max(8px,env(safe-area-inset-bottom,0px))); overflow-y:auto; overscroll-behavior:contain; }
body [id$="Modal"] > div:not(.flex) { padding:var(--space-4); }
body [id$="Modal"] :is(h2,h3) { font-size:var(--text-modal); font-weight:700; }
body [id$="Modal"] .space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top:var(--space-4); }
body #datePickerModal > div, body #styledCalendarModal > div { width:400px; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid), body .grid-cols-7 { grid-template-columns:repeat(7,minmax(0,1fr)); gap:0; }
body main :has(> #futureCalGrid) { padding-inline:var(--space-2); }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > :not(:empty) { min-width:44px; min-height:48px; height:48px; border-radius:var(--radius-control); font-size:var(--text-label); }
body .calendar-day { min-width:44px; min-height:48px; }
body .grid-cols-4 { gap:var(--space-2); }
body .grid-cols-4 button { min-width:0; min-height:56px; overflow-wrap:anywhere; }
body #historyList, body main .rounded-2xl { border-radius:var(--radius-card); }
@media (max-width:380px) {
  body main[class] { padding-inline:var(--space-1); }
  body main .p-4, body main .p-5, body main .p-6 { padding-inline:var(--space-1); }
  body [id$="Modal"] { padding-inline:0; }
  body #datePickerModal > div, body #styledCalendarModal > div { padding-inline:4px; }
  body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > :not(:empty) { min-height:44px; height:44px; }
}
@media (max-width:340px) { body main[class] { padding-inline:0; } body main .p-4,body main .p-5,body main .p-6,body main :has(> #futureCalGrid) { padding-inline:0; } }
@media (prefers-reduced-motion:reduce) { body *,body *::before,body *::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; } }

/* Shared screen shell: header/footer participate in flex layout, never cover the scroller. */
body.screen-open { overflow:hidden; }
body .app-icon { width:22px;height:22px;flex-shrink:0;display:block; }
body button,body [role="button"],body .screen-header { user-select:none;-webkit-user-select:none;-webkit-touch-callout:none; }
body .content-screen { padding:16px; }
body [id$="Modal"].content-screen > .screen-panel { display:flex;flex-direction:column;padding:0;margin:0;overflow:hidden;max-height:calc(100dvh - 32px);width:100%; }
body :is(#datePickerModal,#styledCalendarModal) > .screen-panel { padding:0;width:400px; }
body .screen-header { flex:none;display:flex;align-items:center;gap:8px;padding:16px;margin:0;border-bottom:1px solid #e2e8f0;background:#fff;border-radius:0; }
body .screen-header :is(h2,h3) { flex:1;min-width:0;margin:0;overflow-wrap:anywhere; }
body .screen-header button { display:flex;align-items:center;justify-content:center;flex:none;background:transparent;color:#64748b; }
body .screen-body { flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:16px;scroll-padding-block:16px; }
body .screen-body > .pb-20 { padding-bottom:16px; }
body .screen-footer { flex:none;background:white;border-top:1px solid #e2e8f0;padding:12px 16px max(12px,env(safe-area-inset-bottom,0px)); }
body .screen-footer > button { width:100%;margin:0; }
body .screen-panel.space-y-4 > * { margin-top:0; }
body .screen-body > label { display:block;margin-bottom:16px; }
body #dayActions { width:100%;position:static; }
body #fabMainBtn { display:none; }
body #fabOptions { display:flex;opacity:1;transform:none;pointer-events:auto;width:100%;gap:12px; }
body #fabOptions > button { flex:1;min-width:0;justify-content:center; }
body #backToBarBtn { display:none !important; }
body #graphDetailModal #chartWrapper { height:260px;flex:none; }
body .floating-popup { position:fixed !important;z-index:2000 !important;margin:0;bottom:auto;right:auto;overflow:auto;overscroll-behavior:contain;background:white;border:1px solid #e2e8f0;border-radius:16px;box-shadow:0 12px 36px #0f172a30; }
body .floating-popup button { display:block;width:100%;padding:12px 16px;text-align:right; }
body .menu-trigger { display:inline-flex;align-items:center;justify-content:center; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > :not(:empty) { border-radius:12px;position:relative; }
body #futureCalGrid > :not(:empty) { padding-top:5px;border-color:transparent; }
body #futureCalGrid > button > div { bottom:5px;left:50%;transform:translateX(-50%);gap:3px; }
body :is(#datePickerModal,#styledCalendarModal) .screen-body { padding-inline:16px; }
@media (max-width:640px) {
  body .content-screen { inset:var(--screen-top,0px) 0 auto;height:var(--screen-height,100dvh);padding:0;background:white;align-items:stretch; }
  body [id$="Modal"].content-screen > .screen-panel, body :is(#datePickerModal,#styledCalendarModal) > .screen-panel { width:100%;max-width:none;height:var(--screen-height,100dvh);max-height:var(--screen-height,100dvh);padding:0;border:0;border-radius:0;box-shadow:none;animation:none; }
  body .content-screen .screen-header { padding-top:max(12px,env(safe-area-inset-top,0px)); }
  body .content-screen .screen-body { padding-bottom:max(16px,env(safe-area-inset-bottom,0px)); }
  body :is(#datePickerModal,#styledCalendarModal) .screen-body { padding-inline:4px; }
  body .content-screen .screen-header h3,body .content-screen .screen-header h2 { font-size:21px; }
}
/* Shared swipe surface: actions remain inside the row, clear of adjacent rows. */
body .swipe-row { position:relative;overflow:hidden;isolation:isolate;border-radius:16px;background:#f1f5f9; }
body .swipe-content { position:relative;z-index:1;width:100%;min-width:0;touch-action:pan-y pinch-zoom;transition:transform 180ms ease;background:white;margin:0; }
body .swipe-content > .flex:first-child { min-width:0; }
body .swipe-content .text-right { min-width:0;overflow-wrap:anywhere; }
body .swipe-content > [dir="ltr"] { flex-shrink:0; }
body .swipe-dragging .swipe-content { transition:none;user-select:none; }
body .swipe-actions { position:absolute;top:0;bottom:0;width:64px;display:flex;align-items:center;justify-content:center;direction:ltr;padding:8px; }
body .swipe-tray-delete { left:0;right:auto; }
body .swipe-tray-edit { right:0;left:auto; }
body .swipe-actions[hidden] { display:none; }
body .swipe-actions button { width:48px;height:48px;display:grid;place-items:center;border-radius:14px;background:white; }
body .swipe-edit { color:#2563eb; } body .swipe-delete { color:#e11d48; }
body .swipe-actions button:hover { background:#e2e8f0; } body .swipe-actions button:active { transform:scale(.94); }
body .swipe-content:focus-visible { outline:2px solid #2563eb;outline-offset:-3px; }
body .history-description { display:block;overflow-wrap:anywhere; }
body .secondary-row-options { color:#64748b;font-size:13px; }
body .secondary-row-options summary { min-height:48px;display:flex;align-items:center;cursor:pointer; }
body .screen-header { direction:rtl; }
body .screen-header .screen-back { width:48px;height:48px;min-width:48px;border-radius:14px;margin:0; }
body .screen-header button[hidden] { display:none!important; }
body .screen-header .screen-back:hover { background:#eff6ff;color:#2563eb; }
body .screen-header .screen-back:active { background:#dbeafe;transform:scale(.96); }
body .screen-header .screen-back:focus-visible { outline:2px solid #2563eb;outline-offset:2px; }
body #dayViewModal.content-screen { align-items:center;justify-content:center;background:rgb(15 23 42 / .4);padding:12px;backdrop-filter:blur(6px); }
body #dayViewModal.content-screen > .screen-panel { width:100%;max-width:480px;height:auto;min-height:0;max-height:75dvh;border-radius:24px;box-shadow:0 20px 60px #0f172a30; }
body #dayViewModal .screen-body { flex:0 1 auto; }
body #dayViewModal .screen-footer { padding:12px max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)); }
body #dayActions { display:flex;align-items:center;gap:8px;position:relative;inset:auto;min-height:56px; }
body #fabMainBtn { display:flex;width:56px;height:56px;min-width:56px; }
body #fabOptions { display:flex;flex:1;width:auto;gap:8px;transition:opacity 180ms ease,transform 180ms ease; }
body #fabOptions.opacity-0 { opacity:0;transform:translateX(12px);pointer-events:none; }
body #fabOptions.opacity-100 { opacity:1;transform:translateX(0);pointer-events:auto; }
body #fabOptions > button { padding-inline:8px; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) { gap:1px; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > :not(:empty) { border:1px solid #dbe3ef;border-radius:10px;box-shadow:inset 0 0 0 1px white; }
body #futureCalGrid > :not(:empty) { padding-top:3px; }
body :is(#pickerMonthYear,#styledCalendarMonth,#futureMonthYearTitle) { padding:8px 12px;border:1px solid transparent;border-radius:12px; }
body .calendar-current-month { background:#eff6ff;border-color:#bfdbfe!important;color:#1d4ed8; }
@media(min-width:641px) { body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) { gap:2px; } }
@media(max-width:340px) { body :is(#datePickerModal,#styledCalendarModal) .screen-body { padding-inline:2px; } }
body #fabMainBtn { border-radius:50%;font-size:30px; }
body #fabIcon { padding:0; }
@media(min-width:381px) and (max-width:640px) { body main :has(> #futureCalGrid) { padding-inline:4px; } }
body .swipe-content { border-radius:inherit;box-shadow:none; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > [aria-current="date"] { border-color:#60a5fa;box-shadow:inset 0 0 0 1px #60a5fa; }
/* Main tabs share one fixed navigation height and reserve its entire safe area. */
:root { --bottom-nav-height:76px; }
body main[class] { padding-bottom:calc(var(--bottom-nav-height) + env(safe-area-inset-bottom,0px) + 24px); }
body .bottom-nav { position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:min(100%,448px);height:calc(var(--bottom-nav-height) + env(safe-area-inset-bottom,0px));padding:4px 8px calc(4px + env(safe-area-inset-bottom,0px));display:flex;gap:8px;z-index:40;background:rgb(255 255 255 / .97);border-top:1px solid #e2e8f0;box-shadow:0 -4px 20px #0f172a08;direction:rtl; }
body .bottom-nav button { flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;color:#64748b;font-size:13px;border-radius:16px!important; }
body .bottom-nav button[aria-current="page"] { color:#2563eb;background:#eff6ff; }
body .bottom-nav button:hover { background:#f1f5f9; }
body .bottom-nav button[aria-current="page"]:hover { background:#dbeafe; }
body .balance-card { display:grid;grid-template-columns:minmax(0,1fr) auto;direction:rtl;gap:16px;padding:16px;align-items:center; }
body .balance-main { min-width:0;text-align:right; }
body .balance-value { text-align:right;font-size:30px;font-weight:800;white-space:nowrap; }
body #balanceDisplay { font-size:clamp(24px,6.5vw,32px); }
body .balance-indicators { display:flex;flex-direction:column;gap:12px;align-items:flex-start; }
body .balance-indicator { display:flex;align-items:center;gap:8px;font-size:14px;font-weight:600;white-space:nowrap;direction:ltr; }
body .balance-indicator .app-icon { width:18px;height:18px; }
body .history-screen { min-width:0; }
body .history-screen h2 { font-size:26px;font-weight:700;margin-bottom:16px; }
body .history-filters { display:grid;gap:12px;background:white;padding:16px;border:1px solid #e2e8f0;border-radius:20px;margin-bottom:16px; }
body .history-filters label { display:block;font-size:14px;color:#64748b;margin-bottom:4px; }
body .history-filters input { width:100%;border:1px solid #dbe3ef;background:#f8fafc; }
body .history-types { display:flex;gap:8px;background:#f1f5f9;padding:4px;border-radius:16px; }
body .history-types button { flex:1;min-width:0; }
body .history-types button[aria-pressed="true"] { background:#eff6ff;color:#2563eb;box-shadow:0 1px 4px #0f172a15; }
body .history-filter-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px; }
body .history-filter-grid .custom-field { width:100%;text-align:right;border:1px solid #dbe3ef;padding:8px 12px;min-height:56px;font-size:14px; }
body .history-reset { justify-self:start;color:#64748b;padding-inline:12px; }
body #historyResultsCount { margin:16px 0 8px; }
body .history-empty { text-align:center;padding:32px 16px;color:#64748b; }
body .history-empty p { margin-top:8px; }
body .history-empty button { color:#2563eb;margin-top:12px; }
body #historyOptions button[aria-pressed="true"] { color:#2563eb;background:#eff6ff; }
@media(max-width:360px) { body .balance-card { gap:8px;padding:12px; } body .balance-indicator { gap:4px;font-size:13px; } body .balance-value { font-size:24px; } }
body .balance-value { color:#fff; }
body .category-icon { display:block;width:24px;height:24px;flex-shrink:0; }
body .category-grid .category-tile { display:flex;flex-direction:column;justify-content:center;align-items:center;gap:8px;min-height:84px;padding:12px 4px;border:1px solid #e2e8f0;border-radius:16px;background:white;color:#475569;font-size:13px;overflow-wrap:anywhere; }
body .category-grid .category-tile[aria-pressed="true"] { background:#2563eb;color:white;border-color:#2563eb; }
body .category-grid .category-add { border-style:dashed;color:#2563eb; }
body .category-tile:hover { box-shadow:0 2px 8px #0f172a15; }
body .category-preview { display:flex;align-items:center;gap:12px;padding:16px;margin:16px 0;background:#eff6ff;border:1px solid #dbeafe;border-radius:16px;color:#2563eb;overflow-wrap:anywhere; }
body #categoryNameInput { width:100%;border:1px solid #e2e8f0; }
body #categoryIconCatalog h3 { font-size:16px;margin:24px 0 12px; }
body .icon-catalog-grid { display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px; }
body .icon-catalog-grid button { display:grid;place-items:center;min-width:48px;height:52px;border:1px solid #e2e8f0;border-radius:14px;color:#475569; }
body .icon-catalog-grid button[aria-pressed="true"] { background:#eff6ff;border-color:#2563eb;color:#2563eb; }
body #createCategoryModal .screen-footer button { height:56px; }
@media(max-width:380px) { body .icon-catalog-grid { grid-template-columns:repeat(5,minmax(0,1fr)); } }
body #myCategoriesGrid { margin:12px 0 24px; }
body .category-empty { grid-column:1 / -1;font-size:14px;color:#64748b;padding:12px; }
body .history-toolbar { display:grid;gap:12px;min-width:0; }
body .history-category-row { display:flex;gap:8px;overflow-x:auto;min-width:0;padding:4px 2px 8px;overscroll-behavior-x:contain; }
body .history-chip { padding:8px 14px;border:1px solid #e2e8f0;background:white;color:#475569;flex-shrink:0; }
body .history-chip[aria-pressed="true"] { background:#eff6ff;border-color:#93c5fd;color:#1d4ed8; }
body .history-quick-filters { display:flex;flex-wrap:wrap;gap:8px; }
body .history-quick-filters button { padding:8px 12px;background:#f1f5f9;color:#475569;font-size:14px;border-radius:var(--radius-control); }
body .history-period { display:grid;grid-template-columns:48px minmax(0,1fr) 48px;gap:8px;align-items:center;text-align:center;margin-top:12px; }
body .history-period[hidden] { display:none; }
body .history-period button { display:grid;place-items:center;background:white;border:1px solid #e2e8f0;border-radius:var(--radius-control); }
body .history-period .period-next svg { transform:rotate(180deg); }
body .history-period span { font-size:14px;font-weight:600; }
body .history-filter-section { margin-bottom:24px;scroll-margin-top:12px; }
body .history-filter-section h4 { font-weight:600;margin-bottom:12px;font-size:17px; }
body .history-choice-group { display:flex;flex-wrap:wrap;gap:8px; }
body #historyFilterActions { display:flex;gap:12px; }
body #historyFilterActions button { padding:12px 16px;background:#f1f5f9;border-radius:var(--radius-control);font-size:16px;font-weight:600; }
body #historyFilterActions button:last-child { flex:1;background:#2563eb;color:white; }
body .history-range { position:relative;height:56px;margin:8px 12px; }
body #historyAmountTrack { position:absolute;top:25px;left:24px;right:24px;height:6px;border-radius:8px;background:linear-gradient(to right,#e2e8f0 var(--range-low,0%),#2563eb var(--range-low,0%),#2563eb var(--range-high,100%),#e2e8f0 var(--range-high,100%)); }
body #historyFilterModal .history-range input[type="range"] { position:absolute;inset:0;width:100%;height:56px;min-height:0;padding:0;margin:0;border:0;background:transparent;appearance:none;pointer-events:none; }
body .history-range input::-webkit-slider-thumb { appearance:none;width:48px;height:48px;border:0;border-radius:50%;background:radial-gradient(circle,white 0 10px,#2563eb 11px 14px,transparent 15px);pointer-events:auto;cursor:grab; }
body .history-range input::-moz-range-thumb { width:48px;height:48px;border:0;border-radius:50%;background:radial-gradient(circle,white 0 10px,#2563eb 11px 14px,transparent 15px);pointer-events:auto;cursor:grab; }
body .history-range input:focus-visible { outline:0; }
body .history-range input:focus-visible::-webkit-slider-thumb { outline:3px solid #93c5fd;outline-offset:3px; }
body .history-range input:disabled { opacity:.4; }
body #historyAmountValues { display:block;text-align:center;font-weight:600; }
body .history-filter-trigger { position:relative;display:grid;place-items:center;height:54px;background:#eff6ff;color:#2563eb;border:1px solid #dbeafe; }
body #historyFilterBadge { position:absolute;top:-5px;right:-4px;min-width:20px;height:20px;line-height:20px;border-radius:50%;background:#2563eb;color:white;font-size:13px; }
body #historyFilterBadge[hidden] { display:none; }
body.history-filter-open .bottom-nav { display:none; }
body .history-filter-row { display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:right;width:100%;padding:20px 16px;border:1px solid #e2e8f0;background:white; }
body .history-filter-row > span { min-width:0; }
body .history-filter-row strong { display:block;font-size:17px; }
body .history-filter-value { display:block;font-size:14px;color:#64748b;margin-top:4px;overflow-wrap:anywhere; }
body .history-category-picker { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px; }
body .history-category-picker small { font-size:13px; }
body .history-detail-confirm { width:100%;min-height:56px;background:#2563eb;color:white; }

/* Day planning: content grows first; only the middle section yields to scrolling. */
body #dayViewModal.content-screen {
  padding-top:max(12px,env(safe-area-inset-top,0px));
  padding-bottom:max(12px,env(safe-area-inset-bottom,0px));
}
body #dayViewModal.content-screen > .screen-panel {
  max-height:calc(var(--screen-height,100dvh) - max(12px,env(safe-area-inset-top,0px)) - max(12px,env(safe-area-inset-bottom,0px)));
  transition:height 240ms ease;
}
body #dayViewModal .screen-header, body #dayViewModal .screen-footer { border:0; }
body #dayViewModal .screen-body { flex:1 1 auto; }
body #dayViewModal .screen-body > div { padding:0;flex:none; }
body #dayViewList > .text-center { padding-block:16px; }
body #fabMainBtn { transition:background-color 300ms ease,box-shadow 300ms ease,filter 120ms ease; }
body #fabMainBtn[aria-expanded="true"] { background-color:#7dd3fc;color:#0c4a6e;box-shadow:0 4px 15px rgb(56 189 248 / .25); }
body #fabIcon { transition:transform 300ms ease; }
body #fabOptions .app-icon { width:22px;height:22px; }

/* All three calendars share reference-sized day tiles, regardless of their date rules. */
:root { --calendar-cell-height:76px; --calendar-gap:4px; --calendar-radius:12px; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid).calendar-grid,
body .calendar-weekdays { grid-template-columns:repeat(7,minmax(0,1fr));gap:var(--calendar-gap); }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid).calendar-grid > :not(:empty) {
  min-width:44px;min-height:var(--calendar-cell-height);height:var(--calendar-cell-height);
  border-radius:var(--calendar-radius);display:flex;align-items:center;justify-content:flex-start;
  flex-direction:column;padding:8px 0 0;font-size:var(--text-label);line-height:20px;
}
body #futureCalGrid.calendar-grid > button > div { bottom:12px; }
body :has(> :is(#pickerMonthYear,#styledCalendarMonth,#futureMonthYearTitle)) > button {
  display:inline-flex;align-items:center;justify-content:center;width:var(--touch);height:var(--touch);flex-shrink:0;
}
/* Keep the existing dialog stack and back behavior, only change the calendar shell. */
body :is(#datePickerModal,#styledCalendarModal).calendar-popup {
  inset:0;height:100dvh;padding:max(8px,env(safe-area-inset-top,0px)) 8px max(8px,env(safe-area-inset-bottom,0px));
  align-items:center;justify-content:center;background:rgb(15 23 42 / .4);backdrop-filter:blur(6px);
}
body :is(#datePickerModal,#styledCalendarModal).calendar-popup > .screen-panel {
  width:394px;max-width:100%;height:auto;min-height:0;
  max-height:min(90dvh,calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 16px));
  border:1px solid #e2e8f0;border-radius:var(--radius-modal);box-shadow:0 20px 60px #0f172a30;
}
body :is(#datePickerModal,#styledCalendarModal).calendar-popup .screen-header { padding:12px 16px; }
body :is(#datePickerModal,#styledCalendarModal).calendar-popup .screen-body { flex:0 1 auto;padding:12px 16px; }
@media(max-width:380px) {
  :root { --calendar-gap:2px; }
  body :is(#datePickerModal,#styledCalendarModal).calendar-popup { padding-inline:2px; }
  body :is(#datePickerModal,#styledCalendarModal).calendar-popup .screen-body { padding-inline:4px; }
}
@media(max-width:340px) {
  :root { --calendar-gap:1px; }
  body :is(#datePickerModal,#styledCalendarModal).calendar-popup { padding-inline:0; }
  body :is(#datePickerModal,#styledCalendarModal).calendar-popup .screen-body { padding-inline:2px; }
}

/* Clarity pass: shared states without changing calendar geometry. */
body .field-label { display:block;font-size:var(--text-label);font-weight:600;color:#64748b;margin-bottom:4px; }
body .field-help { display:block;font-size:var(--text-meta);color:#64748b;margin-top:4px; }
body .field-group > :is(input,button,select) { margin-top:0; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > .calendar-day[aria-current="date"] { background:#eff6ff;border-color:#60a5fa;box-shadow:inset 0 0 0 1px #60a5fa; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > .calendar-day[aria-pressed="true"] { background:#2563eb;color:white;border-color:#2563eb; }
body #futureCalGrid > .calendar-day[aria-pressed="true"] > span { color:white; }
body :is(#pickerGrid,#styledCalendarGrid,#futureCalGrid) > .calendar-day[aria-pressed="true"][aria-current="date"] { box-shadow:inset 0 0 0 2px white,inset 0 0 0 4px #60a5fa; }
body .calendar-day[aria-current="date"]::after { content:'';position:absolute;bottom:6px;width:4px;height:4px;border-radius:50%;background:currentColor;left:calc(50% - 2px); }
body #futureCalGrid > button[aria-current="date"] > div { bottom:20px; }
body .chart-empty { padding:24px;text-align:center;color:#64748b;font-size:16px; }
body #chartWrapper:has(#chartEmpty:not([hidden])) #financeChart { position:absolute; }

/* History uses one contextual sheet, with the existing shared control tokens. */
body .history-filter-bar { display:flex;justify-content:flex-start; }
body .history-filter-bar .history-filter-trigger { display:flex;align-items:center;gap:8px;padding:0 16px; }
body #historyFilterModal.content-screen { inset:0;height:100dvh;padding:0;background:rgb(15 23 42 / .4);backdrop-filter:blur(6px);align-items:flex-end;justify-content:center; }
body #historyFilterModal.content-screen > .screen-panel { width:100%;max-width:560px;height:auto;max-height:calc(100dvh - max(16px,env(safe-area-inset-top,0px)));margin:0;border:0;border-radius:24px 24px 0 0;display:flex;flex-direction:column;overflow:hidden;background:white;transition:transform 180ms ease;animation:history-sheet-in 180ms ease-out; }
body .history-sheet-top { flex:none;text-align:center;touch-action:none;user-select:none; }
body #historySheetHandle { width:100%;height:44px;min-height:44px;display:flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:24px; }
body #historySheetHandle span { width:40px;height:4px;background:#cbd5e1;border-radius:8px; }
body #historySheetTitle { font-size:var(--text-section);font-weight:700;margin:0 0 16px; }
body #historyFilterModal .screen-body { flex:1 1 auto;min-height:0;padding:0 16px;overflow-y:auto;overscroll-behavior:contain; }
body #historyFilterModal .screen-footer { flex:none;padding:12px 16px max(12px,env(safe-area-inset-bottom,0px));background:white; }
body #historyFilterActions > button { width:auto;white-space:nowrap;min-height:52px; }
body #historyFilterActions > button:first-child { flex:0 0 30%; }
body #historyFilterModal .history-type-segment { display:flex;flex-wrap:nowrap;background:#f1f5f9;border:1px solid #e2e8f0;padding:4px;border-radius:20px;gap:4px; }
body #historyFilterModal .history-type-segment button { flex:1;min-width:0;border:0;border-radius:16px;background:transparent; }
body #historyFilterModal .history-type-segment button[aria-pressed="true"] { background:#2563eb;color:white; }
body #historyFilterModal .history-category-picker { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px; }
body #historyFilterModal .category-tile { min-height:76px;padding:8px 4px;font-size:13px;gap:4px; }
body #historyFilterModal .category-tile svg { width:22px;height:22px; }
body #historyFilterModal .category-tile small { font-size:13px; }
body #historySourceAccordion summary { min-height:48px;cursor:pointer;display:list-item;font-size:16px;font-weight:600; }
body #historySourceValue { font-size:14px;color:#64748b;font-weight:400;margin-inline-start:8px; }
body #historySourceAccordion .history-choice-group { padding-top:8px; }
@media(max-width:360px) {
  body #historyFilterModal .history-category-picker { grid-template-columns:repeat(3,minmax(0,1fr)); }
  body #historyChoices-source { display:grid;grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@keyframes history-sheet-in { from { transform:translateY(100%); } to { transform:translateY(0); } }
@media(prefers-reduced-motion:reduce) { body #historyFilterModal.content-screen > .screen-panel { animation:none;transition:none; } }
