    /* ═══════════════════════════════════════════════════
       THEME — Telegram integration layer
       Uses CSS custom properties. Falls back to defaults
       if running outside Telegram (desktop preview).
       ═══════════════════════════════════════════════════ */
    :root {
      /* Telegram theme vars (set by TG runtime) */
      --tg-theme-bg-color: #F5F5F0;
      --tg-theme-secondary-bg-color: #FFFFFF;
      --tg-theme-text-color: #1F2937;
      --tg-theme-hint-color: #9CA3AF;
      --tg-theme-link-color: #F59E0B;
      --tg-theme-button-color: #F59E0B;
      --tg-theme-button-text-color: #FFFFFF;
      --tg-theme-header-bg-color: #FFFFFF;

      /* Semantic layer — app uses these */
      --bg: var(--tg-theme-bg-color);
      --surface: var(--tg-theme-secondary-bg-color);
      --accent: var(--tg-theme-button-color, #F59E0B);
      --accent-light: color-mix(in srgb, var(--tg-theme-button-color, #F59E0B) 12%, transparent);
      --accent-dark: color-mix(in srgb, var(--tg-theme-button-color, #F59E0B) 85%, #000);
      --text-primary: var(--tg-theme-text-color, #1F2937);
      --text-secondary: var(--tg-theme-hint-color, #9CA3AF);
      --text-muted: var(--tg-theme-hint-color, #9CA3AF);
      --link-color: var(--tg-theme-link-color, #F59E0B);
      --header-bg: var(--tg-theme-header-bg-color, #FFFFFF);

      --border: color-mix(in srgb, var(--tg-theme-text-color, #1F2937) 8%, var(--tg-theme-secondary-bg-color, #FFF));
      --danger: #EF4444;
      --success: #10B981;
      --radius: 12px;
      --radius-lg: 16px;
      --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
      --transition: 200ms ease;

      /* Native controls (date picker, select, scrollbars) follow the theme */
      color-scheme: light;
    }

    /* Dark fallback palette. `data-theme` is set from Telegram's colorScheme;
       real themeParams (inline styles on <html>) take precedence, so this
       only fills the gaps when params are missing or partial. */
    :root[data-theme="dark"] {
      color-scheme: dark;
      --tg-theme-bg-color: #17212B;
      --tg-theme-secondary-bg-color: #232E3C;
      --tg-theme-text-color: #F5F5F5;
      --tg-theme-hint-color: #8B9AA8;
      --tg-theme-link-color: #FBBF24;
      --tg-theme-button-color: #F59E0B;
      --tg-theme-header-bg-color: #17212B;
      --border: color-mix(in srgb, var(--tg-theme-text-color, #F5F5F5) 12%, var(--tg-theme-secondary-bg-color, #232E3C));
      --shadow: 0 1px 3px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.25);
    }

    * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

    /* Buttons do NOT inherit color by default — the UA paints them black,
       which is unreadable on dark surfaces. Force inheritance; themed
       buttons (.btn-primary, .key-accent, ...) override explicitly. */
    button { color: inherit; }

    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    html {
      /* Prevent bounce/overscroll on iOS */
      overflow: hidden;
      touch-action: manipulation;
    }

    body {
      font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
      background: var(--bg);
      color: var(--text-primary);
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    /* ─── App Shell ─── */
    #app {
      display: flex;
      flex-direction: column;
      height: 100%;
      overflow: hidden;
    }

    /* ─── Screens ─── */
    .screen {
      display: none;
      flex-direction: column;
      height: 100%;
      animation: fadeSlideIn 300ms ease;
    }
    .screen.active { display: flex; }

    @keyframes fadeSlideIn {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* ─── Header ─── */
    .header {
      background: var(--header-bg);
      border-bottom: 1px solid var(--border);
      padding: 12px 16px;
      flex-shrink: 0;
    }
    .header-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .header-title {
      font-size: 19px;
      font-weight: 700;
      color: var(--text-primary);
    }
    .header-subtitle {
      font-size: 13px;
      color: var(--text-secondary);
      margin-top: 2px;
    }
    .header-actions {
      display: flex;
      gap: 4px;
    }
    .header-btn {
      width: 44px; height: 44px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: var(--text-primary);
      font-size: 20px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background var(--transition);
    }
    .header-btn:active { background: var(--border); }

    /* ─── Scrollable Content ─── */
    .content {
      flex: 1;
      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
      padding-bottom: 24px;
    }

    /* ─── Buttons ─── */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 14px 24px;
      border-radius: var(--radius);
      border: none;
      font-family: inherit;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      transition: all var(--transition);
      min-height: 48px;
      min-width: 48px;
      text-decoration: none;
      -webkit-user-select: none;
      user-select: none;
    }
    .btn:active { transform: scale(0.97); opacity: 0.85; }
    .btn:disabled {
      opacity: 0.5;
      pointer-events: none;
    }
    .btn-primary {
      background: var(--accent);
      color: var(--tg-theme-button-text-color, #fff);
      box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 25%, transparent);
    }
    .btn-primary:active { opacity: 0.8; }
    .btn-secondary {
      background: var(--surface);
      color: var(--text-primary);
      border: 1.5px solid var(--border);
    }
    .btn-ghost {
      background: transparent;
      color: var(--text-secondary);
      padding: 12px;
    }
    .btn-danger {
      background: color-mix(in srgb, var(--danger) 10%, var(--surface));
      color: var(--danger);
    }
    .btn-full { width: 100%; }

    /* ─── Cards ─── */
    .card {
      background: var(--surface);
      border-radius: var(--radius-lg);
      margin: 0 16px 12px;
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 20px 10px;
    }
    .card-title {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.6px;
    }

    /* ─── Collapsible cards (admin tab) ─── */
    .card-header-toggle {
      gap: 8px;
      cursor: pointer;
    }
    .card-header-toggle .card-title { flex: 1; min-width: 0; }
    .card-chevron {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      flex-shrink: 0;
      border: none;
      background: transparent;
      color: var(--text-secondary);
      cursor: pointer;
      border-radius: var(--radius);
      transition: transform var(--transition), background var(--transition);
    }
    .card-chevron:active { background: var(--border); }
    .card-chevron svg { transition: transform var(--transition); }
    .collapsible-card.collapsed .card-chevron svg { transform: rotate(-90deg); }
    .card-body {
      display: grid;
      grid-template-rows: 1fr;
      transition: grid-template-rows var(--transition);
    }
    .card-body > * { overflow: hidden; min-height: 0; }
    .collapsible-card.collapsed .card-body { grid-template-rows: 0fr; }
    .budget-settings-body { padding: 0 20px 16px; }

    /* ─── Inputs ─── */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    textarea,
    select {
      font-family: inherit;
      font-size: 16px;
      padding: 14px 16px;
      border-radius: var(--radius);
      border: 1.5px solid var(--border);
      background: var(--surface);
      color: var(--text-primary);
      width: 100%;
      transition: border-color var(--transition);
      -webkit-appearance: none;
    }
    input:focus, textarea:focus, select:focus {
      outline: none;
      border-color: var(--accent);
    }
    textarea { resize: vertical; min-height: 60px; }

    .input-group { margin-bottom: 16px; }
    .input-label {
      display: block;
      font-size: 13px;
      font-weight: 500;
      color: var(--text-secondary);
      margin-bottom: 6px;
      padding: 0 20px;
    }
    .input-group-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 20px;
    }
    .input-group-row .input-label { margin-bottom: 0; padding: 0; flex: 1; }
    .input-group-row input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; }

    /* ─── Cash toggle (entry modal) ───
       A right-aligned pill rather than the label-left / checkbox-right split
       of .input-group-row: at the far edges of a full-width row the label and
       the box it controls read as two unrelated controls, and the tap target
       is only as big as the box. Here the whole pill is the <label>, so
       anywhere in it toggles, and the ticked state is unmistakable. */
    .cash-toggle-row { display: flex; justify-content: flex-end; }
    .cash-toggle {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      padding: 10px 14px;
      border-radius: var(--radius);
      border: 1.5px solid var(--border);
      background: var(--surface);
      color: var(--text-primary);
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      transition: all var(--transition);
      -webkit-user-select: none;
      user-select: none;
    }
    .cash-toggle:active { transform: scale(0.97); }
    .cash-toggle.checked {
      border-color: var(--accent);
      background: var(--accent-light);
    }
    .cash-toggle-icon { font-size: 18px; line-height: 1; }
    .cash-toggle input[type="checkbox"] {
      width: 26px;
      height: 26px;
      margin: 0;
      flex-shrink: 0;
      accent-color: var(--accent);
    }

    /* ─── Join Screen ─── */
    .join-screen {
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 32px 24px;
      text-align: center;
      flex: 1;
    }
    .join-screen.active { display: flex; }

    .join-logo {
      width: 72px; height: 72px;
      background: var(--accent);
      border-radius: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 32px;
      margin-bottom: 20px;
      box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 30%, transparent);
    }
    .join-title {
      font-size: 24px;
      font-weight: 700;
      margin-bottom: 8px;
      color: var(--text-primary);
    }
    .join-desc {
      font-size: 15px;
      color: var(--text-secondary);
      margin-bottom: 28px;
      line-height: 1.5;
    }
    .family-code-input {
      /* Codes are 9 chars ("FAM" + 6 hex), so the box has to fit all of them
         without clipping — hence the smaller type and tighter tracking. */
      font-size: 24px;
      font-weight: 700;
      text-align: center;
      letter-spacing: 3px;
      text-transform: uppercase;
      width: 100%;
      max-width: 280px;
      margin-bottom: 20px;
      border-radius: var(--radius);
      padding: 16px;
    }
    .join-actions { width: 100%; max-width: 280px; }

    /* ─── Expenses List ─── */
    .expense-item {
      display: flex;
      align-items: center;
      padding: 12px 16px;
      gap: 12px;
      transition: background var(--transition);
    }
    .expense-item--editable { cursor: pointer; }
    .expense-item--editable:active { background: var(--border); }
    .expense-delete {
      flex-shrink: 0;
      width: 32px; height: 32px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: var(--danger);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .expense-delete:active { background: color-mix(in srgb, var(--danger) 10%, transparent); }
    .expense-cat-icon {
      width: 44px; height: 44px;
      border-radius: 12px;
      background: var(--accent-light);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
      flex-shrink: 0;
    }
    .expense-info { flex: 1; min-width: 0; }
    .expense-note {
      font-size: 15px;
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .expense-meta {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 2px;
    }
    .expense-amount {
      font-size: 16px;
      font-weight: 700;
      color: var(--text-primary);
      flex-shrink: 0;
    }
    .expense-amount.amount-positive { color: var(--success); }
    .recurring-indicator {
      margin-left: 6px;
      font-size: 13px;
    }

    /* ─── Category Grid ─── */
    .cat-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      padding: 8px 16px;
    }
    .cat-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      padding: 14px 6px;
      border-radius: var(--radius);
      border: 1.5px solid var(--border);
      background: var(--surface);
      cursor: pointer;
      transition: all var(--transition);
      min-height: 76px;
      -webkit-user-select: none;
      user-select: none;
    }
    .cat-btn:active { transform: scale(0.95); }
    .cat-btn.selected {
      border-color: var(--accent);
      background: var(--accent-light);
    }
    .cat-btn-icon { font-size: 24px; }
    .cat-btn-name {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-secondary);
      text-align: center;
      line-height: 1.2;
    }
    .cat-btn.selected .cat-btn-name { color: var(--accent); }

    /* ─── Amount Display ─── */
    .amount-display {
      text-align: center;
      padding: 16px 20px;
    }
    .amount-value {
      font-size: 52px;
      font-weight: 700;
      color: var(--text-primary);
      letter-spacing: -2px;
      line-height: 1;
    }
    .amount-currency {
      font-size: 22px;
      font-weight: 500;
      color: var(--text-secondary);
      margin-left: 4px;
    }


    /* ─── Keypad ─── */
    .keypad {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      padding: 4px 20px 12px;
      max-width: 340px;
      margin: 0 auto;
    }
    .key {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 60px;
      border-radius: var(--radius);
      border: none;
      background: var(--surface);
      font-size: 26px;
      font-weight: 600;
      font-family: inherit;
      color: var(--text-primary);
      cursor: pointer;
      transition: all var(--transition);
      box-shadow: 0 1px 3px rgba(0,0,0,0.06);
      -webkit-user-select: none;
      user-select: none;
      min-width: 0;
    }
    .key:active { transform: scale(0.94); background: var(--border); }
    .key-accent {
      background: var(--accent);
      color: var(--tg-theme-button-text-color, #fff);
    }
    .key-accent:active { opacity: 0.8; }
    .key-danger {
      background: color-mix(in srgb, var(--danger) 8%, var(--surface));
      color: var(--danger);
    }

    /* ─── Streak chip ─── */
    .streak-chip {
      display: inline-flex;
      align-items: center;
      margin: 16px 16px 0;
      padding: 7px 14px;
      border-radius: 20px;
      background: linear-gradient(135deg,
        color-mix(in srgb, var(--accent) 20%, var(--surface)),
        color-mix(in srgb, #EF4444 12%, var(--surface)));
      border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
      color: var(--text-primary);
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.2px;
    }

    /* ─── Hero card (Expenses tab) ─── */
    .hero-card {
      margin: 12px 16px 0;
      padding: 18px 20px 16px;
      text-align: center;
    }
    .hero-label {
      font-size: 11px;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.6px;
      font-weight: 600;
    }
    .hero-value {
      font-size: 36px;
      font-weight: 700;
      letter-spacing: -1px;
      line-height: 1.2;
      margin-top: 4px;
      color: var(--text-primary);
    }
    .hero-value.limit-exceeded { color: var(--danger); }
    .hero-progress { margin-top: 10px; }
    .hero-progress-track {
      height: 6px;
      border-radius: 3px;
      background: var(--border);
      overflow: hidden;
    }
    .hero-progress-fill {
      height: 100%;
      border-radius: 3px;
      background: var(--accent);
      transition: width 400ms ease;
    }
    .hero-progress-fill.limit-exceeded { background: var(--danger); }
    .hero-progress-label {
      margin-top: 6px;
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
    }
    .hero-sub {
      display: block;
      margin-top: 8px;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
    }
    .hero-sub.limit-exceeded { color: var(--danger); }

    /* ─── Dashboard: month summary card ─── */
    .summary-card {
      margin: 12px 16px 0;
      padding: 18px 20px 14px;
      text-align: center;
    }
    .summary-label {
      font-size: 11px;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.6px;
      font-weight: 600;
    }
    .summary-balance {
      font-size: 34px;
      font-weight: 700;
      letter-spacing: -1px;
      line-height: 1.2;
      margin-top: 4px;
      color: var(--text-primary);
    }
    .summary-balance.balance-positive { color: var(--success); }
    .summary-balance.balance-negative { color: var(--danger); }
    .summary-split {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-top: 14px;
      padding-top: 12px;
      border-top: 1px solid var(--border);
    }
    .summary-col-label {
      font-size: 11px;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.4px;
      font-weight: 600;
    }
    .summary-arrow-expense { color: var(--danger); }
    .summary-arrow-income { color: var(--success); }
    .summary-col-value {
      font-size: 18px;
      font-weight: 700;
      margin-top: 2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .summary-footer {
      margin-top: 12px;
      padding-top: 10px;
      border-top: 1px solid var(--border);
    }
    .summary-footer .hero-sub { margin-top: 2px; }

    /* ─── Dashboard: cash/card split ─── */
    .cash-card-split {
      margin-top: 12px;
      padding-top: 10px;
      border-top: 1px solid var(--border);
    }
    .cash-card-split-row {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
    }
    .cash-card-split-bar {
      height: 4px;
      margin-top: 6px;
      background: var(--text-secondary);
      border-radius: 2px;
      overflow: hidden;
    }
    .cash-card-split-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 2px;
      transition: width 400ms ease;
    }

    /* ─── Dashboard: analytics CTA ─── */
    .analytics-card {
      margin: 12px 16px 0;
      padding: 16px 20px;
      background: linear-gradient(135deg,
        color-mix(in srgb, var(--accent) 14%, var(--surface)),
        color-mix(in srgb, var(--accent) 4%, var(--surface)));
      border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    }
    .analytics-head {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 12px;
    }
    .analytics-icon { font-size: 28px; }
    .analytics-title {
      font-size: 15px;
      font-weight: 700;
      color: var(--text-primary);
    }
    .analytics-desc {
      font-size: 12px;
      color: var(--text-secondary);
      margin-top: 2px;
    }

    .category-breakdown { padding: 0 20px 12px; }
    .cat-breakdown-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 0;
    }
    .cat-breakdown-icon { font-size: 18px; width: 28px; text-align: center; }
    .cat-breakdown-main { flex: 1; min-width: 0; }
    .cat-breakdown-row {
      display: flex;
      align-items: baseline;
      gap: 8px;
    }
    .cat-breakdown-name {
      flex: 1;
      font-size: 14px;
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .cat-breakdown-bar {
      height: 4px;
      margin-top: 6px;
      background: var(--border);
      border-radius: 2px;
      overflow: hidden;
    }
    .cat-breakdown-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 2px;
      transition: width 400ms ease;
    }
    .cat-breakdown-amount {
      font-size: 14px;
      font-weight: 600;
      flex-shrink: 0;
    }
    .cat-breakdown-pct {
      font-size: 12px;
      color: var(--text-muted);
      width: 36px;
      text-align: right;
      flex-shrink: 0;
    }
    .cat-breakdown-item--clickable {
      cursor: pointer;
      border-radius: 8px;
      transition: background var(--transition);
      -webkit-user-select: none;
      user-select: none;
    }
    .cat-breakdown-item--clickable:active { background: var(--border); }
    .cat-breakdown-item--clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* ─── Members ─── */
    .member-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 20px;
    }
    .member-avatar {
      width: 36px; height: 36px;
      border-radius: 50%;
      background: var(--accent-light);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      font-weight: 700;
      color: var(--accent);
    }
    .member-name { flex: 1; font-size: 14px; font-weight: 500; }
    .member-total-group { display: flex; flex-direction: column; align-items: flex-end; }
    .member-total { font-size: 14px; font-weight: 600; }
    .member-cashcard-breakdown {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
      white-space: nowrap;
    }
    /* Role chip in the Admin tab's Family card — the filter-chip pill,
       one size down and non-interactive. */
    .role-badge {
      padding: 4px 10px;
      border-radius: 20px;
      border: 1.5px solid var(--border);
      background: var(--surface);
      color: var(--text-secondary);
      font-size: 12px;
      font-weight: 600;
      white-space: nowrap;
    }
    .role-badge--owner {
      border-color: var(--accent);
      color: var(--accent);
      background: var(--accent-light);
    }
    /* Owner-only remove control on another member's roster row — same
       affordance as the category list's delete button. */
    .member-remove {
      width: 36px; height: 36px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: var(--danger);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .member-remove:active { background: color-mix(in srgb, var(--danger) 10%, transparent); }
    .member-remove:disabled { opacity: 0.5; cursor: default; }
    /* Rows of the record-transfer picker: a member row that is a choice. */
    .member-row--clickable {
      cursor: pointer;
      -webkit-user-select: none;
      user-select: none;
    }
    .member-row--clickable:active { background: var(--border); }
    .member-row--clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

    /* ─── Filter Tabs ─── */
    .filter-row {
      display: flex;
      gap: 6px;
      padding: 12px 16px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    .filter-chip {
      padding: 8px 14px;
      border-radius: 20px;
      border: 1.5px solid var(--border);
      background: var(--surface);
      color: var(--text-primary);
      font-size: 13px;
      font-weight: 600;
      font-family: inherit;
      cursor: pointer;
      white-space: nowrap;
      transition: all var(--transition);
      -webkit-user-select: none;
      user-select: none;
    }
    .filter-chip:active { transform: scale(0.96); }
    .filter-chip.active {
      background: var(--accent);
      color: var(--tg-theme-button-text-color, #fff);
      border-color: var(--accent);
    }

    /* ─── Daily spending chart (dashboard) ─── */
    /* Chart.js runs with maintainAspectRatio:false so it fills this box —
       the wrapper must therefore have a height of its own, and be positioned
       so the canvas can't feed its own size back into the layout. */
    .chart-wrap {
      position: relative;
      height: 200px;
      padding: 0 12px 14px;
    }
    .daily-spending-canvas { display: block; }

    /* ─── Empty State ─── */
    .empty-state {
      text-align: center;
      padding: 40px 24px;
      color: var(--text-muted);
    }
    .empty-state-icon { font-size: 44px; margin-bottom: 10px; }
    .empty-state-text { font-size: 14px; line-height: 1.5; }

    /* ─── Family Code Banner ─── */
    .family-code-banner {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 12px 16px;
      margin: 12px 16px;
      background: var(--accent-light);
      border-radius: var(--radius);
      border: 1.5px dashed var(--accent);
      cursor: pointer;
      transition: opacity var(--transition);
    }
    .family-code-banner:active { opacity: 0.7; }
    .family-code-value {
      font-size: 22px;
      font-weight: 700;
      letter-spacing: 3px;
      color: var(--accent);
    }

    /* ─── Admin Category List ─── */
    .admin-cat-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 16px;
    }
    .admin-cat-icon { font-size: 22px; }
    .admin-cat-name { flex: 1; font-size: 15px; font-weight: 500; }
    .admin-cat-type {
      width: auto;
      padding: 6px 10px;
      font-size: 13px;
      border-radius: 20px;
    }
    .admin-cat-delete {
      width: 36px; height: 36px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: var(--danger);
      font-size: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .admin-cat-delete:active { background: color-mix(in srgb, var(--danger) 10%, transparent); }

    /* ─── Admin Recurring Payments List ─── */
    .recurring-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 16px;
      transition: background var(--transition);
    }
    .recurring-item--editable { cursor: pointer; }
    .recurring-item--editable:active { background: var(--border); }
    .recurring-cat-icon {
      width: 40px; height: 40px;
      border-radius: 12px;
      background: var(--accent-light);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      flex-shrink: 0;
    }
    .recurring-info { flex: 1; min-width: 0; }
    .recurring-note {
      font-size: 15px;
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .recurring-schedule {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 2px;
    }
    .recurring-amount {
      font-size: 16px;
      font-weight: 700;
      color: var(--text-primary);
      flex-shrink: 0;
    }
    .recurring-delete {
      flex-shrink: 0;
      width: 32px; height: 32px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: var(--danger);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .recurring-delete:active { background: color-mix(in srgb, var(--danger) 10%, transparent); }

    /* ─── Settings Screen ─── */
    .settings-content {
      padding: 16px;
    }

    /* ─── Modal ─── */
    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.5);
      z-index: 300;
      animation: fadeIn 150ms ease;
    }
    .modal-overlay.active { display: flex; align-items: flex-end; justify-content: center; }
    .modal {
      background: var(--bg);
      border-radius: var(--radius-lg) var(--radius-lg) 0 0;
      width: 100%;
      max-height: 90vh;
      overflow-y: auto;
      animation: slideUp 280ms ease;
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    @keyframes slideUp {
      from { transform: translateY(100%); }
      to { transform: translateY(0); }
    }
    .modal-handle {
      width: 36px; height: 4px;
      background: var(--border);
      border-radius: 2px;
      margin: 8px auto;
    }

    /* ─── Tab Bar ─── */
    .tab-bar {
      display: flex;
      background: var(--header-bg);
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .tab-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 6px 0 8px;
      cursor: pointer;
      transition: all var(--transition);
      gap: 2px;
      border: none;
      background: none;
      font-family: inherit;
      -webkit-user-select: none;
      user-select: none;
    }
    .tab-item:active { background: var(--border); }
    .tab-icon {
      line-height: 1;
      display: flex;
      color: var(--text-muted);
      transition: color var(--transition);
    }
    .tab-icon svg { width: 24px; height: 24px; }
    .tab-label { font-size: 10px; font-weight: 600; color: var(--text-muted); }
    .tab-item.active .tab-icon,
    .tab-item.active .tab-label { color: var(--accent); }

    /* ─── Loading ─── */
    .loading {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      flex: 1;
      gap: 16px;
    }
    .spinner {
      width: 32px; height: 32px;
      border: 3px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 600ms linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .loading-text {
      font-size: 14px;
      color: var(--text-secondary);
    }

    /* ─── Toast ─── */
    .toast {
      position: fixed;
      top: calc(env(safe-area-inset-top, 0px) + 20px);
      left: 50%;
      transform: translateX(-50%) translateY(-80px);
      background: var(--text-primary);
      color: var(--bg);
      padding: 12px 20px;
      border-radius: var(--radius);
      font-size: 14px;
      font-weight: 500;
      z-index: 999;
      transition: transform 300ms ease;
      max-width: calc(100vw - 32px);
      text-align: center;
    }
    .toast.show { transform: translateX(-50%) translateY(0); }
    .toast { display: flex; align-items: center; gap: 12px; }
    .toast-action {
      background: none;
      border: none;
      color: var(--accent);
      font-size: 14px;
      font-weight: 600;
      padding: 0;
      cursor: pointer;
      flex-shrink: 0;
    }

    /* ─── Divider ─── */
    .divider {
      height: 1px;
      background: var(--border);
      margin: 0 16px;
    }

    /* ─── Category Picker Grid (modal) ─── */
    .cat-picker-grid {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 8px;
      padding: 4px 16px 12px;
    }
    .cat-picker-btn {
      width: 52px; height: 52px;
      border-radius: 12px;
      border: 2px solid var(--border);
      background: var(--surface);
      font-size: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all var(--transition);
      -webkit-user-select: none;
      user-select: none;
    }
    .cat-picker-btn:active { transform: scale(0.93); }
    .cat-picker-btn.selected {
      border-color: var(--accent);
      background: var(--accent-light);
    }

    /* ─── Entry Modal — compact layout ─── */
    .entry-footer {
      display: flex;
      gap: 8px;
      padding: 8px 20px 24px;
    }

    /* ─── Section Header ─── */
    .section-header {
      padding: 12px 20px 4px;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    /* ─── FAB (Floating Action Button) ─── */
    .fab {
      position: fixed;
      bottom: calc(64px + env(safe-area-inset-bottom, 0) + 16px);
      right: 20px;
      width: 56px;
      height: 56px;
      border-radius: 50%;
      background: var(--accent);
      color: var(--tg-theme-button-text-color, #fff);
      border: none;
      font-size: 28px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.2);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 100;
      transition: all var(--transition);
      -webkit-user-select: none;
      user-select: none;
    }
    .fab:active { transform: scale(0.9); opacity: 0.85; }
    .fab svg { width: 26px; height: 26px; }

    /* ─── Reduced Motion ─── */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
      }
    }
