/* ============================================================================
   SaveTrack design system
   ----------------------------------------------------------------------------
   Single source of truth for every screen. Previously each feature area carried
   its own <style> partial (_MoneyListStyles, _FeatureStyles, _AuthStyles, ...),
   which meant nine copies of the same tokens and no way to restyle the app in
   one place. Those partials are gone; their component vocabulary lives here.

   Class names were kept identical to the old partials so existing markup did
   not have to change. Sections:

     1  Tokens              7  Tables            13  Empty states
     2  Base                8  Badges & pills    14  Pagination
     3  App shell           9  Buttons           15  Charts
     4  Page primitives    10  Forms             16  Overlays (modal/toast/menu)
     5  Cards & panels     11  Progress          17  Feature modules
     6  Sparklines         12  Alerts            18  Animation, a11y, print
   ========================================================================= */


/* == 1. Tokens ============================================================ */

:root {
    /* Brand — greyed indigo, ~half the chroma of consumer blue.
       White on --primary: 6.77:1; on --primary-dark: 9.24:1. */
    --primary: #3A57A7;
    --primary-dark: #2C4485;
    --primary-light: #7E93C9;
    --primary-soft: #DEE4F2;

    /* Semantic — forest / brick / ochre / steel; all pass 4.5:1 with white text */
    --success: #337052;
    --success-dark: #2A5C44;
    --danger: #A13D3B;
    --danger-dark: #8A3430;
    --danger-light: #F8F1F0;
    --warning: #8A6210;
    --warning-dark: #6E4E0D;
    --info: #3E6B94;

    /* Tinted surfaces for badges, alerts and pills (fg on bg all >= 5.7:1) */
    --success-bg: #E3EDE6;
    --success-fg: #2A5B40;
    --danger-bg: #F4E7E5;
    --danger-fg: #8A3A34;
    --warning-bg: #F4EDDC;
    --warning-fg: #755716;
    --info-bg: #E4EAF2;
    --info-fg: #34517D;

    /* Neutrals — --gray-700 is the spec body text, --gray-200 the spec border */
    --gray-50: #F8F9FA;
    --gray-100: #F1F5F9;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Surfaces — indirection so dark mode only overrides these */
    --bg: #F7F8FA;
    --surface: #FFFFFF;
    --surface-2: #F8F9FA;
    --border: #E5E7EB;
    --border-soft: #F1F5F9;
    --text: #374151;
    --text-muted: #5D6674;
    --text-strong: #1F2937;

    /* Sidebar keeps its dark treatment in both themes — ink navy, so the
       muted primary still reads as the accent against it */
    --sidebar-bg: #171E2C;
    --sidebar-hover: #232C3E;
    --sidebar-text: #C6CDD9;
    --sidebar-label: #8A94A6;
    --sidebar-border: #232C3E;

    /* Shape — spec calls for 10-14px; --radius-lg for feature cards */
    --radius: 14px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --radius-pill: 999px;

    /* Soft, layered shadows */
    --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --shadow-md: 0 4px 12px rgba(16,24,40,.06), 0 2px 4px rgba(16,24,40,.04);
    --shadow-lg: 0 12px 32px rgba(16,24,40,.10), 0 4px 8px rgba(16,24,40,.04);
    --shadow-xl: 0 24px 48px rgba(16,24,40,.14), 0 8px 16px rgba(16,24,40,.06);
    /* Focus ring derives from --primary so it can never drift from the brand */
    --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);

    /* Card elevation — soft ambient pair used across dashboard surfaces */
    --shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.05);
    --shadow-card-hover: 0 2px 4px rgba(16,24,40,.05), 0 12px 28px rgba(16,24,40,.10);

    /* Hero balance card — ink navy through muted indigo; the one saturated
       object on the dashboard. White text: 17.25:1 / 11.69:1 / 6.77:1 per stop. */
    --hero-grad: linear-gradient(135deg, #101A33 0%, #24356B 52%, #3A57A7 100%);
    --hero-grad-neg: linear-gradient(135deg, #2E0F0F 0%, #6E2523 55%, #A13D3B 100%);
    --hero-glow: radial-gradient(circle at 82% -40%, rgba(126,147,201,.35), transparent 60%);
    --hero-shadow: 0 8px 24px rgba(44,68,133,.28), 0 2px 6px rgba(16,26,51,.20);

    /* Tinted icon chips: --tone mixed into transparent at this strength */
    --chip-alpha: 12%;

    /* Floating dark chart tooltip (stays dark in both themes) */
    --tooltip-bg: rgba(15,23,42,.92);
    --tooltip-fg: #F8FAFC;

    /* Motion */
    --ease: cubic-bezier(.2, 0, 0, 1);
    --t-fast: .15s var(--ease);
    --t: .25s var(--ease);
    --t-slow: .6s var(--ease);

    /* Shell metrics */
    --sidebar-width: 260px;
    --sidebar-collapsed: 76px;
    --topbar-height: 64px;
    --page-max: 1440px;
}

/* Dark mode. The toggle in the topbar sets data-theme on <html> and site.js
   restores the choice from localStorage before first paint. */
:root[data-theme="dark"] {
    --gray-50: #1E293B;
    --gray-100: #273449;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748B;
    --gray-500: #94A3B8;
    --gray-600: #CBD5E1;
    --gray-700: #E2E8F0;
    --gray-800: #F1F5F9;
    --gray-900: #F8FAFC;

    --bg: #0F172A;
    --surface: #1E293B;
    --surface-2: #273449;
    --border: #334155;
    --border-soft: #273449;
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --text-strong: #F1F5F9;

    --primary-soft: #26355C;
    --danger-light: #2A1817;
    /* Mid-tones so these read as both button hovers and text on tinted surfaces
       (5.6-6.7:1 on --surface) */
    --success-dark: #6FAE8C;
    --danger-dark: #D98B84;
    --warning-dark: #D3A94F;
    /* fg on bg composited over --surface: 7.0-8.0:1 */
    --success-bg: #1C2E2490;
    --success-fg: #A3C9B2;
    --danger-bg: #3C1D1B90;
    --danger-fg: #E2ABA4;
    --warning-bg: #3A2E1490;
    --warning-fg: #D9BE85;
    --info-bg: #22345E90;
    --info-fg: #A9BEE4;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
    --shadow-md: 0 4px 12px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.45);
    --shadow-xl: 0 24px 48px rgba(0,0,0,.55);
    --shadow-card: 0 1px 2px rgba(0,0,0,.30), 0 4px 16px rgba(0,0,0,.28);
    --shadow-card-hover: 0 2px 4px rgba(0,0,0,.35), 0 12px 28px rgba(0,0,0,.45);

    /* Hero: slightly deeper so it doesn't glow against the #0F172A page */
    --hero-grad: linear-gradient(135deg, #0C1428 0%, #1B2A52 55%, #33478F 100%);
    --hero-glow: radial-gradient(circle at 82% -40%, rgba(126,147,201,.25), transparent 60%);
    --hero-shadow: 0 8px 24px rgba(0,0,0,.50), 0 2px 6px rgba(0,0,0,.35);

    /* 12% tints vanish on #1E293B surfaces */
    --chip-alpha: 18%;
    --tooltip-bg: rgba(51,65,85,.96);
}


/* == 2. Base ============================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--t), color var(--t);
}

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4, h5, h6 { color: var(--text-strong); line-height: 1.25; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* Numeric columns line up when digits share a width */
.num, .amount-cell, .stat-value, .summary-value {
    font-variant-numeric: tabular-nums;
}


/* == 3. App shell ========================================================= */

/* --- sidebar --- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.25rem .75rem 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    transition: width var(--t), transform var(--t);
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 12px rgba(0,0,0,.06);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .25rem .5rem 1.25rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    white-space: nowrap;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand i { font-size: 1.6rem; color: var(--primary-light); }

.nav-group { margin-top: .9rem; }

/* Group label is a disclosure button; aria-expanded drives everything below. */
.nav-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    width: 100%;
    font-family: inherit;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--sidebar-label);
    padding: .3rem .75rem;
    margin-bottom: .25rem;
    font-weight: 600;
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    text-align: left;
    cursor: pointer;
    transition: color var(--t-fast), background-color var(--t-fast);
}
.nav-group-label:hover { color: var(--sidebar-text); background: rgba(148,163,184,.07); }
.nav-group-chevron { font-size: .55rem; opacity: .65; }
.nav-group-label[aria-expanded="false"] .nav-group-chevron { transform: rotate(-90deg); }

