/*
 * Finanšu pārvaldnieks (BudzetsIMT)
 * Copyright (c) 2026 Mārtiņš Barons. Visas tiesības paturētas.
 * Skatīt LICENSE failu repozitorija saknē.
 */
  :root {
    --ink: #1a1d29;
    --paper: #f7f5f0;
    --card: #ffffff;
    --line: #e4e0d6;
    --muted: #8a8576;
    --green: #4a7c59;
    --amber: #c8923a;
    --red: #b8443a;
    --red-soft: #f7e3e1;
    --plum: #8d6e8f;
    --plum-soft: #f0e7f1;
    --accent: #2d5f4f;
    --shadow: 0 1px 3px rgba(26,29,41,.06), 0 8px 24px rgba(26,29,41,.05);
    /* surfaces */
    --surface-sub: #fbfaf7;      /* subtle raised (name focus, summing bill) */
    --plum-border: #e0d2e1;      /* credit borders */
    --plum-ink: #5e4660;         /* credit text */
    --plum-eur: #9a7d9c;         /* credit euro */
    --entry-bg: #faf8f3;         /* entry sublist bg */
    --cd-bg: #f6eef7;            /* credit detail bg */
    --cd-track: #e4d3e5;         /* credit progress track */
    --badge-yes-bg: #e6f0e8;
    --badge-no-bg: #f3efe6;
    --paid-bg: #f2f6f2;          /* paid bill row */
    --btn-ink: #ffffff;          /* text on accent buttons */
  }
  [data-theme="dark"] {
    --ink: #e8e6e0;
    --paper: #16181d;
    --card: #21242b;
    --line: #363a44;
    --muted: #9a978f;
    --green: #6fae82;
    --amber: #d9a65a;
    --red: #e07268;
    --red-soft: #3a2725;
    --plum: #b493b6;
    --plum-soft: #2c2530;
    --accent: #4f9e84;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --surface-sub: #2a2e36;
    --plum-border: #3d3444;
    --plum-ink: #d4b8d6;
    --plum-eur: #a888aa;
    --entry-bg: #1e2128;
    --cd-bg: #2a2333;
    --cd-track: #3d3444;
    --badge-yes-bg: #24352a;
    --badge-no-bg: #2c2a24;
    --paid-bg: #1d2620;
    --btn-ink: #16181d;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  /* Vieta ritjoslai rezervēta vienmēr — citādi lapa lec, pārslēdzoties
     starp garām (Budžets, Kredīti) un īsām (Atgādinājumi, Uzkrājuma mērķi) sadaļām */
  html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--paper); color: var(--ink); line-height: 1.5;
    padding: 0 0 calc(80px + env(safe-area-inset-bottom));
  }
  .wrap {
    max-width: 1000px; margin: 0 auto;
    padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  }
  /* Rezerves variants pārlūkiem bez scrollbar-gutter atbalsta:
     tukšās sadaļas tiek pastieptas, lai ritjosla nepazustu */
  @supports not (scrollbar-gutter: stable) {
    .panel { min-height: calc(100vh - 120px); }
  }

  /* Setup gate */
  .gate {
    max-width: 540px; margin: 60px auto; background: var(--card);
    border: 1px solid var(--line); border-radius: 16px; padding: 32px;
    box-shadow: var(--shadow);
  }
  .gate h2 { font-family: Georgia, serif; font-size: 22px; margin-bottom: 8px; }
  .gate p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
  .gate label { display:block; font-size: 12px; font-weight: 600; letter-spacing:.06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
  .gate input {
    width: 100%; font: inherit; font-size: 14px; padding: 11px 13px;
    border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
  }
  .gate input:focus { outline: none; border-color: var(--accent); }
  .gate .row { display:flex; gap: 8px; }
  .gate .row input { flex: 1; }
  .gate .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

  /* Splash screen — loading overlay */
  .splash {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--paper) url('splash/splash.png') center / cover no-repeat;
    opacity: 1; transition: opacity .4s ease-out;
  }
  .splash.hidden { opacity: 0; pointer-events: none; }
  .splash-img { display: none; }
  .splash-fallback {
    max-width: 340px; margin: 0 18px; padding: 22px 20px; border-radius: 14px;
    background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
    text-align: center; position: relative; z-index: 10;
  }
  .splash-fallback h3 { font-family: Georgia, serif; font-size: 18px; margin-bottom: 10px; }
  .splash-fallback p { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 0 0 8px; }
  .splash-fallback p:last-child { margin-bottom: 0; }
  .spinner {
    width: 48px; height: 48px; border: 4px solid var(--line);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .8s linear infinite;
    position: relative; z-index: 10;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Compact top bar: hamburger · tēriņa tempa indikators · sync dot, dashed rule below, sticky */
  .topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 0 10px; border-bottom: 1px dashed var(--line); position: sticky; top: 0; z-index: 50; background: var(--paper); }
  .topbar-spacer { flex: 1; }

  /* Spending-pace mini indicator, lives in the topbar: dot + 3 rounded values + info button.
     Height stays within the hamburger button's 34px so the topbar itself never grows. */
  .topbar-pace { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
  .tp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
  .tp-dot.under { background: var(--green); }
  .tp-dot.over { background: var(--red); }
  .tp-val { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
  .tp-sep { width: 1px; height: 12px; background: var(--line); flex: none; }
  .tp-info-btn { border: none; background: transparent; cursor: pointer; padding: 2px; margin-left: 1px; font-size: 12px; line-height: 1; color: var(--muted); opacity: .75; flex: none; }
  .tp-info-btn:hover, .tp-info-btn[aria-expanded="true"] { opacity: 1; color: var(--ink); }
  @media (max-width: 420px) {
    .topbar-pace { gap: 4px; }
    .tp-val { font-size: 11px; }
    .tp-sep { height: 10px; }
  }

  /* Tēriņa tempa detaļu panelis — fiksēts zem topbar, lai nekad neizraisa horizontālu overflow */
  .tp-popover { position: fixed; top: var(--nav-h, 54px); left: 12px; right: 12px; max-width: 340px; margin: 6px auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); z-index: 60; }
  .tp-pop-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 13px; }
  .tp-pop-label { color: var(--muted); }
  .tp-pop-val { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
  .tp-pop-hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; margin: 6px 0; }
  .tp-pop-status { font-size: 11.5px; font-weight: 600; margin: 6px 0 0; }

  .hamburger-btn { border: none; background: transparent; cursor: pointer; padding: 6px; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; margin-left: -6px; flex-shrink: 0; }
  .hamburger-btn:hover { background: var(--card); }
  .hamburger-icon { width: 18px; height: 13px; position: relative; display: block; }
  .hamburger-icon span { position: absolute; left: 0; width: 100%; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .2s ease, opacity .2s ease, top .2s ease; }
  .hamburger-icon span:nth-child(1) { top: 0; }
  .hamburger-icon span:nth-child(2) { top: 5.5px; }
  .hamburger-icon span:nth-child(3) { top: 11px; }
  .hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(1) { top: 5.5px; transform: rotate(45deg); }
  .hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(2) { opacity: 0; }
  .hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(3) { top: 5.5px; transform: rotate(-45deg); }
  @media (prefers-reduced-motion: reduce) { .hamburger-icon span { transition: none; } }

  /* Side drawer (navigation + account), slides in from the left */
  .drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility .25s ease; }
  .drawer-backdrop.open { opacity: 1; visibility: visible; pointer-events: auto; }
  .drawer { position: fixed; top: 0; left: 0; height: 100dvh; width: min(300px, 85vw); background: var(--card); z-index: 91; box-shadow: var(--shadow); transform: translateX(-100%); transition: transform .25s ease; display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); overflow-y: auto; }
  .drawer.open { transform: translateX(0); }
  @media (prefers-reduced-motion: reduce) { .drawer, .drawer-backdrop { transition: none; } }
  .drawer-close { align-self: flex-end; border: none; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; margin-bottom: 6px; }
  .drawer-close:hover { color: var(--ink); }
  .drawer-section { padding: 12px 0; border-bottom: 1px dashed var(--line); }
  .drawer-section:last-child { border-bottom: none; margin-top: auto; padding-bottom: 0; }
  .drawer-nav { display: flex; flex-direction: column; gap: 4px; }
  .drawer-nav-item, .drawer-link { display: block; width: 100%; text-align: left; border: none; background: transparent; cursor: pointer; font: inherit; color: var(--muted); padding: 10px; border-radius: 9px; transition: background .15s, color .15s; }
  .drawer-nav-item { font-size: 17px; font-weight: 700; position: relative; }
  .nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; margin-left: 7px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 2px; }
  .drawer-nav-item:hover, .drawer-link:hover { background: var(--paper); color: var(--ink); }
  .drawer-nav-item.active { color: var(--accent); background: var(--paper); }
  .drawer-link { font-size: 14px; font-weight: 600; }
  .drawer-account { display: flex; flex-direction: column; gap: 10px; }
  .drawer-user { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
  .drawer-user .user-name { font-weight: 700; color: var(--ink); font-size: 14px; margin-right: 0; }
  .sync-status { font-size: 12.5px; color: var(--muted); }
  .drawer-account .signout-btn { align-self: flex-start; margin-left: 10px; }

  /* Static brand line — used in the Settings modal header */
  .brand { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
  .brand .eyebrow { margin-bottom: 0; display: inline; }
  .brand .app-name { font-family: Georgia, 'Times New Roman', serif; font-size: 17px; letter-spacing: -.01em; text-transform: none; color: var(--ink); font-weight: 700; }
  .panel { animation: panelFadeIn .28s ease; }
  @keyframes panelFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  @media (prefers-reduced-motion: reduce) { .panel { animation: none; } }
  .panel.hidden { display: none; }
  .eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
  h1 { font-family: Georgia, 'Times New Roman', serif; font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
  .user-name { font-weight: 600; color: var(--ink); margin-right: 4px; }
  .signout-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 4px 10px; border-radius: 7px; margin-left: 4px; }
  .signout-btn:hover { background: var(--red-soft); color: var(--red); border-color: var(--red-soft); }
  /* Settings modal */
  .set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .set-row:last-child { border-bottom: none; }
  .set-label { font-size: 14px; font-weight: 600; color: var(--ink); }
  .set-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .set-danger { margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
  .set-danger .set-label { color: var(--red); }
  .set-danger .set-row { border-bottom: none; padding-top: 0; }
  .theme-switch { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
  .ts-opt { border: none; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
  .ts-opt:hover:not(.active) { color: var(--ink); }
  .ts-opt.active { background: var(--accent); color: var(--btn-ink); }
  .cl-entry { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .cl-entry:last-child { border-bottom: none; }
  .cl-ver { font-weight: 700; font-size: 14px; }
  .cl-date { font-size: 12px; color: var(--muted); margin-left: 8px; font-weight: 400; }
  .cl-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink); }
  .cl-list li { margin: 3px 0; }
  .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
  .dot.ok { background: var(--green); } .dot.saving { background: var(--amber); } .dot.err { background: var(--red); }

  .summary-wrap { position: relative; margin: 8px 0 28px; }
  .summary-wrap.pinned { position: sticky; top: var(--nav-h, 56px); z-index: 40; }
  .summary-wrap .summary { margin: 0; }
  .summary-pin {
    position: absolute; top: 10px; right: 10px; z-index: 5;
    width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--card); color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0;
    transition: all .15s; box-shadow: var(--shadow);
  }
  .summary-pin:hover { color: var(--ink); border-color: var(--accent); }
  .summary-pin.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 8px 0 28px; box-shadow: var(--shadow); transition: all .15s; }
  .summary.pinned .stat { padding: 8px 12px 7px; }
  .summary.pinned .stat .label { font-size: 9px; margin-bottom: 3px; }
  .summary.pinned .stat .value, .summary.pinned .stat input { font-size: 16px; }
  .summary.pinned .stat .sub { font-size: 10px; margin-top: 2px; }
  .summary-wrap.pinned .summary-pin { top: 6px; right: 6px; width: 22px; height: 22px; }
  .summary-wrap.pinned .summary-pin svg { width: 12px; height: 12px; }
  .stat { background: var(--card); padding: 18px 18px 16px; }
  .stat .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
  .over-badge { display: inline-block; font-size: 12px; color: var(--red); cursor: help; margin-left: 2px; letter-spacing: 0; text-transform: none; }
  .over-badge.hidden { display: none; }
  .stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .stat .value.input-val { display: flex; align-items: baseline; gap: 2px; }
  .stat input { font: inherit; font-size: 26px; font-weight: 700; letter-spacing: -.02em; border: none; background: transparent; width: 100%; color: var(--ink); border-bottom: 2px dashed var(--line); padding: 0 0 2px; font-variant-numeric: tabular-nums; }
  .stat input:focus { outline: none; border-bottom-color: var(--accent); }
  .stat .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .value.pos { color: var(--green); } .value.neg { color: var(--red); }

  .sec-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 14px; }
  .sec-head h2 { font-family: Georgia, serif; font-size: 20px; font-weight: 700; }
  .period-label { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; cursor: pointer; border-radius: 6px; padding: 2px 7px; vertical-align: middle; transition: background .15s, color .15s; }
  .period-label:hover, .period-label:focus-visible { background: var(--card); color: var(--ink); outline: none; }
  .period-label-input { font: inherit; font-size: 13px; font-weight: 400; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; margin-left: 6px; vertical-align: middle; width: 170px; max-width: 50vw; }
  .btn { font: inherit; font-size: 14px; font-weight: 600; border: none; border-radius: 9px; padding: 9px 16px; cursor: pointer; background: var(--accent); color: var(--btn-ink); transition: transform .08s, opacity .15s; }
  .btn:hover { opacity: .9; } .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: .4; cursor: not-allowed; }
  .btn:disabled:hover { opacity: .4; } .btn:disabled:active { transform: none; }
  .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
  .btn.sm { padding: 5px 10px; font-size: 13px; }
  .btn.full { width: 100%; margin-top: 22px; padding: 12px; }
  .btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red-soft); }
  .btn.danger:hover { background: var(--red-soft); }
  .btn.danger:disabled { opacity: .6; cursor: default; }

  .bills { display: flex; flex-direction: column; gap: 6px; }
  .bill { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; display: grid; grid-template-columns: 20px 28px 1fr 110px 70px auto auto; align-items: center; gap: 12px; box-shadow: var(--shadow); transition: opacity .2s, background .2s, box-shadow .15s; }
  .bill .drag-handle { display: flex; align-items: center; justify-content: center; cursor: grab; color: var(--muted); border-left: 4px solid var(--line); padding-left: 4px; height: 30px; touch-action: none; }
  .bill .drag-handle:active { cursor: grabbing; }
  .bill[data-cat="komunalie"] .drag-handle { border-left-color: var(--green); }
  .bill[data-cat="kredits"] .drag-handle { border-left-color: var(--plum); }
  .bill[data-cat="transports"] .drag-handle { border-left-color: var(--amber); }
  .bill[data-cat="abonementi"] .drag-handle { border-left-color: #5b7a99; }
  .bill[data-cat="cits"] .drag-handle { border-left-color: var(--muted); }
  .bill.dragging { opacity: .4; }
  .bill.drag-over { box-shadow: 0 -2px 0 var(--accent), var(--shadow); }
  .bill .pay-check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); background: var(--card); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: all .15s; }
  .bill .pay-check:hover { border-color: var(--green); }
  .bill .pay-check svg { width: 14px; height: 14px; opacity: 0; transition: opacity .15s; }
  .bill.paid { background: var(--paid-bg); }
  .bill.paid .pay-check { background: var(--green); border-color: var(--green); }
  .bill.paid .pay-check svg { opacity: 1; }
  .bill.paid .name, .bill.paid .amount { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(74,124,89,.5); }
  .bill .pay-check-auto { background: var(--green); border-color: var(--green); opacity: .6; cursor: default; }
  .pay-check-auto svg { opacity: 1 !important; }
  .bill .pay-check-auto:hover { border-color: var(--green); }
  .bill .tag-strip { width: 6px; height: 30px; border-radius: 3px; background: var(--line); align-self: center; }
  .bill[data-cat="komunalie"] .tag-strip { background: var(--green); }
  .bill[data-cat="kredits"] .tag-strip { background: var(--plum); }
  .bill[data-cat="transports"] .tag-strip { background: var(--amber); }
  .bill[data-cat="abonementi"] .tag-strip { background: #5b7a99; }
  .bill[data-cat="cits"] .tag-strip { background: var(--muted); }
  .bill .name { border: none; background: transparent; font: inherit; font-size: 15px; font-weight: 500; width: 100%; color: var(--ink); padding: 2px 0; }
  .bill .name:focus { outline: none; background: var(--surface-sub); border-radius: 4px; padding: 2px 6px; margin: 0 -6px; }
  .bill .amount-wrap { display: flex; align-items: center; gap: 3px; justify-content: flex-end; }
  .bill .amount-wrap .eur { color: var(--muted); font-size: 14px; }
  .bill .amount { border: none; background: transparent; font: inherit; font-size: 16px; font-weight: 700; width: 75px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; border-bottom: 1px dashed transparent; }
  .bill .amount:focus { outline: none; border-bottom-color: var(--accent); }
  .bill .amount-ro { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
  .bill .add-entry { border: 1.5px solid var(--accent); background: transparent; color: var(--accent); width: 22px; height: 22px; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center; margin-left: 4px; padding: 0; }
  .bill .add-entry:hover { background: var(--accent); color: #fff; }
  .bill.summing { background: var(--surface-sub); }
  .entries { margin: -4px 0 4px 40px; padding: 6px 12px; background: var(--entry-bg); border: 1px solid var(--line); border-radius: 0 0 10px 10px; border-top: none; }
  .entry-row { display: grid; grid-template-columns: 90px 1fr auto 28px; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
  .entry-row:last-child { border-bottom: none; }
  .entry-date { color: var(--muted); font-variant-numeric: tabular-nums; }
  .entry-note { color: var(--ink); }
  .entry-amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
  .entry-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 5px; border-radius: 5px; }
  .entry-del:hover { background: var(--red-soft); color: var(--red); }
  .entry-empty { font-size: 12px; color: var(--muted); padding: 4px 0; font-style: italic; }
  .limit-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 2px 0 6px; }
  .entries-toggle { display: flex; align-items: center; gap: 6px; border: none; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 3px 6px; margin: -3px 0 -3px -6px; border-radius: 7px; transition: background .15s; min-width: 0; }
  .entries-toggle:hover, .entries-toggle:focus-visible { background: var(--card); }
  .entries-toggle .chevron { flex: none; color: var(--accent); transition: transform .2s ease; }
  .entries-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }
  .entries-list { overflow: hidden; max-height: 1200px; opacity: 1; transition: max-height .25s ease, opacity .2s ease, margin .2s ease; }
  .entries-list.collapsed { max-height: 0; opacity: 0; }
  @media (prefers-reduced-motion: reduce) { .entries-toggle .chevron, .entries-list { transition: none; } }
  .limit-label { font-size: 12.5px; color: var(--muted); }
  .limit-label strong { color: var(--ink); font-variant-numeric: tabular-nums; }
  .limit-label .over { color: var(--red); font-weight: 600; }
  .limit-edit { border: none; background: transparent; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 0; white-space: nowrap; }
  .limit-edit:hover { opacity: .75; }
  .limit-track { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
  .limit-fill { height: 100%; border-radius: 4px; transition: width .3s; }
  .bill .pct { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
  .bill select { font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 6px; background: var(--card); color: var(--muted); cursor: pointer; }
  .bill select:focus { outline: none; border-color: var(--accent); }
  .bill .del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
  .bill .del:hover { background: var(--red-soft); color: var(--red); }

  .bills-foot { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 14px 4px; margin-top: 4px; border-top: 2px solid var(--line); }
  .bills-foot .lbl { font-weight: 700; font-size: 15px; }
  .bills-foot .total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

  .credits { display: flex; flex-direction: column; gap: 8px; }
  .credit { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; display: grid; grid-template-columns: 20px 1fr 120px auto; align-items: center; gap: 12px; box-shadow: var(--shadow); transition: opacity .2s, background .2s, box-shadow .15s; }
  .credit .cdrag { display: flex; align-items: center; justify-content: center; cursor: grab; color: var(--muted); border-left: 4px solid var(--line); padding-left: 4px; height: 30px; touch-action: none; }
  .credit .cdrag:active { cursor: grabbing; }
  .credit.dragging { opacity: .4; }
  .credit.drag-over { box-shadow: 0 -2px 0 var(--accent), var(--shadow); }
  .credit input.cname { border: none; background: transparent; font: inherit; font-size: 15px; font-weight: 500; color: var(--ink); width: 100%; padding: 2px 0; }
  .credit input.cname:focus { outline: none; background: var(--surface-sub); border-radius: 4px; padding: 2px 6px; margin: 0 -6px; }
  .credit .camount-wrap { display: flex; align-items: center; gap: 3px; justify-content: flex-end; }
  .credit .camount { border: none; background: transparent; font: inherit; font-size: 16px; font-weight: 700; width: 75px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; border-bottom: 1px dashed transparent; }
  .credit .camount:focus { outline: none; border-bottom-color: var(--accent); }
  .credit-detail { margin: -4px 0 4px 34px; padding: 6px 12px; background: var(--entry-bg); border: 1px solid var(--line); border-radius: 0 0 10px 10px; border-top: none; }
  .cd-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 2px 0 6px; }
  .cd-label { font-size: 12.5px; color: var(--muted); }
  .cd-label strong { color: var(--ink); font-variant-numeric: tabular-nums; }
  .cd-muted { color: var(--muted); }
  .cd-edit { border: none; background: transparent; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 0; white-space: nowrap; }
  .cd-edit:hover { opacity: .75; }
  .cd-track { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
  .cd-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
  .cd-pay-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0 2px; margin-top: 4px; border-top: 1px dashed var(--line); }
  .cd-pay-label { font-size: 12.5px; color: var(--ink); font-weight: 600; }
  .cd-pay-controls { display: flex; align-items: center; gap: 6px; }
  .cd-pay-btn { width: 26px; height: 26px; border-radius: 7px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-size: 18px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
  .cd-pay-btn:hover:not(:disabled) { background: var(--accent); color: var(--btn-ink); }
  .cd-pay-btn:disabled { opacity: .35; cursor: not-allowed; }
  .cd-pay-amt-wrap { display: flex; align-items: center; gap: 2px; }
  .cd-pay-eur { color: var(--muted); font-size: 13px; }
  .cd-pay-amt { width: 68px; text-align: right; border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 700; color: var(--ink); border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
  .cd-pay-amt:focus { outline: none; border-bottom-color: var(--accent); }
  .credit .eur { color: var(--muted); }
  .credit .del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
  .credit .del:hover { background: var(--red-soft); color: var(--red); }
  .credits-foot { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 14px 4px; margin-top: 4px; border-top: 2px solid var(--line); }
  .credits-foot .lbl, .credits-foot span:first-child { font-weight: 700; font-size: 15px; }
  .credits-foot .total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .credits-foot-sub { border-top: none; padding-top: 4px; margin-top: 0; font-weight: 600; font-size: 13px; color: var(--muted); }
  .credits-foot-sub .total { font-size: 13px; font-weight: 600; color: var(--muted); }

  /* ---- Papildus ienākumi ---- */
  .extra-income-list { display: flex; flex-direction: column; gap: 8px; }
  .extra-income-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 8px; display: grid; grid-template-columns: minmax(90px,116px) minmax(0,1fr) minmax(52px,72px) auto; align-items: center; gap: 6px; box-shadow: var(--shadow); }
  .extra-income-row input.eidate { border: none; background: transparent; font: inherit; font-size: 12.5px; color: var(--ink); width: 100%; min-width: 0; padding: 6px 0; }
  .extra-income-row input.eidate:focus { outline: none; background: var(--surface-sub); border-radius: 4px; padding: 6px; margin: 0 -6px; }
  .extra-income-row input.einame { border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink); width: 100%; min-width: 0; padding: 2px 0; overflow: hidden; text-overflow: ellipsis; }
  .extra-income-row input.einame:focus { outline: none; background: var(--surface-sub); border-radius: 4px; padding: 2px 6px; margin: 0 -6px; }
  .extra-income-row .eamount-wrap { display: flex; align-items: center; gap: 2px; justify-content: flex-end; min-width: 0; }
  .extra-income-row .eamount-wrap .eur { color: var(--muted); font-size: 12px; }
  .extra-income-row .eamount { border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 700; width: 100%; min-width: 0; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; border-bottom: 1px dashed transparent; }
  .extra-income-row .eamount:focus { outline: none; border-bottom-color: var(--accent); }
  .extra-income-row .del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 4px 4px; border-radius: 6px; }
  .extra-income-row .del:hover { background: var(--red-soft); color: var(--red); }
  .extra-income-foot { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 14px 4px; margin-top: 4px; border-top: 2px solid var(--line); }
  .extra-income-foot .lbl, .extra-income-foot span:first-child { font-weight: 700; font-size: 15px; }
  .extra-income-foot .total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

  .grid2 { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: start; }
  section { margin-top: 36px; }
  .bar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 14px; }
  .bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease, background .3s; }
  /* Category breakdown */
  .cat-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); margin-top: 8px; display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: center; }
  .donut { position: relative; width: 200px; height: 200px; margin: 0 auto; -webkit-tap-highlight-color: transparent; }
  .donut svg { transform: rotate(-90deg); touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
  .donut .center .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .donut .center .small { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
  .donut svg circle.donut-seg { cursor: pointer; transition: opacity .12s ease; }
  .donut svg circle.donut-seg.dimmed { opacity: .35; }
  .donut-tooltip { position: absolute; top: -6px; left: 50%; pointer-events: none; display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow); z-index: 5; transform: translate(-50%, -100%); }
  .donut-tooltip.hidden { display: none; }
  .donut-tooltip .dt-swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
  .donut-tooltip .dt-name { font-weight: 700; color: var(--ink); }
  .donut-tooltip .dt-amt { color: var(--muted); }
  .cat-legend { display: flex; flex-direction: column; gap: 4px; }
  .cat-row { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
  .cat-row:last-child { border-bottom: none; }
  .cat-swatch { width: 14px; height: 14px; border-radius: 4px; }
  .cat-name { font-size: 14px; font-weight: 600; }
  .cat-amount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .cat-pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
  .cat-bar-row { margin-top: 6px; }
  .cat-bar-track { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 5px; }
  .cat-bar-fill { height: 100%; border-radius: 4px; }
  @media (max-width: 760px) { .cat-wrap { grid-template-columns: 1fr; gap: 20px; } }

  .toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 28px; }
  .saved-note { font-size: 12px; color: var(--muted); margin-left: auto; }
  .hidden { display: none !important; }

  /* Archive */
  .archive-list { display: flex; flex-direction: column; gap: 8px; }
  .arch-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 14px; box-shadow: var(--shadow); }
  .arch-month { font-weight: 700; font-size: 15px; }
  .arch-sub { font-size: 12px; color: var(--muted); }
  .arch-figure { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
  .arch-figure .lbl { display:block; font-size: 10px; letter-spacing:.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
  .arch-figure.rem-pos { color: var(--green); } .arch-figure.rem-neg { color: var(--red); }
  .arch-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .empty-note { color: var(--muted); font-size: 14px; padding: 20px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }

  /* Trends — visi trīs "Tendences" grafiki (atlikums / ien.vs izd. / kategorijas) */
  #trendsCharts { display: flex; flex-direction: column; gap: 20px; }
  .trends-chart-wrap { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px 16px; box-shadow: var(--shadow); overflow-x: auto; }
  .trends-chart { display: block; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
  .trend-zero-line { stroke: var(--line); stroke-width: 1; }
  .trend-bar-pos { fill: var(--green); }
  .trend-bar-neg { fill: var(--red); }
  .trend-seg { stroke: var(--card); stroke-width: 1; cursor: pointer; transition: opacity .12s ease, filter .12s ease; }
  .trend-seg.dim { opacity: .3; }
  .trend-seg.lit { filter: brightness(1.15); }
  .trend-amount { font-size: 11px; font-weight: 700; fill: var(--ink); text-anchor: middle; font-variant-numeric: tabular-nums; }
  .trend-amount-sm { font-size: 9.5px; }
  .trend-label { font-size: 11px; fill: var(--muted); text-anchor: middle; }
  .trends-mini-legend { display: flex; gap: 18px; margin-bottom: 12px; }
  .trends-mini-legend .cat-row { display: flex; align-items: center; gap: 6px; padding: 0; border-bottom: none; }
  .trend-swatch-pos { background: var(--green); }
  .trend-swatch-neg { background: var(--red); }
  .trends-cat-legend .cat-row { cursor: pointer; transition: opacity .12s ease; }
  .trends-cat-legend .cat-row.dim { opacity: .4; }
  .trends-cat-legend .cat-row.lit .cat-name { font-weight: 800; }
  .trends-daily-select { font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); }
  .trend-swatch-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--amber); flex: none; }
  .trends-daily-hint { font-size: 11.5px; color: var(--muted); margin: -4px 0 10px; }
  /* fill iestatīts individuāli caur JS (setAttribute) katram segmentam pēc
     kategorijas krāsas — TE NEDRĪKST likt `fill`, jo CSS klase uzvarētu pār
     SVG presentation atribūtu un pārrakstītu visas kategoriju krāsas uz vienu. */
  .daily-bar { stroke: var(--card); stroke-width: .5; cursor: pointer; transition: filter .12s ease; }
  .daily-bar:hover { filter: brightness(1.15); }
  .daily-trend-line { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .trend-daily-tooltip { flex-direction: column; align-items: flex-start; gap: 4px; white-space: normal; max-width: 220px; z-index: 6; }
  .trend-daily-tooltip .tdt-head { display: flex; align-items: center; gap: 6px; }
  .trend-daily-tooltip .tdt-items { font-size: 11px; color: var(--muted); line-height: 1.4; }
  #trendsCatLegendToggle { margin-top: 10px; }
  .trends-cat-legend { margin-top: 16px; }

  /* ---- Reminder banner (visible above panels when something is due today/overdue) ---- */
  .reminder-banner { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--red); border-left: 4px solid var(--red); border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; box-shadow: var(--shadow); }
  .reminder-banner .rb-icon { font-size: 16px; line-height: 1; }
  .reminder-banner .rb-text { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink); }
  .reminder-banner .rb-view { border: 1px solid var(--red); background: transparent; color: var(--red); font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
  .reminder-banner .rb-view:hover { background: var(--red); color: #fff; }
  .reminder-banner .rb-dismiss { border: none; background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 6px; line-height: 1; }
  .reminder-banner .rb-dismiss:hover { background: var(--red-soft); color: var(--red); }
  /* Neitrāla (nesteidzīga) baneru versija — piem. jauna mēneša atgādinājumam, kas nav "kavēts" tāpat kā rēķini */
  .reminder-banner.info { border-color: var(--accent); border-left-color: var(--accent); }
  .reminder-banner.info .rb-view { border-color: var(--accent); color: var(--accent); }
  .reminder-banner.info .rb-view:hover { background: var(--accent); color: #fff; }
  .reminder-banner.info .rb-dismiss:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }

  /* ---- Reminders section ---- */
  .rem-group { margin-bottom: 18px; }
  .rem-group.hidden { display: none; }
  .rem-group-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
  .rem-group-title-due { color: var(--red); }
  .rem-list { display: flex; flex-direction: column; gap: 8px; }
  .rem-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
  .rem-row.due { border-color: var(--red); border-left: 4px solid var(--red); }
  .rem-row.paused { opacity: .55; }
  .rem-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .rem-name { font-size: 14.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rem-sub { font-size: 12px; color: var(--muted); }
  .rem-sub.due-text { color: var(--red); font-weight: 600; }
  .rem-toggle, .rem-del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 8px; border-radius: 7px; white-space: nowrap; }
  .rem-toggle:hover { background: var(--paper); color: var(--ink); }
  .rem-del { font-size: 18px; line-height: 1; padding: 4px 6px; }
  .rem-del:hover { background: var(--red-soft); color: var(--red); }
  .rem-type-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
  .rem-type-btn { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; padding: 10px; border-radius: 9px; cursor: pointer; }
  .rem-type-btn.active { border-color: var(--accent); color: var(--accent); background: var(--paper); }

  /* ---- Uzkrājuma mērķi section ---- */
  .goal-list { display: flex; flex-direction: column; gap: 8px; }
  .goal-group { margin-top: 22px; }
  .goal-group.hidden { display: none; }
  .goal-group-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
  .goal-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 40px 12px 14px; box-shadow: var(--shadow); }
  .goal-card.achieved { opacity: .8; }
  .goal-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .goal-name { font-size: 14.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .goal-sub { font-size: 12px; color: var(--muted); }
  .goal-track { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 6px; }
  .goal-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
  .goal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
  .goal-status.paid { color: var(--green); font-weight: 600; }
  .goal-del { position: absolute; top: 10px; right: 10px; border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
  .goal-del:hover { background: var(--red-soft); color: var(--red); }
  .goal-months-toggle { flex-wrap: wrap; }
  .goal-months-toggle .rem-type-btn { flex: 1 1 60px; }
  .goal-ag-preview { font-size: 13px; color: var(--muted); margin-top: 12px; min-height: 18px; }
  .bill .del-locked, .bill .del-locked:hover { cursor: default; color: var(--muted); background: transparent; font-size: 14px; }

  .modal-back { position: fixed; inset: 0; background: rgba(26,29,41,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
  .modal { background: var(--paper); border-radius: 16px; padding: 28px; max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
  #setBack .modal { border: 1px dotted var(--line); }
  .modal input[type=text], .modal input[type=number], .modal input[type=date], .modal input:not([type]) { color: var(--ink); background: var(--card) !important; border-color: var(--line) !important; }
  .modal input::placeholder { color: var(--muted); }
  [data-theme="dark"] .modal input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.6); }
  .modal h3 { font-family: Georgia, serif; font-size: 22px; margin-bottom: 4px; }
  .modal-doc { max-width: 720px; }
  .doc-frame { display: block; width: 100%; height: min(65vh, 640px); margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f7f5f0; }
  .arch-name-edit { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
  .arch-name-edit input { flex: 1; font-family: Georgia, serif; font-size: 22px; font-weight: 700; border: none; border-bottom: 2px dashed var(--line); background: transparent; color: var(--ink); padding: 2px 0; }
  .arch-name-edit input:focus { outline: none; border-bottom-color: var(--accent); }
  .arch-name-edit .save-name { font-size: 13px; white-space: nowrap; }
  .arch-name-edit .save-name.dirty { background: var(--accent); color: #fff; }

  /* Editable archive modal */
  .m-savebar { position: sticky; bottom: -28px; margin: 18px -28px -28px; padding: 16px 28px; background: var(--paper); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
  .m-savebar .spacer { flex: 1; }
  .m-savebar .status { font-size: 13px; color: var(--muted); }
  .m-income { display: flex; align-items: center; gap: 6px; }
  .m-income input { width: 110px; font: inherit; font-size: 18px; font-weight: 700; text-align: right; border: none; border-bottom: 1px dashed var(--line); background: transparent; color: var(--ink); font-variant-numeric: tabular-nums; }
  .m-income input:focus { outline: none; border-bottom-color: var(--accent); }
  .ebill { display: grid; grid-template-columns: 18px 24px 1fr auto 92px auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .ebill .ehandle { cursor: grab; color: var(--muted); display: flex; align-items: center; touch-action: none; border-left: 3px solid var(--line); padding-left: 5px; height: 26px; }
  .ebill[data-cat="komunalie"] .ehandle { border-left-color: var(--green); }
  .ebill[data-cat="kredits"] .ehandle { border-left-color: var(--plum); }
  .ebill[data-cat="transports"] .ehandle { border-left-color: var(--amber); }
  .ebill[data-cat="abonementi"] .ehandle { border-left-color: #5b7a99; }
  .ebill[data-cat="cits"] .ehandle { border-left-color: var(--muted); }
  .ebill.dragging { opacity: .4; } .ebill.drag-over { box-shadow: 0 -2px 0 var(--accent); }
  .ebill .echk { width: 20px; height: 20px; border-radius: 5px; border: 2px solid var(--line); background: var(--card); cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; }
  .ebill .echk svg { width: 12px; height: 12px; opacity: 0; }
  .ebill.paid .echk { background: var(--green); border-color: var(--green); }
  .ebill.paid .echk svg { opacity: 1; }
  .ebill .echk-auto { background: var(--green); border-color: var(--green); opacity: .6; cursor: default; }
  .echk-auto svg { opacity: 1 !important; }
  .ebill .ename { border: none; background: transparent; font: inherit; font-size: 14px; width: 100%; color: var(--ink); }
  .ebill .ename:focus { outline: none; background: var(--surface-sub); border-radius: 4px; }
  .ebill .eamt { border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 700; width: 82px; text-align: right; color: var(--ink); border-bottom: 1px dashed transparent; font-variant-numeric: tabular-nums; }
  .ebill .eamt:focus { outline: none; border-bottom-color: var(--accent); }
  .eamt-wrap { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
  .eamt-wrap .e-eur { color: var(--muted); font-size: 13px; }
  .ebill .ecat { font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; background: var(--card); color: var(--muted); }
  .ebill .edel { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px; padding: 2px 6px; border-radius: 5px; }
  .ebill .edel:hover { background: var(--red-soft); color: var(--red); }
  .ecredit { display: grid; grid-template-columns: 1fr 92px auto; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
  .ecredit input { border: none; background: transparent; font: inherit; font-size: 14px; color: var(--ink); width: 100%; }
  .ecredit .ec-name { font-weight: 600; } .ecredit .ec-amt { font-weight: 700; text-align: right; border-bottom: 1px dashed transparent; font-variant-numeric: tabular-nums; width: 82px; }
  .ecredit input:focus { outline: none; }
  .ecredit-foot { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0 2px; margin-top: 4px; border-top: 2px solid var(--line); font-weight: 700; font-size: 14px; }
  .ecredit-foot .ec-total { font-variant-numeric: tabular-nums; }
  .add-line { margin-top: 8px; }
  /* Category manager */
  .cat-mgr-row { display: grid; grid-template-columns: 44px 1fr auto auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .cat-mgr-row input[type=color] { width: 40px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; padding: 2px; }
  .cat-mgr-row .cm-name { border: none; background: transparent; font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); border-bottom: 1px dashed var(--line); padding: 3px 0; }
  .cat-mgr-row .cm-name:focus { outline: none; border-bottom-color: var(--accent); }
  .cat-mgr-row .cm-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
  .cat-mgr-row .cm-del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; padding: 2px 8px; border-radius: 6px; }
  .cat-mgr-row .cm-del:hover { background: var(--red-soft); color: var(--red); }
  .cat-mgr-row .cm-del:disabled { opacity: .3; cursor: not-allowed; }
  .cat-mgr-row .cm-del:disabled:hover { background: transparent; color: var(--muted); }
  /* Locked (view-only) state */
  .modal.locked input, .modal.locked select { pointer-events: none; border-bottom-color: transparent !important; background: transparent !important; -webkit-appearance: none; appearance: none; }
  .modal.locked select { color: var(--muted); }
  .modal.locked .ehandle { cursor: default; pointer-events: none; opacity: .55; }
  .modal.locked .echk { pointer-events: none; }
  .modal.locked .edel, .modal.locked .add-line, .modal.locked .entry-del { display: none; }
  .modal.locked .m-income input { border-bottom-color: transparent; }
  .modal .msub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
  .nm-list { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow-y: auto; margin: 4px 0 16px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
  .nm-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 7px; cursor: pointer; transition: background .15s; }
  .nm-row:hover { background: var(--card); }
  .nm-row input[type="checkbox"] { flex: none; width: 17px; height: 17px; accent-color: var(--accent); }
  .nm-name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nm-amt { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); font-size: 13px; }
  .nm-archive-opt { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
  .nm-archive-opt input { accent-color: var(--accent); }
  .nm-type-confirm { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
  .nm-type-confirm label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
  .nm-type-confirm input { width: 100%; font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); }
  .nm-type-confirm input:focus { outline: none; border-color: var(--accent); }
  .modal-close { float: right; border: none; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
  .mini-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
  .mini-summary .ms { background: var(--card); padding: 12px 14px; }
  .mini-summary .ms .l { font-size: 10px; letter-spacing:.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
  .mini-summary .ms .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
  .modal-bill { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
  .modal-bill:last-child { border-bottom: none; }
  .modal-bill .mb-amt { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
  .pay-badge { font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
  .pay-badge.yes { background: var(--badge-yes-bg); color: var(--green); }
  .pay-badge.no { background: var(--badge-no-bg); color: var(--muted); }
  .epaid-info { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
  .epaid-info .edate { border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--muted); font: inherit; font-size: 11px; padding: 2px 4px; }
  .epaid-info .edate:focus { outline: none; border-color: var(--accent); color: var(--ink); }
  @media (max-width: 620px) {
    .sec-head { flex-wrap: wrap; row-gap: 8px; }
    .sec-head > div { flex-wrap: wrap; }
    .ebill { grid-template-columns: 16px 22px minmax(60px,1fr) auto 74px auto; gap: 6px; }
    .ebill .pay-badge { font-size: 10px; padding: 2px 6px; }
    .ebill .ename { font-size: 13px; }
    .ebill .eamt { width: 66px; font-size: 13px; }
    .ebill .ecat { max-width: 84px; }

    .arch-row {
      grid-template-columns: 1fr auto auto;
      row-gap: 10px;
      padding: 12px 14px;
    }
    .arch-row > div:nth-child(1) { grid-column: 1; grid-row: 1; }
    .arch-row > div:nth-child(2) { grid-column: 2; grid-row: 1; }
    .arch-row > div:nth-child(3) { grid-column: 3; grid-row: 1; }
    .arch-row > .arch-actions {
      grid-column: 1 / -1;
      grid-row: 2;
      justify-content: flex-start;
      padding-top: 10px;
      border-top: 1px dashed var(--line);
    }
    .arch-month { font-size: 14px; }
    .arch-sub { font-size: 11px; }
    .arch-figure { font-size: 13px; }
    .arch-figure .lbl { font-size: 9px; }
    .arch-actions .btn { font-size: 12px; padding: 6px 10px; }
  }

  @media (max-width: 760px) {
    .drawer-nav-item { font-size: 16px; }
    .summary { grid-template-columns: repeat(2, 1fr); }
    .grid2 { grid-template-columns: 1fr; gap: 28px; }
    .bill { grid-template-columns: 20px 28px 1fr auto auto; row-gap: 6px; column-gap: 10px; }
    .bill .drag-handle { grid-column: 1; grid-row: 1 / 3; height: 100%; }
    .bill .pay-check { grid-column: 2; grid-row: 1; }
    .bill .name { grid-column: 3; grid-row: 1; }
    .bill .amount-wrap { grid-column: 4; grid-row: 1; }
    .bill .del { grid-column: 5; grid-row: 1; }
    .bill .pct { grid-column: 3; grid-row: 2; text-align: left; }
    .bill select { grid-column: 4 / 6; grid-row: 2; }
    .stat .value, .stat input { font-size: 22px; }
  }

  @media (max-width: 420px) {
    .extra-income-row { grid-template-columns: minmax(78px,98px) minmax(0,1fr) minmax(44px,60px) auto; gap: 4px; padding: 4px 6px; }
    .extra-income-row input.eidate { font-size: 11px; }
    .extra-income-row input.einame { font-size: 13px; }
    .extra-income-row .eamount { font-size: 13px; }
  }
