  :root {
    color-scheme: light;
    --page: #f8f8fb;
    --surface: #fdfdfe;
    --surface-raised: #ffffff;
    --text-primary: #0e0e14;
    --text-secondary: #55555f;
    --text-muted: #8b8b94;
    --border: rgba(14, 14, 20, 0.09);
    --gridline: #e5e4ee;
    --good: #10b981;
    --warning: #f59e0b;
    --serious: #f97316;
    --critical: #ef4444;
    --accent: #361680;
    --accent-2: #7c3aed;
    --accent-dark: #240f57;
    --accent-soft: rgba(54, 22, 128, 0.10);
    --accent-track: #ede9fe;
    --accent-gradient: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    --shadow-xs: 0 1px 2px rgba(14, 14, 20, 0.05);
    --shadow-sm: 0 2px 4px rgba(14, 14, 20, 0.06), 0 1px 2px rgba(14, 14, 20, 0.04);
    --shadow: 0 4px 12px rgba(14, 14, 20, 0.06), 0 1px 3px rgba(14, 14, 20, 0.04);
    --shadow-md: 0 8px 24px rgba(54, 22, 128, 0.09), 0 2px 6px rgba(14, 14, 20, 0.04);
    --shadow-lg: 0 16px 36px rgba(54, 22, 128, 0.14), 0 4px 10px rgba(14, 14, 20, 0.05);
    --shadow-hover: 0 12px 28px rgba(54, 22, 128, 0.15), 0 3px 8px rgba(14, 14, 20, 0.05);
    --shadow-table: 0 4px 16px rgba(14, 14, 20, 0.06), 0 1px 3px rgba(14, 14, 20, 0.04);
    --radius: 14px;
    --backdrop: rgba(14, 14, 20, 0.35);
    --chart-paid: #10b981;
    --chart-pending: var(--critical);
    --chart-tagged: #3b82f6;
    --chart-untagged: #f97316;
    --chart-1: #3b82f6;
    --chart-2: #f97316;
    --chart-3: #10b981;
    --chart-4: #8b5cf6;
    --chart-5: #ec4899;
    --chart-6: #06b6d4;
    --chart-7: #eab308;
    --chart-8: #ef4444;
    --chart-other: #64748b;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --page: #0c0c12;
      --surface: #17171f;
      --surface-raised: #1e1e28;
      --text-primary: #f7f7fb;
      --text-secondary: #c2c1cf;
      --text-muted: #8f8e9c;
      --border: rgba(255, 255, 255, 0.10);
      --gridline: #2b2b38;
      --good: #34d399;
      --warning: #fbbf24;
      --serious: #fb923c;
      --critical: #fb7185;
      --accent: #a78bfa;
      --accent-2: #c4b5fd;
      --accent-dark: #ddd6fe;
      --accent-soft: rgba(167, 139, 250, 0.16);
      --accent-track: #4c1d95;
      --accent-gradient: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
      --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
      --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
      --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
      --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
      --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.65);
      --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.6);
      --shadow-table: 0 6px 20px rgba(0, 0, 0, 0.45);
      --backdrop: rgba(0, 0, 0, 0.6);
      --chart-paid: #34d399;
      --chart-pending: var(--critical);
      --chart-tagged: #60a5fa;
      --chart-untagged: #fb923c;
      --chart-1: #60a5fa;
      --chart-2: #fb923c;
      --chart-3: #34d399;
      --chart-4: #a78bfa;
      --chart-5: #f472b6;
      --chart-6: #22d3ee;
      --chart-7: #facc15;
      --chart-8: #f87171;
      --chart-other: #94a3b8;
      --sb-text: #e2e1ec;
      --sb-text-dim: #9896ab;
      --sb-border: rgba(255, 255, 255, 0.08);
      --sb-card-bg: rgba(255, 255, 255, 0.04);
      --sb-hover-bg: rgba(167, 139, 250, 0.15);
      --sb-hover-text: #ddd6fe;
      --sb-bg: linear-gradient(180deg, #12121c 0%, #161624 100%);
      --sb-nav-bg: #1a1a26;
      --sb-nav-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0c0c12;
    --surface: #17171f;
    --surface-raised: #1e1e28;
    --text-primary: #f7f7fb;
    --text-secondary: #c2c1cf;
    --text-muted: #8f8e9c;
    --border: rgba(255, 255, 255, 0.10);
    --gridline: #2b2b38;
    --good: #34d399;
    --warning: #fbbf24;
    --serious: #fb923c;
    --critical: #fb7185;
    --accent: #a78bfa;
    --accent-2: #c4b5fd;
    --accent-dark: #ddd6fe;
    --accent-soft: rgba(167, 139, 250, 0.16);
    --accent-track: #4c1d95;
    --accent-gradient: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.65);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.6);
    --shadow-table: 0 6px 20px rgba(0, 0, 0, 0.45);
    --backdrop: rgba(0, 0, 0, 0.55);
    --chart-paid: #34d399;
    --chart-pending: var(--critical);
    --chart-tagged: #60a5fa;
    --chart-untagged: #fb923c;
    --chart-1: #60a5fa;
    --chart-2: #fb923c;
    --chart-3: #34d399;
    --chart-4: #a78bfa;
    --chart-5: #f472b6;
    --chart-6: #22d3ee;
    --chart-7: #facc15;
    --chart-8: #f87171;
    --chart-other: #94a3b8;
    --sb-text: #e2e1ec;
    --sb-text-dim: #9896ab;
    --sb-border: rgba(255, 255, 255, 0.08);
    --sb-card-bg: rgba(255, 255, 255, 0.04);
    --sb-hover-bg: rgba(167, 139, 250, 0.15);
    --sb-hover-text: #ddd6fe;
    --sb-bg: linear-gradient(180deg, #12121c 0%, #161624 100%);
    --sb-nav-bg: #1a1a26;
    --sb-nav-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  }

  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--page);
    color: var(--text-primary);
    font-family: "Segoe UI", system-ui, -apple-system, 'Noto Sans Devanagari', Tahoma, Arial, sans-serif;
  }
  a { color: inherit; }
  code, .mono { font-family: 'IBM Plex Mono', monospace; }

  .shell { display: flex; align-items: flex-start; min-height: 100vh; }

  /* ---------- Sidebar (theme-aware, responsive) ---------- */
  .sidebar {
    --sb-text: #3f3d56;
    --sb-text-dim: #6b6880;
    --sb-border: rgba(54, 22, 128, 0.10);
    --sb-card-bg: rgba(54, 22, 128, 0.04);
    --sb-hover-bg: rgba(124, 58, 237, 0.10);
    --sb-hover-text: #361680;
    --sb-bg: linear-gradient(180deg, #ffffff 0%, #f5f3ff 100%);
    --sb-nav-bg: #ffffff;
    --sb-nav-shadow: 0 1px 2px rgba(54, 22, 128, 0.05);
    width: 270px;
    flex: 0 0 270px;
    min-height: 100vh;
    background: var(--sb-bg);
    color: var(--sb-text);
    border-right: 1px solid var(--sb-border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
    transition: background 0.2s ease, border-color 0.2s ease;
  }
  .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--sb-text);
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--sb-border);
    margin-bottom: 12px;
  }
  .sidebar .brand .mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--accent-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 26px;
    box-shadow: 0 4px 10px rgba(54, 22, 128, 0.35);
  }
  .sidebar .brand .mark svg { width: 15px; height: 15px; }
  .sidebar nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 6px 12px;
    padding: 8px 10px;
    background: var(--sb-nav-bg);
    border: 1px solid var(--sb-border);
    border-radius: 14px;
    box-shadow: var(--sb-nav-shadow);
    color: var(--sb-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .sidebar > nav > a.nav-link { font-size: 15px; margin: 2px 12px 10px; }
  .nav-icon-badge {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-track);
    color: var(--accent);
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .sidebar nav a.nav-link svg { width: 16px; height: 16px; flex: 0 0 16px; }
  .nav-label { overflow: hidden; text-overflow: ellipsis; }
  .sidebar nav a.nav-link:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(54, 22, 128, 0.14); }
  .sidebar nav a.nav-link:hover .nav-icon-badge { background: var(--accent); color: #fff; }
  .sidebar nav a.nav-link.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(54, 22, 128, 0.28);
  }
  .sidebar nav a.nav-link.active .nav-icon-badge { background: rgba(255, 255, 255, 0.2); color: #fff; }

  .nav-group { margin: 0; }
  .nav-group summary.nav-group-label {
    display: flex;
    align-items: center;
    gap: 12px;
    list-style: none;
    cursor: pointer;
    margin: 6px 12px;
    padding: 8px 10px;
    background: var(--sb-nav-bg);
    border: 1px solid var(--sb-border);
    border-radius: 14px;
    box-shadow: var(--sb-nav-shadow);
    white-space: nowrap;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  }
  .nav-group summary.nav-group-label:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(54, 22, 128, 0.14); }
  .nav-group[open] > summary.nav-group-label { border-color: var(--accent); }
  .nav-group summary.nav-group-label .nav-group-icon-box {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-track);
    color: var(--accent);
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .nav-group[open] > summary .nav-group-icon-box { background: var(--accent); color: #fff; }
  .nav-group summary.nav-group-label .nav-group-bar {
    flex: 1;
    min-width: 0;
    color: var(--sb-text);
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-group summary.nav-group-label span { overflow: hidden; text-overflow: ellipsis; }
  .nav-group summary.nav-group-label::-webkit-details-marker { display: none; }
  .nav-group-toggle { position: relative; flex: 0 0 12px; width: 12px; height: 12px; }
  .nav-group-toggle::before, .nav-group-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    background: currentColor;
    transform: translate(-50%, -50%);
  }
  .nav-group-toggle::before { width: 12px; height: 2px; }
  .nav-group-toggle::after { width: 2px; height: 12px; transition: opacity 0.15s ease; }
  .nav-group[open] > summary .nav-group-toggle::after { opacity: 0; }
  .sidebar .nav-group a.nav-link { margin-left: 20px; margin-right: 12px; }
  .nav-group > .nav-link {
    /* Overrides the browser's native details-closed hiding (display:none
       or content-visibility:hidden, depending on engine) so the group can
       collapse via a max-height animation instead of its links just
       vanishing - each link is a fixed single line, so a slightly-generous
       max-height reaches its natural height well before the transition ends. */
    display: flex !important;
    content-visibility: visible !important;
    max-height: 56px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.2s ease, opacity 0.15s ease, margin 0.2s ease;
  }
  .nav-group:not([open]) > .nav-link {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
    pointer-events: none;
  }

  .backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--backdrop);
    z-index: 40;
  }

  /* ---------- Main area: topbar + page ---------- */
  .main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 24px;
    background: var(--page);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 4px 12px rgba(54, 22, 128, 0.03);
  }
  :root[data-theme="dark"] .topbar {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  }
  .topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .topbar-title { font-size: 15px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { display: flex; align-items: center; gap: 10px; }

  .menu-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    flex: 0 0 34px;
  }
  .menu-btn svg { width: 18px; height: 18px; }

  .data-updated {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
  }
  .data-updated svg { width: 14px; height: 14px; flex: 0 0 14px; color: var(--text-muted); }
  .data-updated-text { overflow: hidden; text-overflow: ellipsis; }
  .days-ago-badge {
    flex: 0 0 auto;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .theme-toggle {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    flex: 0 0 34px;
    position: relative;
    transition: color 0.15s ease, border-color 0.15s ease;
  }
  .theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
  .theme-toggle svg {
    width: 17px;
    height: 17px;
    position: absolute;
    top: 50%;
    left: 50%;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    transition: opacity 0.2s ease, transform 0.3s ease;
  }
  .theme-toggle .icon-moon { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-90deg); }
  :root[data-theme="dark"] .theme-toggle .icon-sun { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(90deg); }
  :root[data-theme="dark"] .theme-toggle .icon-moon { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }

  .home-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
  }
  .home-btn:hover { color: var(--text-primary); border-color: var(--accent); }
  .home-btn svg { width: 14px; height: 14px; }

  .user-menu { position: relative; }
  .user-menu summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid transparent;
  }
  .user-menu summary::-webkit-details-marker { display: none; }
  .user-menu summary:hover { background: var(--gridline); }
  .user-menu .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
  }
  .user-menu-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
  .user-menu-dropdown {
    /* Overrides the browser's native details-closed hiding (display:none
       or content-visibility:hidden, depending on engine) so the fade/slide
       below can animate instead of the content just popping in and out. */
    display: block !important;
    content-visibility: visible !important;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    width: 220px;
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
  }
  .user-menu[open] .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition: opacity 0.15s ease, transform 0.15s ease;
  }
  .user-menu-info strong { font-size: 14px; }
  .user-menu-info .text-muted { display: block; margin-top: 2px; }
  .user-menu-link, .user-menu-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-secondary);
    width: 100%;
    border: none;
    background: none;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
  }
  .user-menu-link svg, .user-menu-logout svg { width: 14px; height: 14px; }
  .user-menu-link:hover { background: var(--gridline); color: var(--text-primary); }
  .user-menu-logout { color: var(--critical); }
  .user-menu-logout:hover { background: rgba(208, 59, 59, 0.10); }
  .divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

  @view-transition { navigation: auto; }

  .page {
    flex: 1;
    min-width: 0;
    width: 100%;
    margin: 0 auto;
    padding: 32px clamp(24px, 3vw, 64px) 64px;
    animation: pageOpen 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
    will-change: opacity, transform;
  }
  .page.page-closing {
    animation: pageClose 0.16s cubic-bezier(0.4, 0, 1, 1) forwards;
    pointer-events: none;
  }
  @keyframes pageOpen {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
  }
  @keyframes pageClose {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-6px); }
  }

  .breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    font-size: 13px;
    color: var(--text-muted);
  }
  .breadcrumb a { color: var(--text-muted); text-decoration: none; }
  .breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
  .breadcrumb-sep { color: var(--text-muted); opacity: 0.6; }
  .breadcrumb-current { color: var(--text-primary); font-weight: 600; }

  .page-head { margin-bottom: 32px; }
  .page-head h1 { font-size: 23px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.01em; }
  .page-head .greeting { font-size: 14px; color: var(--text-muted); margin: 0; }

  section { margin-bottom: 40px; opacity: 0; animation: rise 0.5s ease forwards; }
  section h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0 0 12px;
  }

  .filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
  }
  .filter-bar input[type="text"] { flex: 1 1 160px; min-width: 140px; max-width: 320px; }
  .filter-bar select { max-width: 180px; }
  .filter-bar input[type="date"] { max-width: 180px; }

  .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
  .tile {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-hover);
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  }
  .tile::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
  }
  .tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
  }
  .tile:hover::before { transform: scaleX(1); }

  /* Table cards: rich elevation shadow, no hover lift disruption */
  .tile.table-tile,
  .tile:has(.data-table),
  .tile:has(.table-wrap) {
    box-shadow: var(--shadow-table);
    overflow: hidden;
  }
  .tile.table-tile:hover,
  .tile:has(.data-table):hover,
  .tile:has(.table-wrap):hover {
    transform: none;
    box-shadow: var(--shadow-md);
  }
  .tiles .tile .label { justify-content: flex-start; }
  .tiles .tile .value { text-align: left; }
  .tiles .tile .sub { text-align: left; }
  .tile .label { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; }
  .tile .label svg {
    width: 32px;
    height: 32px;
    padding: 8px;
    box-sizing: border-box;
    flex: 0 0 32px;
    background: var(--accent-track);
    color: var(--accent);
    border-radius: 10px;
    opacity: 1;
  }
  .tile .value { font-size: 28px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
  .tile .value .unit { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; }
  .tile .sub { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
  .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; flex: 0 0 8px; }

  /* ---------- Modern Badges ---------- */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    border: 1px solid transparent;
  }
  .badge .dot {
    margin-right: 0;
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
  }
  .badge-success {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
    border-color: rgba(22, 163, 74, 0.25);
  }
  :root[data-theme="dark"] .badge-success {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
  }
  .badge-warning {
    background: rgba(234, 156, 20, 0.12);
    color: #b45309;
    border-color: rgba(234, 156, 20, 0.25);
  }
  :root[data-theme="dark"] .badge-warning {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
  }
  .badge-danger {
    background: rgba(225, 29, 72, 0.12);
    color: #be123c;
    border-color: rgba(225, 29, 72, 0.25);
  }
  :root[data-theme="dark"] .badge-danger {
    background: rgba(251, 113, 133, 0.15);
    color: #fb7185;
    border-color: rgba(251, 113, 133, 0.3);
  }
  .badge-neutral {
    background: rgba(139, 139, 148, 0.12);
    color: var(--text-secondary);
    border-color: var(--border);
  }
  .badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(124, 58, 237, 0.2);
  }
  .badge-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid rgba(124, 58, 237, 0.15);
    box-shadow: 0 1px 3px rgba(124, 58, 237, 0.12);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  }
  .badge-action:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.28);
    transform: translateY(-1.5px);
  }

  /* ---------- Tax-wise demand lines (taximport/_tax_heads_table.html) ---------- */
  .tax-heads { width: auto; min-width: 420px; border-collapse: collapse; font-size: 13px; }
  .tax-heads th, .tax-heads td { padding: 4px 12px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
  .tax-heads th:first-child, .tax-heads td:first-child { text-align: left; }
  .tax-heads tr.total td { font-weight: 600; border-bottom: none; }
  .tax-heads.horizontal thead th { vertical-align: bottom; }
  .tax-heads.horizontal tbody th { text-align: left; font-weight: 600; }
  .tax-heads.horizontal td { white-space: nowrap; }
  .tax-heads.horizontal td:last-child, .tax-heads.horizontal th:last-child { font-weight: 600; }
  .tax-heads.horizontal tr.total th { border-bottom: none; }
  .tax-heads.horizontal input { width: 96px; }
  /* A read-only total sized like the amount inputs, digits lined up with theirs. */
  .tax-heads .amount-box {
    display: inline-block; width: 96px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--page);
    font-size: 15px; line-height: normal; text-align: right; font-variant-numeric: tabular-nums;
  }
  /* No spinner arrows - they leave a gap after right-aligned digits. */
  input.amount-input { text-align: right; font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield; }
  input.amount-input::-webkit-inner-spin-button,
  input.amount-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .tax-heads .field-error { color: var(--critical); font-size: 12px; white-space: normal; }

  /* ---------- Recovery Progress Bar ---------- */
  .progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--gridline);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
  }
  .progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.4s ease;
  }
  .progress-bar-fill.good { background: var(--good); }
  .progress-bar-fill.warning { background: var(--warning); }
  .progress-bar-fill.critical { background: var(--critical); }

  /* ---------- Dashboard Filter Pills ---------- */
  .filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 22px;
    align-items: center;
  }
  .filter-pill {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .filter-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1.5px);
  }
  .filter-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(54, 22, 128, 0.3);
  }

  /* Interactive chart hover */
  .ring-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .ring-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(54, 22, 128, 0.12);
  }
  .ring-seg {
    transition: opacity 0.15s ease, stroke-width 0.15s ease;
    cursor: pointer;
  }
  .ring-seg:hover {
    opacity: 0.85;
    stroke-width: 14px;
  }

  .empty-note {
    color: var(--text-muted);
    font-size: 13px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
  }

  /* ---------- Forms / buttons (shared by login + future pages) ---------- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(54, 22, 128, 0.22);
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  }
  .btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 18px rgba(54, 22, 128, 0.32);
    transform: translateY(-2px);
  }
  .btn:active {
    box-shadow: 0 2px 4px rgba(54, 22, 128, 0.22);
    transform: translateY(0);
  }
  label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
  .field-icon { display: inline-flex; vertical-align: middle; margin-right: 6px; opacity: 0.75; }
  .field-icon svg { width: 14px; height: 14px; display: block; }
  input[type=text], input[type=password], input[type=email], input[type=number],
  input[type=file], input[type=date], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: inset 0 1px 2px rgba(14, 14, 20, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  :root[data-theme="dark"] input[type=text],
  :root[data-theme="dark"] input[type=password],
  :root[data-theme="dark"] input[type=email],
  :root[data-theme="dark"] input[type=number],
  :root[data-theme="dark"] input[type=file],
  :root[data-theme="dark"] input[type=date],
  :root[data-theme="dark"] select,
  :root[data-theme="dark"] textarea {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  }
  textarea { resize: vertical; min-height: 90px; }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-xs);
  }
  input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle; }

  /* ---------- Form field grid (add/edit forms) ----------
     Fields flow in document order, up to 4 per row on wide screens;
     fewer columns kick in as the form's available width shrinks, down
     to a single column on narrow/mobile viewports. */
  .form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px 20px;
    align-items: start;
  }
  .form-field { margin-bottom: 16px; min-width: 0; overflow: visible; }
  .form-field-wide { grid-column: 1 / -1; }
  /* Spans every column but the first, so an element placed right after a
     row's first field fills out the rest of THAT row instead of wrapping
     to a row of its own (see apps.waterimport/taximport's
     collection_demand_panel.js, which needs its property-demand panel
     beside the property field rather than below it). */
  .form-field-fill-row { grid-column: 2 / -1; }
  @media (max-width: 900px) {
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 480px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
  }

  /* ---------- Menu access checklist (accounts/_menu_access.html) ---------- */
  .menu-access {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
  }
  .menu-access-group { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
  .menu-access-group-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
  .menu-access-items { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 0 22px; }
  .menu-access-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
  .menu-access-group.is-disabled .menu-access-items { opacity: 0.45; }

  /* Search-as-you-type picker (common/autocomplete_select.js) - the
     native <select> it enhances stays in the DOM, visually hidden, as
     what actually submits. */
  .searchable-select-wrapper { position: relative; }
  .searchable-select-native { position: absolute; opacity: 0; height: 1px; width: 1px; overflow: hidden; pointer-events: none; }
  .searchable-select-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
  .searchable-select-list li { padding: 8px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; }
  .searchable-select-list li:hover { background: var(--accent-soft); color: var(--accent); }
  .searchable-select-list li.is-active { background: var(--accent-soft); color: var(--accent); }
  .searchable-select-list li.is-empty { color: var(--text-muted); cursor: default; background: none; }

  /* GeoDjango's OSMWidget (location/boundary map fields): fill the wide
     form column. Django 5.1+ no longer sizes the map itself, so without
     a height the map (and its ULB/Zone overlays) collapses to 0px. Height
     follows the width (16:9), capped to the viewport so it keeps the same
     shape from phone to wide desktop without pushing Save off-screen. */
  .dj_map_wrapper { width: 100%; }
  .dj_map {
    width: 100% !important; max-width: 100%;
    aspect-ratio: 16 / 9; min-height: 260px; max-height: 70vh;
  }

  /* ---------- Data table (list pages) ---------- */
  .table-wrap { overflow-x: auto; }
  .data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .data-table th {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #cbd5e1;
    padding: 12px 16px;
    background: #2e1065;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
  }
  /* .plain: same column labels, no indigo bar - used on a record detail
     page's own register history tables (see property_detail.html,
     water_connection_detail.html) so they read as part of that page's
     tile-based layout instead of a standalone list page. */
  .data-table.plain th {
    color: var(--text-muted);
    background: transparent;
    border-bottom: 1px solid var(--border);
  }
  .data-table td {
    text-align: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
    transition: background 0.12s ease;
  }
  .data-table tr:last-child td { border-bottom: none; }
  .data-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--gridline) 45%, var(--surface)); }
  .data-table tr:hover td { background: var(--gridline); }
  .data-table .actions { text-align: right; white-space: nowrap; }
  .data-table .actions a:not(.badge-action), .data-table .actions button:not(.badge-action) {
    background: none;
    border: none;
    padding: 0;
    margin-left: 12px;
    font: inherit;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
  }
  /* Every list's actions are icon-only badges (partials/_action_icon.html),
     named by their title/aria-label, so the column stays narrow. */
  .data-table td.actions { width: 1%; }
  .data-table .actions .badge-action {
    padding: 4px;
    margin-left: 2px;
  }
  .data-table .actions .badge-action.danger { color: var(--critical); }
  .data-table .actions .badge-action.danger:hover { background: var(--critical); color: #fff; box-shadow: none; }
  .data-table .actions button.danger { color: var(--critical); }
  .data-table .actions a:not(.badge-action):hover, .data-table .actions button:not(.badge-action):hover { text-decoration: underline; }
  .sort-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; text-decoration: none; cursor: pointer; }
  .sort-link:hover { color: var(--accent); }
  .sort-icons { display: inline-flex; flex-direction: column; gap: 1px; }
  .sort-icon { opacity: 0.35; }
  .sort-icon-active { opacity: 1; color: var(--accent); }
  .pagination-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
  }
  .pager { display: flex; align-items: center; gap: 10px; }
  .pager-btn {
    display: inline-block;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 5px 13px;
    cursor: pointer;
    text-decoration: none;
  }
  a.pager-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
  .pager-btn:disabled { color: var(--text-muted); cursor: not-allowed; opacity: 0.6; }
  .avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    text-decoration: none;
  }
  .user-name-cell { display: flex; align-items: center; gap: 10px; }
  .alert { padding: 11px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
  .alert-error { background: color-mix(in srgb, var(--critical) 12%, transparent); color: var(--critical); border: 1px solid color-mix(in srgb, var(--critical) 30%, transparent); }
  .text-muted { color: var(--text-muted); font-size: 13.5px; }

  /* ---------- Login page ---------- */
  .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(120deg, var(--accent-dark) 0%, var(--accent) 45%, var(--accent-2) 100%);
    background-size: 200% 200%;
    animation: gradient-pan 12s ease infinite;
  }
  @keyframes gradient-pan {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }
  @media (prefers-reduced-motion: reduce) {
    .login-wrap { animation: none; }
  }
  .login-card {
    background: var(--surface-raised);
    width: 100%;
    max-width: 380px;
    padding: 38px 36px;
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(11, 11, 11, 0.35);
  }
  .login-card .mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--accent-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
  }
  .login-card .mark svg { width: 18px; height: 18px; }
  .login-card h2 { margin: 0 0 2px; font-size: 20px; }

  /* ---------- Toasts ---------- */
  .toast-container { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
  .toast {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    animation: rise 0.25s ease forwards;
  }
  .toast-error { border-left-color: var(--critical); }
  .toast-close { appearance: none; border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
  .toast-hide { animation: fade-out 0.2s ease forwards; }

  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes fade-out { to { opacity: 0; transform: translateY(-4px); } }
  section:nth-of-type(1) { animation-delay: 0.02s; }
  section:nth-of-type(2) { animation-delay: 0.08s; }
  section:nth-of-type(3) { animation-delay: 0.14s; }
  section:nth-of-type(4) { animation-delay: 0.20s; }

  @media (prefers-reduced-motion: reduce) {
    .page, .page.page-closing { animation: none !important; transition: none !important; }
    section { opacity: 1; animation: none; }
    .tile, .tile:hover, .tile::before,
    .ring-card, .ring-card:hover, .pie-card, .pie-card:hover,
    .pie-slice, .pie-slice:hover { transition: none; transform: none; filter: none; }
    .btn, .badge-action, .filter-pill { transition: none; transform: none; }
    .data-table td,
    input[type=text], input[type=password], input[type=email], select,
    .theme-toggle, .theme-toggle svg,
    .user-menu-dropdown, .user-menu[open] .user-menu-dropdown,
    .nav-group > .nav-link {
      transition: none;
    }
  }

  /* ---------- Responsive ---------- */
  @media (max-width: 880px) {
    .menu-btn { display: flex; }
    .sidebar {
      position: fixed;
      z-index: 50;
      top: 0;
      left: 0;
      height: 100vh;
      max-height: 100vh;
      transform: translateX(-100%);
      transition: transform 0.22s ease;
      box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .backdrop.open { display: block; }
    .page { padding: 20px 16px 48px; }
    .topbar { padding: 12px 16px; }
    .user-menu-name { display: none; }
    .data-updated-text { display: none; }
    .data-updated { padding: 7px; }
  }
  @media (max-width: 420px) {
    .tile .value { font-size: 24px; }
    .login-card { padding: 30px 24px; }
  }

  .ring-row, .pie-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
  }
  .ring-card, .pie-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    text-align: left;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .ring-card:hover, .pie-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
  }
  .pie-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
  }
  .pie-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
    margin: 0;
  }
  .pie-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .pie-badge.good {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
  }
  :root[data-theme="dark"] .pie-badge.good {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
  }
  .pie-badge.accent {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(124, 58, 237, 0.2);
  }
  .pie-badge.warning {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.25);
  }
  :root[data-theme="dark"] .pie-badge.warning {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
  }
  .ring-card .ring-wrap, .pie-card .pie-wrap {
    position: relative;
    width: 240px;
    max-width: 100%;
    height: 222px;
    margin: 4px auto;
    flex: 0 0 222px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .pie-svg {
    width: 100%;
    height: 100%;
    transform: none !important;
    overflow: visible;
    filter: drop-shadow(0 4px 10px rgba(14, 14, 20, 0.08));
  }
  :root[data-theme="dark"] .pie-svg {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
  }
  .pie-slice {
    stroke: var(--surface);
    stroke-width: 2.5px;
    stroke-linejoin: round;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.15s ease, opacity 0.15s ease;
    transform-origin: 140px 130px;
    cursor: pointer;
  }
  .pie-slice:hover {
    transform: scale(1.06);
    filter: brightness(1.12) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.22));
  }
  .pie-callout {
    pointer-events: none;
  }
  .pie-callout text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
  .ring-wrap svg:not(.pie-svg) { width: 100%; height: 100%; transform: rotate(-90deg); }
  .ring-track, .ring-seg { fill: none; stroke-width: 12; }
  .ring-track { stroke: var(--gridline); }
  .ring-seg { stroke-linecap: round; }
  .ring-wrap .ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
  }
  .ring-wrap .ring-center .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
  .ring-wrap .ring-center .caption { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
  .ring-card .ring-meta, .pie-card .pie-meta { min-width: 0; width: 100%; margin-top: auto; }
  .ring-card .ring-meta .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
  .ring-legend, .pie-legend { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-secondary); text-align: left; }
  .ring-legend .row, .pie-legend .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.12s ease;
  }
  .ring-legend .row:hover, .pie-legend .row:hover { background: var(--gridline); }
  .ring-legend .row .n, .pie-legend .row .n { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

  @media (max-width: 420px) {
    .ring-row, .pie-row { grid-template-columns: 1fr; }
    .ring-card .ring-wrap, .pie-card .pie-wrap { width: 160px; height: 160px; flex: 0 0 160px; }
  }

  /* ---------- Grouped bar chart (config.charts.grouped_bars) ---------- */
  .bar-chart-legend { display: flex; gap: 18px; margin-bottom: 16px; font-size: 13px; color: var(--text-secondary); }
  .bar-chart-legend .row { display: flex; align-items: center; }
  .bar-chart { display: flex; align-items: flex-end; gap: 32px; height: 270px; padding: 0 4px; overflow-x: auto; }
  .bar-group { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; min-width: 64px; }
  .bar-group .bars { display: flex; align-items: stretch; gap: 10px; height: 210px; }
  .bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
  .bar-value { font-size: 11px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .bar-wrap .bar { width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; transition: height 0.25s ease; }
  .bar-group .bar-zone { margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-align: center; white-space: nowrap; }

  /* Stacked bar chart (config.charts.stacked_bars) - one bar per group,
     split into colored segments, vs. .bar-wrap/.bar above which is one
     bar per series. Reuses .bar-chart/.bar-group/.bar-value/.bar-zone. */
  .bar-wrap .bar-stack { width: 26px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 2px; }
  .bar-segment { width: 100%; min-height: 1px; transition: height 0.25s ease; }

  /* ---------- Filter-bar + map pages (property/tax/water/combined maps) ----------
     Shared by every "<Thing> Map" page (property_map, tax_demand_map,
     collection_map, water_connection_map, water_demand_map,
     water_collection_map, combined_properties_map, combined_demand_map,
     combined_collection_map) - each just marks its Leaflet/OL container
     with class="map-canvas" instead of redeclaring all of this per page.
     Page-specific bits (container id for JS hooks, popup min-width,
     paid/pending popup coloring) still live in each page's own
     extra_head block. */
  .page:has(.map-canvas) { padding-top: 16px; padding-bottom: 20px; }
  .page:has(.map-canvas) .page-head { margin-bottom: 10px; }
  .page:has(.map-canvas) .page-head h1 { font-size: 18px; }
  .page:has(.map-canvas) section { margin-bottom: 10px; }

  .map-canvas { position: relative; width: 100%; height: calc(100vh - 200px); min-height: 640px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
  .map-legend { display: flex; gap: 16px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--text-secondary); }
  .map-legend .dot { flex: 0 0 8px; }
  .map-layer-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    max-width: calc(100% - 20px);
    z-index: 10;
    display: flex;
    gap: 4px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    box-shadow: var(--shadow);
  }
  .map-layer-toggle button {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
  }
  .map-layer-toggle button.active { background: var(--accent); color: #fff; }
  .map-boundary-filter {
    position: absolute;
    top: 50px;
    right: 10px;
    z-index: 10;
    width: 135px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    box-shadow: var(--shadow);
  }
  .map-boundary-filter label { display: flex; align-items: center; gap: 5px; cursor: pointer; margin: 0; }
  .map-boundary-legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 10px; }
  /* OL's default position (top: .5em; right: .5em) sits directly under our
     own .map-layer-toggle bar (top: 10px; right: 10px; z-index: 10),
     which renders on top of it and makes the button unreachable - move it
     to the bottom-left corner, the one spot no other map overlay claims.
     Scoped under .map-canvas (2 classes) rather than bare .ol-full-screen
     (1 class) so this wins on specificity regardless of whether ol.css or
     base.css happens to load second. */
  .map-canvas .ol-full-screen { top: auto; right: auto; bottom: 0.5em; left: 0.5em; }
  .map-popup {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 10px 12px;
    font-size: 13px;
    min-width: 180px;
  }
  .map-popup-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
  .map-popup-meta { color: var(--text-muted); font-size: 12px; margin: 4px 0 6px; }
  .map-popup-amounts { margin: 4px 0 6px; }
  .map-popup-amounts .row { display: flex; justify-content: space-between; gap: 12px; }
  .map-popup a { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 12px; }

  .import-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 20, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
  }
  .import-progress-box {
    background: var(--surface);
    border-radius: 10px;
    padding: 22px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
  }
  .import-progress-spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: import-progress-spin 0.7s linear infinite;
    flex-shrink: 0;
  }
  @keyframes import-progress-spin { to { transform: rotate(360deg); } }
  .import-progress-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
  }
  .import-progress-bar {
    width: 260px;
    max-width: 60vw;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
  }
  .import-progress-bar[hidden], .import-progress-detail[hidden] { display: none; }
  .import-progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.4s ease;
  }
  .import-progress-detail {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
  }

  /* Auto-refresh indicator & animation */
  .auto-refresh-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    box-shadow: var(--shadow);
  }
  .live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 6px rgba(22, 163, 74, 0.6);
    flex-shrink: 0;
    transition: all 0.2s ease;
  }
  .live-dot.active {
    animation: live-dot-pulse 2s infinite ease-in-out;
  }
  .live-dot.paused {
    background: var(--text-muted);
    box-shadow: none;
    animation: none;
  }
  @keyframes live-dot-pulse {
    0% { transform: scale(0.95); opacity: 0.85; }
    50% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 8px rgba(22, 163, 74, 0.9); }
    100% { transform: scale(0.95); opacity: 0.85; }
  }
  .spinning {
    animation: icon-spin 0.7s linear infinite;
  }
  @keyframes icon-spin {
    to { transform: rotate(360deg); }
  }