/* Height animation via grid-template-rows 0fr -> 1fr: animatable, needs no JS
   measurement, and works with any content height. The <ul> is the sole grid
   item and does the clipping. The 4px padding / -4px margin pair nets to zero
   in layout but leaves paint room so focus rings aren't sheared by overflow. */
.nav-group-body {
    display: grid;
    grid-template-rows: 1fr;
}
.nav-group-body > .sidebar-nav {
    min-height: 0;
    overflow: hidden;
    padding: 4px;
    margin: -4px;
}
.nav-group-label[aria-expanded="false"] + .nav-group-body { grid-template-rows: 0fr; }

/* Motion is opt-in after first paint (site.js adds .nav-anim-ready two frames
   in) so a restored-collapsed group renders shut instead of animating shut on
   every page load. */
.sidebar.nav-anim-ready .nav-group-body { transition: grid-template-rows var(--t); }
.sidebar.nav-anim-ready .nav-group-chevron { transition: transform var(--t); }

/* Icon rail: labels are hidden, so every group must render open — otherwise
   icons would be unreachable. State is not rewritten, this override merely
   outranks it, so per-group states return intact when the sidebar re-expands.
   Desktop only: on mobile .collapsed means "drawer closed", and an open drawer
   must keep its groups collapsible. */
@media (min-width: 821px) {
    .sidebar.collapsed .nav-group-label[aria-expanded="false"] + .nav-group-body {
        grid-template-rows: 1fr;
    }
}

.sidebar-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .55rem .9rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: .85rem;
    transition: background-color var(--t-fast), color var(--t-fast);
    white-space: nowrap;
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
}
.sidebar-link i { width: 1.4rem; font-size: 1.02rem; opacity: .7; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(148,163,184,.09); color: #fff; }

/* Active = tinted wash + accent bar, not a solid saturated block. Keeps the
   hierarchy hover < active without shouting on the dark rail. */
.sidebar-link.active {
    background: color-mix(in srgb, var(--primary-light) 13%, transparent);
    color: #fff;
    font-weight: 600;
}
.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.1rem;
    border-radius: 2px;
    background: var(--primary-light);
}
.sidebar-link.active i { color: var(--primary-light); opacity: 1; }

/* The global 8px light thumb glows against the dark rail */
.sidebar { scrollbar-width: thin; scrollbar-color: var(--sidebar-hover) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-hover); }

.sidebar-user {
    margin-top: auto;
    padding: .75rem .5rem .25rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-user .avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .8rem; color: #fff; flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-weight: 600; font-size: .8rem; color: #E2E8F0; }
.sidebar-user .user-email {
    font-size: .65rem; color: var(--sidebar-label);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-logout {
    background: none; border: none; color: var(--sidebar-label);
    font-size: 1rem; cursor: pointer; padding: .35rem;
    border-radius: 50%; transition: var(--t-fast);
}
.sidebar-logout:hover { color: #FCA5A5; background: rgba(220,38,38,.12); }

.sidebar-toggle-btn {
    background: none; border: none; color: var(--sidebar-label);
    font-size: 1rem; cursor: pointer; padding: .3rem .55rem;
    border-radius: var(--radius-sm); transition: var(--t-fast);
    margin-bottom: 1.25rem;
}
.sidebar-toggle-btn:hover { background: var(--sidebar-hover); color: #fff; }

/* collapsed: icons only */
.sidebar.collapsed { width: var(--sidebar-collapsed); padding: 1.25rem .5rem; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .sidebar-user .user-info { display: none; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: .6rem; }
.sidebar.collapsed .sidebar-link i { margin: 0; font-size: 1.2rem; }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-head,
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .nav-group { margin-top: .6rem; border-top: 1px solid var(--sidebar-border); padding-top: .6rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.35);
    backdrop-filter: blur(2px);
    z-index: 1045;
}
.sidebar-overlay.active { display: block; }

/* --- topbar --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    min-height: var(--topbar-height);
    /* saturate(180%) made scrolled content bloom under the bar */
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    padding: .6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--t);
}
.sidebar.collapsed ~ .topbar { margin-left: var(--sidebar-collapsed); }

.topbar-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.topbar-brand { font-weight: 700; font-size: 1rem; color: var(--text-strong); }
.topbar-brand i { color: var(--primary); margin-right: .4rem; }
.topbar-center { flex: 1; max-width: 460px; min-width: 140px; }
.topbar-right { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* Recessed until focused — the Stripe/Linear idiom */
.search-box {
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    padding: .25rem .9rem;
    box-shadow: none;
    transition: background-color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-box:focus-within { background: var(--surface); border-color: var(--primary); box-shadow: var(--ring); }
.search-box i { color: var(--text-muted); font-size: .85rem; }
.search-box input {
    border: none; outline: none; background: transparent;
    padding: .4rem .6rem; font-size: .85rem; width: 100%;
    color: var(--text); font-family: inherit;
}

.btn-icon {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    cursor: pointer;
    position: relative;
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }

.badge-dot {
    position: absolute;
    top: 3px; right: 3px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--danger);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: .6rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--surface);
}

.btn-quick-add {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: .5rem 1.1rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: .8rem;
    display: flex; align-items: center; gap: .5rem;
    transition: var(--t);
    cursor: pointer;
}
.btn-quick-add:hover { background: var(--primary-dark); color: #fff; }

.user-profile-btn {
    display: flex; align-items: center; gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: .2rem .8rem .2rem .25rem;
    transition: background-color var(--t-fast), border-color var(--t-fast);
    cursor: pointer;
    color: var(--text);
}
.user-profile-btn:hover { border-color: var(--primary); background: var(--surface-2); }
.avatar-small {
    width: 30px; height: 30px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: .7rem;
    flex-shrink: 0;
}

.sidebar-toggle-mobile {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: var(--t);
}
.sidebar-toggle-mobile:hover { background: var(--surface-2); }

/* --- main + footer --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem 2.5rem;
    flex: 1;
    transition: margin-left var(--t);
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }
.main-content.no-sidebar { margin-left: 0; padding: 2rem 1rem; }

.container-custom { max-width: var(--page-max); margin: 0 auto; }

/* One 320ms settle per navigation, instead of an eight-step card cascade */
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.main-content > .container-custom { animation: pageIn .32s var(--ease) both; }

.app-footer {
    margin-left: var(--sidebar-width);
    padding: 1rem 2rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: .75rem;
    color: var(--text-muted);
    transition: margin-left var(--t);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
}
.sidebar.collapsed ~ .app-footer { margin-left: var(--sidebar-collapsed); }
.app-footer .foot-item { display: inline-flex; align-items: center; gap: .4rem; }
.app-footer .dot-ok { color: var(--success); }
.app-footer .dot-bad { color: var(--danger); }

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { width: 280px; transform: translateX(-100%); padding: 1.25rem .75rem 1.5rem 1rem; }
    .sidebar.collapsed.open { transform: translateX(0); }
    /* on mobile the drawer is always full width — undo icon-only collapsing */
    .sidebar.collapsed .sidebar-brand span,
    .sidebar.collapsed .sidebar-link span,
    .sidebar.collapsed .sidebar-user .user-info { display: revert; }
    /* not display:revert — the label is a <button>, which would revert to
       inline-block and break the label/chevron row */
    .sidebar.collapsed .nav-group-label { display: flex; }
    .sidebar.collapsed .sidebar-link { justify-content: flex-start; padding: .55rem .9rem; }
    .sidebar.collapsed .nav-group { border-top: none; padding-top: 0; margin-top: .9rem; }
    .sidebar-toggle-btn { display: none; }
    .sidebar-toggle-mobile { display: flex; }

    .topbar, .main-content, .app-footer { margin-left: 0 !important; }
    .main-content { padding: 1rem; }
    .app-footer { padding: .75rem 1rem; flex-direction: column; text-align: center; align-items: center; }

    /* The header has to earn its vertical space on a phone. Left + right were
       overflowing the row by a few pixels and wrapping, which pushed search onto
       a third line and cost 150px before any content. Tighten the gaps, let the
       title truncate, and drop the search box - the ledger pages have their own
       search field, so it is redundant here. */
    .topbar { padding: .5rem .75rem; gap: .5rem; }
    .topbar-left { flex: 1; min-width: 0; gap: .6rem; }
    .topbar-brand {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: .95rem;
    }
    .topbar-right { gap: .4rem; flex-wrap: nowrap; }
    .topbar-center { display: none; }
}


/* == 4. Page primitives =================================================== */

.page-container { max-width: var(--page-max); margin: 0 auto; }
/* Forms read better in a narrow column */
.page-container.narrow { max-width: 820px; }

.page-header { margin-bottom: 1.75rem; }
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-strong);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.page-title i { color: var(--primary); }
.page-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .35rem; }

.breadcrumb-nav { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--text-muted); margin-bottom: .6rem; flex-wrap: wrap; }
.breadcrumb-nav a { color: var(--text-muted); }
.breadcrumb-nav a:hover { color: var(--primary); }
.breadcrumb-nav .sep { color: var(--gray-300); }
.breadcrumb-nav [aria-current="page"] { color: var(--text-strong); font-weight: 600; }

.section-heading {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .25rem 0 1rem;
}
.section-heading i { color: var(--primary); }


/* == 5. Cards & panels ==================================================== */

/* Generic surface used by the dashboard rows — one elevation language */
.card-modern, .panel, .entries-card, .add-entry-card, .stat-tile, .stat-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.card-modern { padding: 1.25rem 1.5rem; transition: box-shadow var(--t), transform var(--t); }
.card-modern:hover { box-shadow: var(--shadow-md); }
.card-modern.flush { padding: 0; }

.card-title {
    font-weight: 600;
    font-size: .95rem;
    color: var(--text-strong);
    margin-bottom: .9rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
/* Leading icon renders as a mini tinted chip — same grammar as the summary cards */
.card-title i {
    color: var(--primary);
    width: 30px; height: 30px;
    border-radius: 8px;
    display: grid; place-items: center;
    font-size: .8rem;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    flex-shrink: 0;
}
.card-title .card-title-note { font-weight: 400; font-size: .75rem; color: var(--text-muted); }

.panel { margin-bottom: 1.75rem; overflow: hidden; }
.panel-head {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
}
.panel-title {
    font-weight: 700; color: var(--text-strong); font-size: .95rem;
    display: flex; align-items: center; gap: .5rem; margin: 0;
}
.panel-title i { color: var(--primary); }
.panel-body { padding: 1.25rem; }
.panel-body.flush { padding: 0; }

/* --- dashboard summary cards (chip, value, delta pill, sparkline, caption) --- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.summary-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.15rem 1.3rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--t), border-color var(--t);
}
/* Hover deepens the shadow; nothing moves. Six surfaces bouncing 2-3px reads
   as noise — the page entrance is handled once, on .container-custom. */
.summary-card:hover { box-shadow: var(--shadow-card-hover); }
.summary-card.tone-primary { --tone: var(--primary); }
.summary-card.tone-success { --tone: var(--success); }
.summary-card.tone-danger { --tone: var(--danger); }
.summary-card.tone-warning { --tone: var(--warning); }
.summary-card.tone-neutral { --tone: var(--gray-400); }

.summary-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.summary-label {
    font-size: .7rem; font-weight: 500; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted);
}
/* Tinted rounded-square chip, colour derived from the card's --tone */
.summary-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: .95rem;
    color: var(--tone, var(--primary));
    background: color-mix(in srgb, var(--tone, var(--primary)) var(--chip-alpha, 12%), transparent);
    transition: transform var(--t);
    flex-shrink: 0;
}
.summary-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.015em; color: var(--text-strong); line-height: 1.15; }
.summary-delta {
    font-size: .7rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .18rem .55rem; width: fit-content;
    border-radius: var(--radius-pill);
}
.summary-delta.up { background: var(--success-bg); color: var(--success-fg); }
.summary-delta.down { background: var(--danger-bg); color: var(--danger-fg); }
.summary-delta.flat { background: var(--gray-100); color: var(--text-muted); }
.summary-caption { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; }

/* --- hero balance card: full-width gradient feature, the page's focal point --- */
.summary-card.hero-card {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    min-height: 168px;
    padding: 1.5rem 1.75rem;
    border: none;
    border-radius: 20px;
    background: var(--hero-grad);
    box-shadow: var(--hero-shadow);
    color: #fff;
}
.summary-card.hero-card.negative { background: var(--hero-grad-neg); }
.summary-card.hero-card:hover { box-shadow: var(--hero-shadow); }
.summary-card.hero-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--hero-glow);
    pointer-events: none;
}
.hero-main { display: flex; flex-direction: column; gap: .3rem; position: relative; z-index: 1; }
.hero-card .summary-label { color: rgba(255,255,255,.72); font-size: .72rem; letter-spacing: .08em; }
.hero-card .summary-value {
    color: #fff;
    font-size: clamp(2.1rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -.025em;
}
.hero-card .summary-caption { color: rgba(255,255,255,.65); font-size: .78rem; }
.hero-card .summary-icon {
    color: rgba(255,255,255,.85);
    background: rgba(255,255,255,.16);
}

.hero-spark {
    width: min(340px, 38%);
    height: 72px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.hero-spark polyline {
    fill: none;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    /* 600 comfortably exceeds the line's on-screen length; with non-scaling-stroke,
       Chromium measures dashes in screen pixels, so 300 could truncate the tail. */
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: heroDash .9s .25s var(--ease) forwards;
}
@keyframes heroDash { to { stroke-dashoffset: 0; } }

@media (max-width: 640px) {
    .summary-card.hero-card { flex-direction: column; align-items: flex-start; min-height: 0; gap: .75rem; }
    .hero-spark { width: 100%; height: 56px; }
}

/* --- stat tiles (feature pages) --- */
.stat-tile { padding: 1.1rem 1.25rem; transition: box-shadow var(--t); }
.stat-tile:hover { box-shadow: var(--shadow-md); }
.stat-label {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 600;
    display: flex; align-items: center; gap: .4rem;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-strong); margin-top: .35rem; line-height: 1.15; }
.stat-value.sm { font-size: 1.12rem; }
.stat-sub { font-size: .76rem; color: var(--text-muted); margin-top: .3rem; }
.stat-tile.accent { border-left: 3px solid var(--primary); }
.stat-tile.good { border-left: 3px solid var(--success); }
.stat-tile.warn { border-left: 3px solid var(--warning); }
.stat-tile.bad { border-left: 3px solid var(--danger); }

/* --- stat cards (list pages: icon tile + figure) --- */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}
@media (max-width: 1024px) { .stats-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .stats-cards { grid-template-columns: 1fr; } }

.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow var(--t);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.stat-info h3 { font-size: 1.5rem; font-weight: 700; margin: 0; color: var(--text-strong); line-height: 1.2; }
.stat-info p {
    margin: 0; color: var(--text-muted); font-size: .78rem;
    text-transform: uppercase; letter-spacing: .03em; font-weight: 500;
}

/* --- feature grid --- */
.feature-grid { display: grid; gap: 1rem; margin-bottom: 1.75rem; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* --- goal / mini cards --- */
.mini-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 1rem 1.1rem;
    transition: box-shadow var(--t);
}
.mini-card:hover { box-shadow: var(--shadow-card-hover); }
.mini-card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.mini-card-icon {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; flex-shrink: 0;
    background: var(--primary-soft); color: var(--primary);
}
.mini-card-title { font-weight: 600; font-size: .88rem; color: var(--text-strong); }
.mini-card-meta { font-size: .72rem; color: var(--text-muted); }
.mini-card-value { font-weight: 700; color: var(--text-strong); font-size: 1rem; white-space: nowrap; }

/* --- balance sheet rows --- */
.sheet-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
    transition: background-color var(--t-fast);
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row:hover { background: var(--surface-2); }
.sheet-name { font-weight: 600; color: var(--text-strong); font-size: .9rem; }
.sheet-meta { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; }
.sheet-amount { font-weight: 700; color: var(--text-strong); white-space: nowrap; }
.sheet-actions { display: flex; gap: .35rem; }
.sheet-actions a, .sheet-actions button {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gray-100); border: none; border-radius: var(--radius-xs);
    color: var(--text-muted); cursor: pointer; font-size: .78rem;
    transition: var(--t-fast);
}
.sheet-actions a:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.sheet-actions .danger:hover { background: var(--danger-bg); color: var(--danger-fg); }

.card-header-custom {
    background: var(--surface-2);
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-strong);
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1rem;
}
.entries-card, .add-entry-card { overflow: hidden; }
.entry-count { font-size: .8rem; font-weight: 400; color: var(--text-muted); }
.card-body-custom { padding: 2rem; }
@media (max-width: 768px) {
    .card-body-custom { padding: 1.5rem; }
    .card-header-custom { flex-direction: column; align-items: flex-start; }
}


/* == 6. Sparklines ======================================================== */

.sparkline { display: block; width: 100%; height: 36px; margin-top: .4rem; overflow: visible; }
.sparkline polyline {
    fill: none;
    stroke: var(--tone, var(--primary));
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.sparkline polygon { fill: var(--tone, var(--primary)); opacity: .12; }
.sparkline circle { fill: var(--tone, var(--primary)); }


/* == 7. Tables ============================================================ */

.entries-table, .feature-table { width: 100%; border-collapse: collapse; }

.entries-table thead { background: transparent; }
.feature-table thead { background: var(--surface-2); }
.entries-table th, .feature-table th {
    padding: .7rem 1.5rem;
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.entries-table td, .feature-table td {
    padding: .9rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
    font-size: .85rem;
    color: var(--text);
}
.entries-table tbody tr, .feature-table tbody tr { transition: background-color var(--t-fast); }
.entries-table tbody tr:hover, .feature-table tbody tr:hover { background: var(--surface-2); }
.entries-table tbody tr:last-child td, .feature-table tbody tr:last-child td { border-bottom: none; }

.entries-table tfoot { background: var(--surface-2); font-weight: 600; }
.entries-table tfoot td { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

.feature-table th, .feature-table td { padding: .75rem 1.25rem; }

.date-cell { color: var(--text-muted); white-space: nowrap; }
.amount-cell { font-weight: 600; }
.notes-cell { color: var(--text-muted); font-size: .75rem; margin-top: .25rem; }
.total-label { text-align: right; color: var(--text-muted); font-size: .85rem; font-weight: 600; }
.num { text-align: right; white-space: nowrap; }

/* Card-per-row on narrow screens; cells label themselves from data-label */
@media (max-width: 768px) {
    .page-header .d-flex { flex-direction: column; align-items: stretch; gap: 1rem; }
    .entries-table thead { display: none; }
    .entries-table tbody tr {
        display: block; margin-bottom: 1rem;
        border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem;
    }
    .entries-table td {
        display: flex; justify-content: space-between; align-items: center;
        padding: .5rem; border: none; border-bottom: 1px solid var(--border-soft);
    }
    .entries-table td:last-child { border-bottom: none; }
    .entries-table td:before {
        content: attr(data-label);
        font-weight: 700; color: var(--text-muted); margin-right: 1rem;
        font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    }
    .entries-table tfoot { display: block; }
    .entries-table tfoot tr { display: block; padding: .5rem; }
    .entries-table tfoot td { display: flex; justify-content: space-between; padding: .5rem; border: none; }
    .action-buttons { justify-content: flex-end; }
}

.table-scroll { width: 100%; overflow-x: auto; }


/* == 8. Badges & pills ==================================================== */

.category-badge {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .25rem .75rem; border-radius: var(--radius-pill);
    font-size: .72rem; font-weight: 600;
    background: var(--gray-100); color: var(--text-muted);
}
.category-badge i { font-size: .65rem; }

/* Category colours are hue-coded so a category keeps its identity everywhere */
.cat-food { background: #FFF1E6; color: #C2410C; }
.cat-transport { background: #DBEAFE; color: #1D4ED8; }
.cat-housing { background: #EDE9FE; color: #6D28D9; }
.cat-utilities { background: #CFFAFE; color: #0E7490; }
.cat-healthcare { background: #FCE7F3; color: #BE185D; }
.cat-entertainment { background: #FEF3C7; color: #B45309; }
.cat-shopping { background: #FEE2E2; color: #B91C1C; }
.cat-education { background: #DCFCE7; color: #15803D; }
.cat-insurance { background: #E2E8F0; color: #475569; }
.cat-other { background: var(--gray-100); color: var(--text-muted); }
.cat-salary { background: #DCFCE7; color: #15803D; }
.cat-business { background: #DBEAFE; color: #1D4ED8; }
.cat-freelance { background: #EDE9FE; color: #6D28D9; }
.cat-investment { background: #FFF1E6; color: #C2410C; }
.cat-rental { background: #CFFAFE; color: #0E7490; }
.cat-bonus { background: #FEF3C7; color: #B45309; }
.cat-gift { background: #FCE7F3; color: #BE185D; }
.cat-refund { background: #E2E8F0; color: #475569; }

.pill {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .65rem; border-radius: var(--radius-pill);
    font-size: .7rem; font-weight: 700; letter-spacing: .01em;
}
.pill-derived { background: var(--gray-100); color: var(--text-muted); }
.pill-good, .badge-status.paid { background: var(--success-bg); color: var(--success-fg); }
.pill-warn, .badge-status.pending { background: var(--warning-bg); color: var(--warning-fg); }
.pill-bad, .badge-status.overdue { background: var(--danger-bg); color: var(--danger-fg); }
.pill-info { background: var(--info-bg); color: var(--info-fg); }

.badge-status {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .7rem; border-radius: var(--radius-pill);
    font-size: .7rem; font-weight: 700;
}

.tag-pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .65rem; border-radius: var(--radius-pill);
    font-size: .72rem; font-weight: 700; color: #fff;
}
.tag-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.role-badge, .status-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .7rem; border-radius: var(--radius-pill);
    font-size: .7rem; font-weight: 700;
}
.role-badge.admin { background: #EDE9FE; color: #6D28D9; }
.role-badge.user { background: var(--info-bg); color: var(--info-fg); }
.status-badge.on { background: var(--success-bg); color: var(--success-fg); }
.status-badge.off { background: var(--gray-100); color: var(--text-muted); }

.t-good { color: var(--success); }
.t-warn { color: var(--warning); }
.t-bad { color: var(--danger); }
.t-muted { color: var(--text-muted); }


/* == 9. Buttons =========================================================== */

.btn-primary-soft, .btn-save, .btn-add-user, .btn-create-first, .filter-apply, .btn-auth, .btn-pill.primary {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn-primary-soft, .filter-apply { padding: .6rem 1.15rem; font-size: .85rem; }
.btn-save, .btn-add-user { padding: .75rem 1.5rem; font-size: .875rem; }
.btn-create-first { padding: .65rem 1.25rem; font-size: .875rem; }

/* Hover signals with colour, press with 1px down — buttons never levitate. */
.btn-primary-soft:hover, .btn-save:hover, .btn-add-user:hover,
.btn-create-first:hover, .filter-apply:hover, .btn-auth:hover, .btn-pill.primary:hover {
    background: var(--primary-dark);
    color: #fff;
}
.btn-primary-soft:active, .btn-save:active, .btn-add-user:active,
.btn-create-first:active, .filter-apply:active, .btn-auth:active,
.btn-pill:active, .btn-quick-add:active, .btn-reset:active { transform: translateY(1px); }

.btn-ghost, .btn-cancel, .filter-clear {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    background: var(--gray-100); color: var(--text-muted);
    border: none; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .82rem;
    cursor: pointer; white-space: nowrap;
    transition: var(--t-fast);
}
.btn-ghost, .filter-clear { padding: .55rem 1rem; }
.btn-cancel { padding: .75rem 1.5rem; background: var(--surface); border: 1px solid var(--border); font-size: .875rem; }
.btn-ghost:hover, .filter-clear:hover { background: var(--gray-200); color: var(--text-strong); }
.btn-cancel:hover { background: var(--surface-2); color: var(--text-strong); }

.btn-save, .btn-cancel { flex: 1; }

/* Tone variants used by feature pages */
.btn-pill {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem 1.1rem; border-radius: var(--radius-pill);
    font-weight: 600; font-size: .82rem; border: none;
    cursor: pointer; white-space: nowrap; color: #fff;
    transition: var(--t-fast);
}
/* Tone pills are secondary quick-actions sitting beside content, so they read
   as tinted chips rather than three saturated blocks. Declared after the base
   rule so they win the `color: #fff` there. */
.btn-pill.success { background: var(--success-bg); color: var(--success-fg); }
.btn-pill.success:hover { background: color-mix(in srgb, var(--success) 22%, transparent); color: var(--success-fg); }
.btn-pill.danger { background: var(--danger-bg); color: var(--danger-fg); }
.btn-pill.danger:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger-fg); }
.btn-pill.warning { background: var(--warning-bg); color: var(--warning-fg); }
.btn-pill.warning:hover { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--warning-fg); }
.btn-pill.ghost { background: var(--gray-100); color: var(--text-muted); }
.btn-pill.ghost:hover { background: var(--gray-200); color: var(--text-strong); }

.btn-reset {
    background: var(--warning-bg); color: var(--warning-fg); cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
    padding: .75rem 1.25rem; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .875rem;
    display: inline-flex; align-items: center; gap: .5rem;
    white-space: nowrap;
    transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn-reset:hover { background: color-mix(in srgb, var(--warning) 24%, transparent); }

.btn-back {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); border-radius: var(--radius-sm);
    color: var(--text-muted); border: 1px solid var(--border);
    transition: var(--t-fast); flex-shrink: 0;
}
.btn-back:hover { background: var(--surface-2); color: var(--primary); border-color: var(--gray-300); }

.action-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.action-btn {
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-xs); font-size: .875rem;
    transition: var(--t-fast);
}
/* Tint on hover — a table row shouldn't sprout three saturated squares */
.btn-view { background: var(--gray-100); color: var(--info); }
.btn-view:hover { background: var(--info-bg); color: var(--info-fg); }
.btn-edit { background: var(--gray-100); color: var(--warning); }
.btn-edit:hover { background: var(--warning-bg); color: var(--warning-fg); }
.btn-delete { background: var(--gray-100); color: var(--danger); }
.btn-delete:hover { background: var(--danger-bg); color: var(--danger-fg); }

/* Ripple: a span is injected on pointer-down by site.js */
.ripple-host { position: relative; overflow: hidden; }
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(255,255,255,.25);
    animation: ripple .45s var(--ease);
    pointer-events: none;
}


/* == 10. Forms ============================================================ */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 1.5rem; }
.form-column { display: flex; flex-direction: column; gap: 1.5rem; }
.form-group-modern { display: flex; flex-direction: column; gap: .5rem; }
@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; gap: 1.5rem; } }

.form-label {
    font-weight: 600; font-size: .875rem; color: var(--text-strong);
    display: flex; align-items: center; gap: .5rem;
}
.form-label i { color: var(--primary); font-size: .875rem; }
.required { color: var(--danger); font-size: 1rem; }

.input-icon-wrapper, .select-wrapper, .textarea-wrapper { position: relative; }
.input-icon-wrapper i.input-icon {
    position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: .875rem; pointer-events: none;
}
.textarea-icon {
    position: absolute; left: .8rem; top: .8rem;
    color: var(--text-muted); font-size: .875rem; pointer-events: none;
}
.select-icon {
    position: absolute; right: .8rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none; font-size: .75rem;
}

.form-control-modern, .form-control-textarea, .select-wrapper select, .auth-input {
    width: 100%;
    font-size: .875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-control-modern { padding: .75rem .75rem .75rem 2.3rem; }
.form-control-textarea { padding: .75rem .75rem .75rem 2.3rem; resize: vertical; }
.select-wrapper select { appearance: none; padding: .75rem 2.3rem .75rem .75rem; cursor: pointer; }
.auth-input { padding: .75rem .9rem; font-size: .9rem; }

.form-control-modern:focus, .form-control-textarea:focus,
.select-wrapper select:focus, .auth-input:focus {
    outline: none; border-color: var(--primary); box-shadow: var(--ring);
}

.validation-message { font-size: .75rem; color: var(--danger); display: flex; align-items: center; gap: .25rem; }
.form-hint { font-size: .72rem; color: var(--text-muted); display: flex; align-items: center; gap: .5rem; }
.form-hint i { font-size: .7rem; }

.validation-summary {
    background: var(--danger-bg);
    border-left: 3px solid var(--danger);
    color: var(--danger-fg);
    padding: 1rem; border-radius: var(--radius-sm);
    margin-bottom: 1.5rem; font-size: .875rem;
}
.validation-summary ul { margin: .5rem 0 0 1.5rem; }
.validation-summary ul:empty { display: none; }

.form-actions { display: flex; gap: 1rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
@media (max-width: 768px) { .form-actions { flex-direction: column; } }

.checkbox-row {
    display: flex; align-items: center; gap: .6rem;
    margin-bottom: 1.5rem; font-size: .875rem; color: var(--text); cursor: pointer;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); }

/* --- filter / toolbar --- */
.toolbar, .filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex; gap: .75rem; flex-wrap: wrap;
}
.toolbar { align-items: stretch; }
.filter-bar { align-items: flex-end; }
.toolbar .grow { flex: 1; min-width: 160px; }

.filter-field { display: flex; flex-direction: column; gap: .25rem; position: relative; }
.filter-field.grow { flex: 1 1 220px; }
.filter-field label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 700;
}
.filter-field input, .filter-field select {
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    padding: .55rem .75rem; font-size: .85rem; font-family: inherit;
    background: var(--surface); color: var(--text); min-width: 140px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.filter-field.grow input { width: 100%; padding-left: 2.1rem; }
.filter-field.grow > i {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: .8rem; pointer-events: none;
}
.filter-field input:focus, .filter-field select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.filter-apply, .filter-clear { padding: .55rem 1.1rem; font-size: .85rem; }

@media (max-width: 768px) {
    .filter-field, .filter-field select, .filter-field input { min-width: 0; width: 100%; }
    .filter-field { flex: 1 1 100%; }
    .filter-apply, .filter-clear { flex: 1; }
}

/* --- auth pages --- */
.auth-wrap { min-height: 82vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card {
    background: var(--surface); width: 100%; max-width: 430px;
    border-radius: var(--radius); padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border); text-align: center;
}
.auth-brand {
    display: inline-flex; align-items: center; gap: .5rem;
    font-weight: 700; font-size: 1.35rem; color: var(--text-strong); margin-bottom: 1.5rem;
}
.auth-brand i { color: var(--primary); font-size: 1.6rem; }
.auth-title { font-size: 1.55rem; font-weight: 700; color: var(--text-strong); margin: 0 0 .5rem; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin: 0 0 1.75rem; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; text-align: left; }
.auth-field { display: flex; flex-direction: column; gap: .4rem; }
.auth-field label { font-size: .8rem; font-weight: 600; color: var(--text-strong); display: flex; align-items: center; gap: .4rem; }
.auth-field label i { color: var(--primary); }
.auth-err { font-size: .72rem; color: var(--danger); }
.btn-auth { margin-top: .5rem; width: 100%; padding: .85rem; font-size: .95rem; border-radius: var(--radius-sm); }
.auth-switch { margin-top: 1.5rem; font-size: .85rem; color: var(--text-muted); }
.auth-switch a { color: var(--primary); font-weight: 600; }
/* Resending the code has to be a POST (it mutates state and needs an antiforgery
   token), so it is a submit button dressed as the link it reads as. */
.auth-linkish {
    background: none; border: 0; padding: 0; font: inherit;
    color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: underline;
}
.auth-linkish:hover { color: var(--primary-dark); }
.auth-footer { margin-top: 1.5rem; color: var(--text-muted); font-size: .78rem; }
.auth-forgot { text-align: right; margin-top: -.25rem; }
.auth-forgot a { font-size: .78rem; color: var(--primary); font-weight: 600; }
.auth-alert-box { color: var(--danger-fg); font-size: .85rem; text-align: left; }
.auth-alert-box ul {
    margin: 0 0 1rem; padding: .75rem 1rem .75rem 2.25rem;
    background: var(--danger-bg); border-left: 3px solid var(--danger);
    border-radius: var(--radius-xs); list-style: disc;
}
.auth-alert-box ul:empty { display: none; }
.auth-alert-box a { color: var(--primary); font-weight: 600; }
.auth-alert-ok {
    color: var(--success-fg); background: var(--success-bg);
    border-left: 3px solid var(--success); border-radius: var(--radius-xs);
    padding: .75rem 1rem; margin-bottom: 1rem;
    display: flex; align-items: center; gap: .5rem;
}


/* == 11. Progress ========================================================= */

.meter, .progress-custom {
    height: 8px;
    background: var(--gray-100);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.meter-fill, .progress-custom .bar {
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--primary);
    width: 0;                              /* site.js animates to data-width */
    transition: width var(--t-slow);
}
.meter.tall { height: 12px; }

.budget-row { margin-bottom: .9rem; }
.budget-row:last-child { margin-bottom: 0; }
.budget-row-top {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: .75rem; font-size: .82rem; margin-bottom: .3rem;
}
.budget-row-name { font-weight: 600; color: var(--text-strong); }
.budget-row-figure { color: var(--text-muted); font-size: .75rem; }

.repay-progress-wrapper {
    height: 26px; background: var(--gray-100);
    border-radius: var(--radius-pill); overflow: hidden; position: relative;
}
.repay-progress-fill {
    height: 100%; border-radius: var(--radius-pill);
    display: flex; align-items: center; justify-content: center;
    transition: width .8s var(--ease); min-width: 2.5rem;
}
.repay-progress-fill.lent { background: var(--success); }
.repay-progress-fill.borrowed { background: var(--danger); }
.repay-progress-fill.settled { background: var(--info); }
.repay-progress-text { font-size: .72rem; font-weight: 700; color: #fff; }


/* == 12. Alerts =========================================================== */

.feature-alert, .admin-alert {
    border-radius: var(--radius-sm);
    padding: .9rem 1.1rem;
    margin-bottom: 1.5rem;
    display: flex; align-items: center; gap: .6rem;
    font-size: .875rem; font-weight: 500;
}
.feature-alert.success, .admin-alert.success { background: var(--success-bg); color: var(--success-fg); border-left: 3px solid var(--success); }
.feature-alert.error, .admin-alert.error { background: var(--danger-bg); color: var(--danger-fg); border-left: 3px solid var(--danger); }
.feature-alert.warn { background: var(--warning-bg); color: var(--warning-fg); border-left: 3px solid var(--warning); }
.feature-alert.info { background: var(--info-bg); color: var(--info-fg); border-left: 3px solid var(--info); }

.delete-warning {
    background: var(--danger-bg); border: 1px solid var(--danger-bg);
    border-left: 3px solid var(--danger); color: var(--danger-fg);
    padding: 1rem 1.25rem; border-radius: var(--radius-sm); margin-bottom: 1.5rem;
    display: flex; align-items: center; gap: .75rem; font-size: .875rem;
}

.insight-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--tone, var(--primary));
    border-radius: var(--radius-sm);
    padding: .85rem 1.1rem;
    box-shadow: var(--shadow-card);
    font-size: .85rem;
    display: flex; align-items: flex-start; gap: .6rem;
    transition: box-shadow var(--t);
}
.insight-card:hover { box-shadow: var(--shadow-card-hover); }
.insight-card i { color: var(--tone, var(--primary)); margin-top: .15rem; }
.insight-card.good { --tone: var(--success); }
.insight-card.warn { --tone: var(--warning); }
.insight-card.bad { --tone: var(--danger); }


/* == 13. Empty states ===================================================== */

.empty-state, .feature-empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-state i, .feature-empty i { font-size: 2.75rem; color: var(--gray-300); margin-bottom: 1rem; display: block; }
.empty-state h3, .feature-empty h3 { font-size: 1.15rem; margin-bottom: .5rem; color: var(--text-strong); font-weight: 700; }
.empty-state p, .feature-empty p { font-size: .88rem; max-width: 460px; margin: 0 auto 1.25rem; line-height: 1.6; }


/* == 14. Pagination ======================================================= */

.pager {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border);
}
.pager-summary { font-size: .8rem; color: var(--text-muted); }
.pager-links { display: flex; align-items: center; gap: .3rem; }
.pager-btn {
    min-width: 34px; height: 34px; padding: 0 .5rem;
    border-radius: var(--radius-xs);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .82rem; font-weight: 600;
    color: var(--text-muted); background: var(--gray-100);
    transition: var(--t-fast);
}
.pager-btn:hover { background: var(--gray-200); color: var(--text-strong); }
.pager-btn.active { background: var(--primary); color: #fff; }
.pager-btn.disabled { opacity: .4; pointer-events: none; }
.pager-gap { color: var(--text-muted); padding: 0 .2rem; }


/* == 15. Charts =========================================================== */

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; min-width: 320px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; font-size: .75rem; color: var(--text-muted); margin-top: .75rem; }
.chart-legend .key { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.chart-placeholder {
    height: 180px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: .85rem; gap: .5rem;
}

/* Range switcher above a chart */
.chart-range {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    padding: 3px; gap: 2px;
}
.chart-range button, .chart-range a {
    border: none; background: transparent; cursor: pointer;
    padding: .3rem .75rem; border-radius: var(--radius-pill);
    font-size: .72rem; font-weight: 600; color: var(--text-muted);
    transition: var(--t-fast);
}
.chart-range button:hover, .chart-range a:hover { color: var(--text-strong); }
.chart-range .active { background: var(--surface); color: var(--text-strong); box-shadow: 0 1px 2px rgba(16,24,40,.10); }


/* == 16. Overlays: dropdown, modal, toast, skeleton ======================= */

.menu-anchor { position: relative; }
.menu {
    transform-origin: top right;
    position: absolute;
    top: calc(100% + .5rem);
    right: 0;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: .4rem;
    z-index: 1060;
    display: none;
    animation: menuIn .16s var(--ease);
}
.menu.open { display: block; }
.menu-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .7rem;
    border-radius: var(--radius-xs);
    font-size: .84rem; color: var(--text);
    background: none; border: none; width: 100%;
    text-align: left; cursor: pointer;
    transition: var(--t-fast);
}
.menu-item:hover { background: var(--surface-2); color: var(--primary); }
.menu-item i { width: 1.1rem; text-align: center; color: var(--text-muted); }
.menu-item:hover i { color: var(--primary); }
.menu-label {
    font-size: .65rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); font-weight: 700; padding: .45rem .7rem .25rem;
}
.menu-sep { height: 1px; background: var(--border); margin: .3rem 0; }
.menu-empty { padding: .8rem .7rem; font-size: .8rem; color: var(--text-muted); text-align: center; }

.modal-backdrop-custom {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(2px);
    z-index: 1070;
    display: none;
    align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-backdrop-custom.open { display: flex; }
.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    width: 100%; max-width: 480px;
    animation: modalIn .2s var(--ease);
    overflow: hidden;
}
.modal-head { padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-weight: 700; font-size: 1rem; color: var(--text-strong); }
.modal-body { padding: 1.35rem; font-size: .88rem; }
.modal-foot { padding: 1rem 1.35rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

.toast-stack {
    position: fixed;
    right: 1.25rem; bottom: 1.25rem;
    z-index: 1080;
    display: flex; flex-direction: column; gap: .6rem;
    max-width: min(360px, calc(100vw - 2.5rem));
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--tone, var(--primary));
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .8rem 1rem;
    font-size: .85rem;
    display: flex; align-items: flex-start; gap: .6rem;
    animation: toastIn .22s var(--ease);
}
.toast.leaving { animation: toastOut .2s var(--ease) forwards; }
.toast.success { --tone: var(--success); }
.toast.error { --tone: var(--danger); }
.toast.warn { --tone: var(--warning); }
.toast i { color: var(--tone, var(--primary)); margin-top: .1rem; }
.toast-close { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; }

.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s var(--ease) infinite;
    border-radius: var(--radius-xs);
}
.skeleton-line { height: .75rem; margin-bottom: .5rem; }
.skeleton-line.short { width: 40%; }
.skeleton-card { height: 110px; border-radius: var(--radius); }


/* == 17. Feature modules ================================================== */

/* --- loans --- */
.loan-avatar {
    width: 44px; height: 44px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 1rem;
    flex-shrink: 0; text-transform: uppercase;
}
.loan-avatar.lent { background: var(--danger); }
.loan-avatar.borrowed { background: var(--success); }

.loan-type-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .15rem .6rem; border-radius: var(--radius-pill);
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.loan-type-badge.lent { background: var(--danger-bg); color: var(--danger-fg); }
.loan-type-badge.borrowed { background: var(--success-bg); color: var(--success-fg); }
.loan-type-badge.settled { background: var(--info-bg); color: var(--info-fg); }

.loan-amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0; }
.loan-amt { text-align: center; }
.loan-amt .amt-label {
    display: block; font-size: .6rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted); margin-bottom: .15rem;
}
.loan-amt .amt-value { font-size: .9rem; font-weight: 700; color: var(--text); }
.loan-amt .amt-value.principal { color: var(--text-strong); }
.loan-amt .amt-value.repaid { color: var(--success); }
.loan-amt .amt-value.outstanding { color: var(--warning); }

/* --- detail pages --- */
.detail-amount-banner {
    padding: 1.75rem 2rem;
    display: flex; flex-direction: column; gap: .25rem;
    color: #fff; border-bottom: 1px solid var(--border);
}
.detail-amount-banner.expense { background: var(--danger); }
.detail-amount-banner.income { background: var(--success); }
.detail-amount-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
.detail-amount-value { font-size: 2rem; font-weight: 700; }

.detail-list { margin: 0 0 1.5rem; }
.detail-row { display: flex; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--border-soft); }
.detail-row:last-child { border-bottom: none; }
.detail-row dt {
    flex: 0 0 180px; font-weight: 600; font-size: .8rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .03em;
    display: flex; align-items: center; gap: .5rem;
}
.detail-row dt i { color: var(--primary); }
.detail-row dd { margin: 0; font-size: .95rem; color: var(--text-strong); }
@media (max-width: 640px) {
    .detail-row { flex-direction: column; gap: .25rem; }
    .detail-row dt { flex-basis: auto; }
}

/* --- admin users --- */
.u-cell { display: flex; align-items: center; gap: .75rem; }
.u-avatar {
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.u-avatar.admin { background: #7C3AED; }
.u-name { font-weight: 600; color: var(--text-strong); font-size: .875rem; }
.u-email { font-size: .75rem; color: var(--text-muted); }

.stat-icon.total { background: var(--primary); color: #fff; }
.stat-icon.admins { background: #7C3AED; color: #fff; }
.stat-icon.active { background: var(--success); color: #fff; }

.reset-card { margin-top: 1.5rem; }
.reset-card .card-header-custom { color: var(--danger); }
.reset-row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.reset-row .form-group-modern { flex: 1; min-width: 220px; margin: 0; }


/* == 18. Animation, accessibility, print ================================== */

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes menuIn {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to { opacity: 1; transform: none; }
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(16px); }
}
@keyframes shimmer {
    from { background-position: 100% 50%; }
    to { background-position: 0 50%; }
}
@keyframes ripple {
    to { transform: scale(3); opacity: 0; }
}

.fade-in { animation: fadeUp .4s var(--ease) both; }

/* Focus is always visible for keyboard users, never a ring on mouse clicks */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}
.sidebar :focus-visible { outline-color: var(--primary-light); }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 1100;
    background: var(--primary); color: #fff;
    padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
    font-size: .85rem; font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .sidebar, .topbar, .app-footer, .sidebar-overlay,
    .action-buttons, .toolbar, .filter-bar, .pager, .toast-stack { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .card-modern, .panel, .entries-card, .summary-card, .stat-tile, .stat-card {
        box-shadow: none; break-inside: avoid;
    }
}


/* == 19. Phone layout ===================================================== */
/* Placed last on purpose: these override components defined above, and an
   @media block carries no extra specificity - only source order decides. */

/* --- phone layout: two-up cards instead of one long column ---------------- */
@media (max-width: 640px) {
    /* Eight full-width cards is ~1100px of scrolling before the first chart.
       Two-up halves that while staying readable at this size. */
    .summary-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
    .summary-card { padding: .85rem .9rem; }
    .summary-card .summary-value { font-size: 1.3rem; }
    .summary-card .summary-icon { width: 32px; height: 32px; font-size: .8rem; border-radius: 9px; }
    .summary-caption, .summary-delta { font-size: .65rem; }
    .sparkline { height: 26px; }

    /* The hero keeps the full width - it is the headline figure. */
    .summary-card.hero-card { grid-column: 1 / -1; }

    /* Same treatment for the feature-page stat tiles. */
    .stats-cards { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
    .stat-card { padding: .85rem .9rem; flex-direction: column; align-items: flex-start; gap: .5rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
    .stat-info h3 { font-size: 1.15rem; }
    .stat-info p { font-size: .66rem; }

    /* Filter fields were each forced to 100%, stacking into a 325px wall.
       Let the short ones pair up; only the search box needs a full row. */
    .filter-bar { padding: .8rem .9rem; gap: .6rem; }
    .filter-field { flex: 1 1 calc(50% - .3rem); min-width: 0; }
    .filter-field.grow { flex: 1 1 100%; }
    .filter-field input, .filter-field select { width: 100%; min-width: 0; }
    .filter-apply, .filter-clear { flex: 1 1 calc(50% - .3rem); justify-content: center; }

    .page-title { font-size: 1.35rem; }
    .page-subtitle { font-size: .82rem; }
}
