/* ============================================
   WONDERWISE DESIGN SYSTEM
   Neutral · Monochrome · Clean
   Inspired by Linear, shadcn/ui, Vercel
   ============================================ */

/* Hide number input spinners globally */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ── Light Theme ── */
:root {
    --bg: #ffffff;
    --bg-subtle: #f9fafb;
    --bg-muted: #f3f4f6;
    --bg-hover: #eef0f3;
    --bg-active: #e5e7eb;
    --bg-overlay: rgba(0,0,0,0.4);

    --fg: #111827;
    --fg-secondary: #4b5563;
    --fg-muted: #5f6876;
    --fg-faint: #d1d5db;
    --fg-inverse: #ffffff;
    --code-fg: #b4235a;
    --semantic-fg: #ffffff;

    --border: #e5e7eb;
    --border-subtle: #f0f1f3;
    --border-strong: #d1d5db;

    /* Brand accent — blue, used sparingly */
    --accent: #006FCF;
    --accent-fg: #ffffff;
    --accent-hover: #005FB3;
    --accent-light: #EBF5FF;
    --accent-muted: rgba(0,133,245,0.08);

    /* Semantic colors — richer tones */
    --red: #b91c1c;
    --red-bg: #fef2f2;
    --red-muted: rgba(220,38,38,0.08);
    --green: #047857;
    --green-bg: #ecfdf5;
    --green-muted: rgba(5,150,105,0.08);
    --yellow: #a16207;
    --yellow-bg: #fffbeb;
    --yellow-muted: rgba(217,119,6,0.08);
    --blue: #2563eb;
    --blue-bg: #eff6ff;
    --blue-muted: rgba(37,99,235,0.08);
    --purple: #7c3aed;
    --purple-bg: #f5f3ff;

    /* Sidebar */
    --sidebar-bg: #f9fafb;
    --sidebar-border: #e5e7eb;
    --sidebar-fg: #6b7280;
    --sidebar-fg-active: #111827;
    --sidebar-hover: #f3f4f6;
    --sidebar-active-bg: var(--accent-muted);
    --sidebar-active-fg: var(--accent);

    /* Dimensions */
    --sidebar-w: 220px;
    --sidebar-collapsed: 56px;
    --topbar-h: 52px;
    --mobile-nav-h: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Transitions */
    --ease: 150ms ease;
    --ease-slow: 250ms ease;

    /* Legacy page aliases. Keep older screens on the shared theme tokens. */
    --bg-color: var(--bg);
    --bg-light: var(--bg-subtle);
    --card-bg: var(--bg);
    --text-muted: var(--fg-muted);
    --border-color: var(--border);
    --border-light: var(--border-subtle);
    --primary: var(--accent);
    --primary-color: var(--accent);
    --danger: var(--red);
    --danger-color: var(--red);
    --success: var(--green);
    --success-color: var(--green);
    --info: var(--blue);
}

/* ── Dark Theme — TRUE BLACK ── */
[data-theme="dark"] {
    --bg: #161618;
    --bg-subtle: #1c1c1f;
    --bg-muted: #232326;
    --bg-hover: #2a2a2e;
    --bg-active: #313136;
    --bg-overlay: rgba(0,0,0,0.6);

    --fg: #e8e8ec;
    --fg-secondary: #a0a0a8;
    --fg-muted: #94949e;
    --fg-faint: #3a3a42;
    --fg-inverse: #161618;
    --code-fg: #ff8ab5;
    --semantic-fg: #161618;

    --border: #2a2a30;
    --border-subtle: #222228;
    --border-strong: #3e3e46;

    --accent: #4DA6F7;
    --accent-fg: #161618;
    --accent-hover: #7BC0FA;
    --accent-light: rgba(77,166,247,0.12);
    --accent-muted: rgba(77,166,247,0.08);

    --red: #f87171;
    --red-bg: #261212;
    --red-muted: rgba(248,113,113,0.12);
    --green: #34d399;
    --green-bg: #0f2418;
    --green-muted: rgba(52,211,153,0.12);
    --yellow: #fbbf24;
    --yellow-bg: #231e0a;
    --yellow-muted: rgba(251,191,36,0.12);
    --blue: #60a5fa;
    --blue-bg: #121d30;
    --blue-muted: rgba(96,165,250,0.12);
    --purple: #a78bfa;
    --purple-bg: #1c182e;

    --sidebar-bg: #131315;
    --sidebar-border: #2a2a30;
    --sidebar-fg: #8b8b96;
    --sidebar-fg-active: #e8e8ec;
    --sidebar-hover: #1e1e22;
    --sidebar-active-bg: rgba(129,140,248,0.12);
    --sidebar-active-fg: #4DA6F7;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    transition: background var(--ease), color var(--ease);
}

html.mobile-sidebar-open {
    overflow: hidden;
    overscroll-behavior: none;
}

body.mobile-sidebar-open {
    position: fixed;
    right: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

#wrapper { min-height: 100vh; }
#content-wrapper { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg) !important; }
#content { flex: 1; }
.container-fluid { padding: 0 24px 24px; }

a { color: var(--fg); }
a:hover { text-decoration: none; }
code { color: var(--code-fg); }

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--fg); letter-spacing: -0.02em; margin-top: 0; }
.page-title { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.3; }
.page-subtitle { font-size: 0.8rem; color: var(--fg-secondary); font-weight: 400; margin-top: 2px; }
.section-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); margin-bottom: 10px; }
.text-mono { font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.85em; }

/* ── SIDEBAR ── */
#accordionSidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    max-width: var(--sidebar-w) !important;
    background: var(--sidebar-bg) !important;
    background-image: none !important;
    border-right: 1px solid var(--sidebar-border);
    transition: width var(--ease-slow), min-width var(--ease-slow), max-width var(--ease-slow), transform var(--ease-slow);
    overflow: hidden;
    z-index: 1040;
    display: flex;
    flex-direction: column;
}
#accordionSidebar.toggled {
    width: var(--sidebar-collapsed) !important;
    min-width: var(--sidebar-collapsed) !important;
    max-width: var(--sidebar-collapsed) !important;
}
/* Push content to the right of fixed sidebar */
#content-wrapper {
    margin-left: var(--sidebar-w);
    transition: margin-left var(--ease-slow);
}
body.sidebar-toggled #content-wrapper {
    margin-left: var(--sidebar-collapsed);
}

/* Brand */
.sidebar-brand {
    padding: 14px 16px !important;
    height: auto !important;
    min-height: var(--topbar-h);
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    text-decoration: none !important;
    flex-shrink: 0;
}
.sidebar-brand img {
    height: 18px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar-logo-dark { display: none; }
[data-theme="dark"] .sidebar-logo-light { display: none; }
[data-theme="dark"] .sidebar-logo-dark { display: block; }

/* Nav scroll area */
#sidebar_nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}
#sidebar_nav::-webkit-scrollbar { width: 3px; }
#sidebar_nav::-webkit-scrollbar-track { background: transparent; }
#sidebar_nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 3px; }

/* Divider between groups */
.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 8px 16px !important;
    border: none !important;
}

/* Group label */
.sidebar-group-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
    padding: 12px 18px 6px;
    white-space: nowrap;
}

/* Nav items */
#accordionSidebar .nav-item { margin: 2px 10px; }
#accordionSidebar .nav-item .nav-link {
    color: var(--sidebar-fg) !important;
    font-weight: 500;
    font-size: 0.88rem;
    padding: 10px 12px !important;
    border-radius: var(--radius-lg);
    border-left: none !important;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--ease);
    white-space: nowrap;
}
#accordionSidebar .nav-item .nav-link i {
    font-size: 0.92rem;
    width: 20px;
    text-align: center;
    color: var(--fg-muted);
    flex-shrink: 0;
    transition: color var(--ease);
}
#accordionSidebar .nav-item .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-fg-active) !important;
}
#accordionSidebar .nav-item .nav-link:hover i { color: var(--sidebar-fg-active); }
#accordionSidebar .nav-item .nav-link.active {
    background: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-fg) !important;
    font-weight: 600;
}
#accordionSidebar .nav-item .nav-link.active i { color: var(--sidebar-active-fg); }

/* ── Collapsed state ── */
#accordionSidebar.toggled .sidebar-brand img { height: 22px; width: 22px; }
#accordionSidebar.toggled .sidebar-brand { justify-content: center; padding: 14px 0 !important; }
#accordionSidebar.toggled .sidebar-group-label { display: none !important; }
#accordionSidebar.toggled .sidebar-divider { margin: 6px 8px !important; }
#accordionSidebar.toggled .nav-item { margin: 2px 6px; }
#accordionSidebar.toggled .nav-item .nav-link span { display: none !important; }
#accordionSidebar.toggled .nav-item .nav-link {
    justify-content: center;
    padding: 10px !important;
    border-radius: var(--radius);
}
#accordionSidebar.toggled .nav-item .nav-link i { margin: 0; }
#accordionSidebar.toggled .sidebar-collapse-btn i { transform: rotate(180deg); }

/* Sidebar bottom — collapse toggle */
.sidebar-bottom {
    padding: 8px 10px;
    flex-shrink: 0;
}
.sidebar-collapse-btn {
    width: 100%;
    height: 28px;
    border: none;
    border-radius: var(--radius);
    background: none;
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.6875rem;
    padding: 0;
    opacity: 0.3;
    transition: opacity var(--ease);
}
.sidebar-collapse-btn i {
    transition: transform 0.2s ease;
}
.sidebar-collapse-btn:hover {
    opacity: 0.7;
}

#sidebarToggleTop {
    background: none !important;
    border: none;
    color: var(--fg-muted);
    gap: 5px;
    padding: 0 8px;
    width: auto; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
}
#sidebarToggleTop:hover { background: var(--bg-hover) !important; color: var(--fg); }
#sidebarToggleTop.active { background: var(--accent-muted) !important; color: var(--accent); }
.topbar-more-label { font-size: .72rem; font-weight: 650; }

/* ── TOPBAR ── */
.topbar {
    height: var(--topbar-h) !important;
    background: var(--bg) !important;
    border-bottom: 1px solid var(--border);
    box-shadow: none !important;
    padding: 0 20px !important;
    transition: background var(--ease), border var(--ease);
    z-index: 1030;
}
.topbar .navbar-nav { align-items: center; }

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}
.topbar-breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.topbar-breadcrumb a:hover { color: var(--fg); }
.topbar-breadcrumb .separator { color: var(--fg-faint); font-size: 0.6875rem; }
.topbar-breadcrumb .current { color: var(--fg); font-weight: 500; }

.topbar-action-btn {
    width: 32px; height: 32px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease);
    font-size: 0.85rem;
}
.topbar-action-btn:hover { background: var(--bg-hover); color: var(--fg); }

.theme-toggle { cursor: pointer; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none !important;
    margin-left: 4px;
}
.topbar-user:hover { background: var(--bg-hover); }
.topbar-user img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.topbar-user-name { font-size: 0.8rem; font-weight: 500; color: var(--fg); }
.topbar-user-role { font-size: 0.6875rem; color: var(--fg-muted); }

/* Dropdown */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    padding: 4px;
    background: var(--bg);
    min-width: 180px;
}
[data-theme="dark"] .dropdown-menu { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.dropdown-item {
    border-radius: var(--radius);
    padding: 7px 10px;
    font-size: 0.82rem;
    color: var(--fg);
    transition: background var(--ease);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--fg); }
.dropdown-item i { width: 16px; margin-right: 8px; color: var(--fg-muted); font-size: 0.8rem; }
.dropdown-divider { border-color: var(--border); margin: 3px 0; }

/* ── CARDS ── */
.card {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: none;
    transition: border-color var(--ease);
}
.card:hover { border-color: var(--border-strong); }
.card-body { padding: 16px; }
.list-group-item { background: transparent; color: var(--fg); border-color: var(--border); }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* KPI Cards */
.kpi-card {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: border-color var(--ease);
    position: relative;
}
.kpi-card:hover { border-color: var(--border-strong); }
.kpi-label { font-size: 0.7rem; font-weight: 500; color: var(--fg-muted); margin-bottom: 6px; letter-spacing: 0.01em; }
.kpi-value { font-size: 1.25rem; font-weight: 700; color: var(--fg); letter-spacing: -0.03em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 0.7rem; color: var(--fg-muted); margin-top: 4px; }
.kpi-icon { position: absolute; right: 14px; top: 14px; font-size: 0.9rem; color: var(--fg-faint); }

/* KPI card color accents — tinted icon + colored label */
.kpi-primary .kpi-icon { color: var(--accent); opacity: 0.15; }
.kpi-primary .kpi-label { color: var(--accent); }

.kpi-success .kpi-icon { color: var(--green); opacity: 0.15; }
.kpi-success .kpi-label { color: var(--green); }

.kpi-danger .kpi-icon { color: var(--red); opacity: 0.15; }
.kpi-danger .kpi-label { color: var(--red); }

.kpi-warning .kpi-icon { color: var(--yellow); opacity: 0.15; }
.kpi-warning .kpi-label { color: var(--yellow); }

.kpi-info .kpi-icon { color: var(--blue); opacity: 0.15; }
.kpi-info .kpi-label { color: var(--blue); }

.kpi-accent .kpi-icon { color: var(--purple, var(--fg-secondary)); opacity: 0.15; }
.kpi-accent .kpi-label { color: var(--purple, var(--fg-secondary)); }

/* Account cards — fill row evenly */
.account-strip {
    display: flex;
    gap: 8px;
}

.account-card {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    flex: 1;
    min-width: 0;
    position: relative;
    transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}
.account-card .ac-label { font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.account-card .ac-value { font-size: 0.88rem; font-weight: 700; margin-top: 3px; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.account-card--fill { border-color: transparent; }
.account-card--fill .ac-label,
.account-card--fill .ac-value { color: #fff; }
.account-card--total { background: var(--fg); }
[data-theme="dark"] .account-card--fill { position: relative; }
[data-theme="dark"] .account-card--fill::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.3); border-radius: inherit; pointer-events: none; }
[data-theme="dark"] .account-card--fill .ac-label,
[data-theme="dark"] .account-card--fill .ac-value { position: relative; z-index: 1; }
[data-theme="dark"] .account-card--total { background: #000; }
[data-theme="dark"] .account-card--total::after { display: none; }

/* Gradient card (DEPRECATED — kept for compat, no gradient) */
.gradient-card {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    min-width: 130px;
}
.gradient-card .gc-label { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); }
.gradient-card .gc-value { font-size: 1rem; font-weight: 700; margin-top: 4px; color: var(--fg); }
.gradient-card::after { display: none; }

/* ── BUTTONS ── */
.btn {
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.82rem;
    padding: 7px 14px;
    transition: all var(--ease);
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.4;
}
.btn:focus { box-shadow: none; outline: none; }

/* Primary = solid black (light) / solid white (dark) */
.btn-primary {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: var(--accent-fg) !important;
}
.btn-primary:hover { background: var(--accent-hover) !important; border-color: var(--accent-hover) !important; }

.btn-secondary { background: var(--bg-muted); border-color: var(--border); color: var(--fg); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--fg); }

.btn-success { background: var(--green); border-color: var(--green); color: var(--semantic-fg); }
.btn-danger { background: var(--red); border-color: var(--red); color: var(--semantic-fg); }
.btn-warning { background: var(--yellow); border-color: var(--yellow); color: var(--semantic-fg); }
.btn-info { background: var(--blue); border-color: var(--blue); color: var(--semantic-fg); }

.btn-outline-primary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
.btn-outline-primary:hover { background: var(--bg-hover); color: var(--fg); border-color: var(--border-strong); }
.btn-outline-primary.active, .btn-outline-primary:active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.btn-ghost { background: transparent; color: var(--fg-secondary); border: none; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); }

.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon.sm { width: 26px; height: 26px; font-size: 0.75rem; }

.action-btns { display: flex; gap: 4px; }

/* ── FORMS ── */
.form-control, select.form-control {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 0.82rem;
    background: var(--bg);
    color: var(--fg);
    transition: border-color var(--ease);
    height: auto;
}
.form-control:focus, select.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
    background: var(--bg);
    color: var(--fg);
    outline: none;
}
.form-control::placeholder { color: var(--fg-muted); }

.form-label, label { font-size: 0.78rem; font-weight: 500; color: var(--fg-secondary); margin-bottom: 4px; }
.form-group { margin-bottom: 14px; }
.text-muted { color: var(--fg-muted) !important; }

/* ── TABLES ── */
.table { color: var(--fg); margin-bottom: 0; }
.table thead th {
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    border-top: none;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-muted);
    padding: 8px 14px;
    white-space: nowrap;
}
.table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    border-top: none;
    font-size: 0.82rem;
    vertical-align: middle;
}
.table tbody tr { transition: background var(--ease); }
.table tbody tr:hover { background: var(--bg-hover) !important; }
.table-striped tbody tr:nth-of-type(odd) { background: var(--bg-subtle); }

/* DataTables */
.dataTables_wrapper { padding-top: 4px; }
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    font-size: 0.82rem;
    background: var(--bg);
    color: var(--fg);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
    outline: none;
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 8px;
    background: var(--bg);
    color: var(--fg);
    font-size: 0.82rem;
}
.dataTables_wrapper .dataTables_info {
    font-size: 0.75rem;
    color: var(--fg-muted);
    padding-top: 12px;
}
/* ── Pagination — override sb-admin-2 + Bootstrap 4 + DataTables ── */
.dataTables_wrapper .dataTables_paginate { margin: 0; }
.dataTables_wrapper .dataTables_paginate ul.pagination {
    margin: 0 !important; gap: 2px; flex-wrap: nowrap; justify-content: flex-end;
}
.pagination .page-item .page-link,
.dataTables_wrapper .pagination .page-item .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex !important; align-items: center !important; justify-content: center !important;
    border: none !important; border-radius: 4px !important;
    margin: 0 !important; margin-left: 0 !important; padding: 0 6px !important;
    min-width: 28px; height: 28px;
    font-size: 0.72rem !important; font-weight: 500; line-height: 1 !important;
    color: var(--fg-secondary) !important;
    background-color: transparent !important; background: transparent !important;
    cursor: pointer; transition: background-color 80ms, color 80ms;
    box-shadow: none !important; outline: none !important;
}
.pagination .page-item.active .page-link,
.dataTables_wrapper .pagination .page-item.active .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background-color: var(--fg) !important; background: var(--fg) !important;
    color: var(--bg) !important;
    border-color: var(--fg) !important;
    font-weight: 600;
}
.pagination .page-item:not(.active):not(.disabled) .page-link:hover,
.dataTables_wrapper .pagination .page-item:not(.active):not(.disabled) .page-link:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
    background-color: var(--bg-hover) !important; background: var(--bg-hover) !important;
    color: var(--fg) !important;
}
.pagination .page-item.disabled .page-link,
.dataTables_wrapper .pagination .page-item.disabled .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: var(--fg-faint) !important;
    background-color: transparent !important; background: transparent !important;
    border-color: transparent !important;
    cursor: default; opacity: 0.35; pointer-events: none;
}
.pagination .page-item:first-child .page-link,
.pagination .page-item:last-child .page-link {
    font-size: 0.7rem !important; color: var(--fg-muted) !important; min-width: auto;
    border-radius: 4px !important;
}
.dataTables_wrapper .dataTables_paginate .ellipsis {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; font-size: 0.7rem; color: var(--fg-faint); cursor: default;
}
.pagination .page-link:focus {
    box-shadow: none !important; outline: none !important;
}
/* Bottom bar layout */
.dataTables_wrapper .dataTables_info { float: left; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { padding-top: 10px; padding-bottom: 4px; }
/* Fix DT filter/length bottom margin */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { margin-bottom: 12px; }
/* Table header */
.dataTables_wrapper table.dataTable thead th {
    border-bottom: 1px solid var(--border) !important;
    border-top: none !important;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    padding: 8px 10px !important;
    background: transparent;
    white-space: nowrap;
}
.dataTables_wrapper table.dataTable thead th:first-child { padding-left: 16px !important; }
.dataTables_wrapper table.dataTable thead th:last-child { padding-right: 16px !important; }
.dataTables_wrapper table.dataTable tbody td {
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 10px !important;
    vertical-align: middle;
    font-size: 0.8rem;
}
.dataTables_wrapper table.dataTable tbody td:first-child { padding-left: 16px !important; }
.dataTables_wrapper table.dataTable tbody td:last-child { padding-right: 16px !important; }
.dataTables_wrapper table.dataTable tbody tr:hover {
    background: var(--bg-hover) !important;
}
/* Compact action buttons inside tables */
.dataTables_wrapper .action-btns { gap: 2px; justify-content: flex-end; }
.dataTables_wrapper .action-btns .btn-icon {
    width: 24px; height: 24px;
    font-size: 0.6875rem;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 100ms ease;
}
.dataTables_wrapper tbody tr:hover .action-btns .btn-icon { opacity: 1; }
/* Pagination bottom spacing inside cards */
.card-body .dataTables_wrapper .dataTables_info,
.card-body .dataTables_wrapper .dataTables_paginate { padding-left: 16px; padding-right: 16px; }
/* Alignment helpers for DT */
table.dataTable th.text-right, table.dataTable td.text-right { text-align: right !important; }
table.dataTable th.text-center, table.dataTable td.text-center { text-align: center !important; }
table.dataTable th.text-muted, table.dataTable td.text-muted { color: var(--fg-muted) !important; }
/* No bottom border on last row */
.dataTables_wrapper table.dataTable tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge { font-weight: 500; font-size: 0.6875rem; padding: 3px 8px; border-radius: 100px; letter-spacing: 0.01em; }
.badge-primary, .bg-primary { background: var(--accent) !important; color: var(--accent-fg) !important; }
.badge-success, .bg-success { background: var(--green) !important; color: var(--semantic-fg) !important; }
.badge-danger, .bg-danger { background: var(--red) !important; color: var(--semantic-fg) !important; }
.badge-warning, .bg-warning { background: var(--yellow) !important; color: var(--semantic-fg) !important; }
.badge-info, .bg-info { background: var(--blue) !important; color: var(--semantic-fg) !important; }
.badge-secondary, .bg-secondary { background: var(--bg-muted) !important; color: var(--fg-secondary) !important; }

.badge-soft-primary { background: var(--accent-light); color: var(--accent); }
.badge-soft-success { background: var(--green-bg); color: var(--green); }
.badge-soft-danger { background: var(--red-bg); color: var(--red); }
.badge-soft-warning { background: var(--yellow-bg); color: var(--yellow); }
.badge-soft-info { background: var(--blue-bg); color: var(--blue); }
.badge-soft-purple { background: var(--purple-bg); color: var(--purple); }

/* ── MODALS ── */
.modal-content {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: 0 16px 48px rgba(0,0,0,0.12);
    background: var(--bg);
}
[data-theme="dark"] .modal-content { box-shadow: 0 16px 48px rgba(0,0,0,0.5); }
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title { font-weight: 600; font-size: 0.95rem; color: var(--fg); }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 20px; }
.modal-backdrop { opacity: 0.4 !important; }
[data-theme="dark"] .modal-backdrop { opacity: 0.7 !important; }
.close { background: none; border: none; color: var(--fg-muted); opacity: 0.6; font-size: 1.3rem; }
.close:hover { opacity: 1; color: var(--fg); }

/* ── TOASTS ── */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ww-toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.2s ease;
    width: min(360px, calc(100vw - 40px));
    border: 1px solid;
}
.ww-toast > i { flex-shrink: 0; margin-top: 2px; }
.ww-toast > span { min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
.ww-toast.success { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.ww-toast.error { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.ww-toast.warning { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow); }
.ww-toast.info { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.ww-toast .toast-close { flex-shrink: 0; margin-left: auto; background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--fg-muted); }
.empty-state i { font-size: 2rem; margin-bottom: 12px; opacity: 0.3; }
.empty-state h5 { color: var(--fg-secondary); font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }
.empty-state p { font-size: 0.82rem; max-width: 320px; margin: 0 auto; }

/* ── LOADING ── */
#page_content { transition: opacity var(--ease); }
#page_content.loading { opacity: 0.3; pointer-events: none; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* ── MOBILE BOTTOM NAV ── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--mobile-nav-h);
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 1050;
    padding: 0;
}
.mobile-nav-items { display: flex; height: 100%; align-items: center; justify-content: space-around; }
.mobile-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 10px; border-radius: var(--radius);
    border: 0; background: transparent; color: inherit;
    font: inherit; text-decoration: none;
}
.mobile-nav-item i { font-size: 1rem; color: var(--fg-muted); }
.mobile-nav-item span { font-size: 0.6875rem; font-weight: 500; color: var(--fg-muted); }
.mobile-nav-item.active i, .mobile-nav-item.active span { color: var(--accent); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    #accordionSidebar {
        transform: translateX(-100%);
        box-shadow: none;
        transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 260ms ease;
    }
    #accordionSidebar.show-mobile {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    #content-wrapper {
        margin-left: 0 !important;
        padding-bottom: var(--mobile-nav-h);
    }
    .mobile-bottom-nav { display: block; }
    .sidebar-collapse-btn { display: none !important; }
    /* Overlay behind sidebar when open on mobile */
    .sidebar-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        z-index: 1039;
    }
    .container-fluid { padding: 0 14px 14px; }
    .topbar { padding: 0 14px !important; }
    .grid-2 { grid-template-columns: 1fr !important; }
    .grid-3 { grid-template-columns: 1fr !important; }
    .grid-md-3 { grid-template-columns: 1fr 1fr !important; }
    .modal-dialog.modal-lg { max-width: 95vw; margin: 10px auto; }
    .modal-body { padding: 16px; }
    .action-btns .btn-icon { padding: 4px 6px; }
    .table td, .table th { font-size: 13px; padding: 8px 6px; }
    .account-strip { gap: 6px; }
    .account-card { min-width: 120px; padding: 8px 10px; }
    .account-card .ac-value { font-size: 0.82rem; }
    .page-title { font-size: 1.1rem !important; }
    .page-subtitle { font-size: 0.75rem !important; }
}
@media (max-width: 480px) {
    .account-card { min-width: 110px; }
}

/* ── LAYOUT UTILS ── */
/* Wrap instead of fixed columns so the last row always fills the width.
   Fixed column counts left holes whenever the card count did not divide evenly. */
.kpi-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.kpi-grid > * { flex: 1 1 190px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-md-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
/* account-strip scrollable wrapper */
.account-strip-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.account-strip-wrap::-webkit-scrollbar { display: none; }
.account-strip { min-width: max-content; }
.account-card.active { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius);
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Money visibility — replace with dots, animated */
.money-value { transition: opacity 0.2s ease; }
.money-hidden .money-value { font-size: 0 !important; }
.money-hidden .money-value::before {
    content: '••••';
    font-size: 0.85rem;
    color: var(--fg-faint);
    letter-spacing: 3px;
}
.money-chart { transition: opacity 0.2s ease; }
.money-hidden .money-chart { opacity: 1; }

/* Chart cards */
.chart-card { min-height: auto; }

/* ── FOOTER ── */
.sticky-footer {
    background: var(--bg) !important;
    border-top: 1px solid var(--border);
    padding: 14px 0;
    font-size: 0.75rem;
    color: var(--fg-muted);
}

/* ── LOGIN ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}
.login-card { width: 100%; max-width: 380px; }

/* ── Remove SB Admin gradient overrides ── */
.bg-gradient-primary, .bg-gradient-success, .bg-gradient-info,
.bg-gradient-warning, .bg-gradient-danger, .bg-gradient-secondary {
    background-image: none !important;
    background: var(--bg-muted) !important;
}
.border-left-primary, .border-left-success, .border-left-danger,
.border-left-warning, .border-left-info { border-left: none !important; }

/* ── Filter Pills ── */
.filter-pill {
    background: var(--bg-muted);
    color: var(--fg-muted);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all var(--ease);
    white-space: nowrap;
}
.filter-pill:hover {
    background: var(--bg);
    color: var(--fg);
    border-color: var(--fg-muted);
}
.filter-pill.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

/* ── Internal Toggle Buttons ── */
.internal-toggle {
    background: var(--bg-muted);
    color: var(--fg-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-weight: 500;
    transition: all var(--ease);
}
.internal-toggle:hover {
    background: var(--bg);
    color: var(--fg);
}
.internal-toggle.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

/* ── Mobile responsive helpers ── */
@media (max-width: 576px) {
    #account_summary .card { min-width: 0 !important; }
    #account_summary .card-body { padding: 6px 8px !important; }
    #account_summary .font-weight-bold { font-size: 0.85rem; }
}

/* ══════════════════════════════════════════
   REPORT PAGE
   ══════════════════════════════════════════ */

/* Config panel */
.report-config-panel {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
}

/* ── Type selector strip ── */
.report-type-strip-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin: -16px -16px 14px; padding: 16px 16px 0;
}
.report-type-strip-wrap::-webkit-scrollbar { display: none; }
.report-type-strip { display: flex; gap: 6px; min-width: max-content; }
.report-type-btn {
    display: flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg);
    color: var(--fg-secondary); font-size: 0.78rem; font-weight: 500;
    cursor: pointer; transition: all var(--ease); white-space: nowrap; flex-shrink: 0;
}
.report-type-btn i { font-size: 0.78rem; color: var(--fg-muted); transition: color var(--ease); }
.report-type-btn:hover { border-color: var(--border-strong); color: var(--fg); background: var(--bg-hover); }
.report-type-btn.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.report-type-btn.active i { color: var(--accent-fg); }

/* ── Controls: single flexible row ── */
.report-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Mode toggle */
.report-mode-group {
    display: inline-flex; border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; flex-shrink: 0;
}
.report-mode-btn {
    padding: 6px 10px; font-size: 0.74rem; font-weight: 500;
    color: var(--fg-secondary); background: var(--bg);
    border: none; border-right: 1px solid var(--border);
    cursor: pointer; transition: all var(--ease); white-space: nowrap;
    display: flex; align-items: center; gap: 5px;
}
.report-mode-btn:last-child { border-right: none; }
.report-mode-btn i { font-size: 0.7rem; color: var(--fg-muted); }
.report-mode-btn:hover { background: var(--bg-hover); color: var(--fg); }
.report-mode-btn.active { background: var(--fg); color: var(--bg); }
.report-mode-btn.active i { color: var(--bg); }
[data-theme="dark"] .report-mode-btn.active { background: var(--accent); color: var(--accent-fg); }
[data-theme="dark"] .report-mode-btn.active i { color: var(--accent-fg); }

/* Date section */
.report-date-section { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.report-date-inputs { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.report-date-inputs .form-control { width: 130px; padding: 6px 8px; font-size: 0.78rem; }
.report-date-sep { color: var(--fg-muted); font-size: 0.78rem; }

/* Presets */
.report-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.report-preset {
    padding: 4px 10px; font-size: 0.7rem; font-weight: 500;
    border-radius: 100px; border: 1px solid var(--border);
    background: var(--bg); color: var(--fg-muted);
    cursor: pointer; transition: all var(--ease); white-space: nowrap;
}
.report-preset:hover { border-color: var(--border-strong); color: var(--fg); }
.report-preset.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
[data-theme="dark"] .report-preset.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Filter select inline */
.report-filter-select {
    width: auto; min-width: 140px; max-width: 200px;
    padding: 6px 8px; font-size: 0.78rem; flex-shrink: 0;
}

/* Generate — rightmost on desktop */
.report-generate-btn {
    padding: 7px 18px; font-weight: 600; font-size: 0.8rem;
    white-space: nowrap; flex-shrink: 0; margin-left: auto;
}

/* ── Results bar ── */
.report-results-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.report-results-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-results-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Table helpers */
.report-table-top { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.report-table-bottom {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 8px; padding-top: 10px;
}

/* Totals row */
.report-totals-row { font-weight: 700; border-top: 2px solid var(--border-strong) !important; background: var(--bg-muted) !important; }
.report-totals-row td { border-bottom: none !important; padding-top: 10px !important; padding-bottom: 10px !important; }
.report-totals-label { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-secondary); }
.report-totals-val { font-weight: 700; }

/* ── Print ── */
@media print {
    .report-config-panel, .mobile-bottom-nav, #accordionSidebar,
    .topbar, .sidebar-bottom, .sticky-footer,
    .report-results-actions, .toast-container { display: none !important; }
    #content-wrapper { padding: 0 !important; }
    .kpi-card { break-inside: avoid; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .report-config-panel { padding: 12px; }
    .report-type-strip-wrap { margin: -12px -12px 12px; padding: 12px 12px 0; }
    .report-type-btn { padding: 6px 10px; font-size: 0.74rem; }
    .report-controls { flex-direction: column; align-items: stretch; gap: 10px; }
    .report-mode-group { width: 100%; display: flex; }
    .report-mode-btn { flex: 1; justify-content: center; padding: 9px 6px; font-size: 0.74rem; }
    .report-date-section { flex-direction: column; align-items: stretch; gap: 8px; }
    .report-date-section,
    .report-date-inputs,
    .report-presets {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .report-date-inputs .form-control { flex: 1; width: auto; min-width: 0; }
    .report-presets {
        overflow-x: auto; flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .report-presets::-webkit-scrollbar { display: none; }
    .report-filter-select { width: 100%; max-width: 100%; }
    .report-generate-btn { width: 100%; padding: 11px 20px; margin-left: 0; }
    .report-results-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
    .report-results-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 480px) {
    .report-type-btn { padding: 5px 8px; font-size: 0.7rem; gap: 5px; }
    .report-mode-btn span { font-size: 0.7rem; }
    .report-mode-btn i { display: none; }
    .report-preset { padding: 3px 8px; font-size: 0.6875rem; }
}

/* ══════════════════════════════════════════
   PWA + NATIVE MOBILE SHELL
   ══════════════════════════════════════════ */

[hidden] { display: none !important; }

html {
    min-height: 100%;
    max-width: 100%;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

button, a, input, select, textarea, [role="button"] {
    touch-action: manipulation;
}

button, a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent) !important;
    outline-offset: 2px;
    box-shadow: none;
}

#page_content:focus { outline: none !important; }

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: fixed;
    top: calc(8px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    z-index: 10001;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    transform: translateY(calc(-100% - var(--safe-top) - 16px));
}

.skip-link:focus-visible {
    color: var(--accent-fg);
    pointer-events: auto;
    transform: translateY(0);
}

.skip-link:focus:not(:focus-visible) {
    pointer-events: none;
    transform: translateY(calc(-100% - var(--safe-top) - 16px));
}

.sidebar-overlay {
    display: none;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    appearance: none;
}

/* Connection and update state */
.pwa-status-bar {
    min-height: 40px;
    padding: 8px max(16px, var(--safe-right)) 8px max(16px, var(--safe-left));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--fg-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    z-index: 1025;
}

.pwa-status-bar > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.pwa-status-bar.is-offline {
    background: var(--yellow-bg);
    border-color: color-mix(in srgb, var(--yellow) 30%, transparent);
    color: var(--yellow);
}

.pwa-status-bar.is-update {
    background: var(--blue-bg);
    border-color: color-mix(in srgb, var(--blue) 30%, transparent);
    color: var(--blue);
}

.pwa-status-bar.is-error {
    background: var(--red-bg);
    border-color: color-mix(in srgb, var(--red) 30%, transparent);
    color: var(--red);
}

.pwa-status-action,
.pwa-status-dismiss {
    min-width: 44px;
    min-height: 44px;
    padding: 4px 9px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.pwa-status-action {
    border: 1px solid currentColor;
    background: transparent;
}

.pwa-status-action:hover,
.pwa-status-dismiss:hover {
    filter: brightness(0.95);
}

.pwa-status-dismiss {
    flex: 0 0 44px;
    width: 44px;
    padding: 0;
    opacity: 0.75;
}

.checkbox-hit-target {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin: -10px 0;
    cursor: pointer;
}

.checkbox-hit-target > input[type="checkbox"] {
    width: 24px !important;
    height: 24px !important;
}

/* Initial app shell */
.app-shell-loader {
    width: 100%;
    animation: shellFadeIn 180ms ease both;
}

.app-shell-heading {
    width: min(260px, 70%);
    height: 28px;
    margin-bottom: 24px;
}

.app-shell-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.app-shell-card {
    min-height: 116px;
    border: 1px solid var(--border);
}

.app-page-skeleton {
    width: 100%;
    animation: shellFadeIn 160ms ease both;
}

.app-page-skeleton-heading {
    width: min(280px, 72%);
    height: 30px;
    margin-bottom: 22px;
}

.app-page-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.app-page-skeleton-card {
    min-height: 112px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.app-page-skeleton-panel {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
}

.app-page-skeleton-row {
    height: 52px;
    margin-bottom: 10px;
    border-radius: var(--radius);
}

.app-page-skeleton-row:last-child {
    width: 76%;
    margin-bottom: 0;
}

@keyframes shellFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#page_content {
    position: relative;
    min-width: 0;
    min-height: 180px;
}

#page_content.loading::after {
    content: '';
    position: fixed;
    left: calc(50% + (var(--sidebar-w) / 2));
    top: 50%;
    z-index: 20;
    width: 26px;
    height: 26px;
    margin: -13px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: pwaSpin 650ms linear infinite;
}

@keyframes pwaSpin {
    to { transform: rotate(360deg); }
}

/* Install surface */
.pwa-install-body {
    position: relative;
    padding: 30px 26px 22px;
    text-align: center;
}

.pwa-install-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 40px;
    height: 40px;
}

.pwa-install-icon {
    display: block;
    width: 76px;
    height: 76px;
    margin: 0 auto 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09);
}

.pwa-install-body h2 {
    margin: 0 0 7px;
    font-size: 1.15rem;
}

.pwa-install-body > p {
    margin: 0 auto 20px;
    max-width: 290px;
    color: var(--fg-secondary);
    font-size: 0.84rem;
}

.pwa-ios-steps {
    display: grid;
    gap: 9px;
    margin: 0 0 20px;
    text-align: left;
}

.pwa-ios-steps > div {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: var(--radius-lg);
    background: var(--bg-muted);
    color: var(--fg-secondary);
    font-size: 0.8rem;
}

.pwa-ios-steps i {
    width: 22px;
    color: var(--accent);
    text-align: center;
}

#pwa_notification_button.is-enabled {
    background: var(--green-bg);
    color: var(--green);
}

#pwa_notification_button.is-blocked {
    background: var(--red-bg);
    color: var(--red);
}

.pwa-modal-fallback {
    display: block;
    background: var(--bg-overlay);
}

@media (display-mode: standalone) {
    html { background: var(--bg); }
}

html.pwa-standalone #accordionSidebar {
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

html.pwa-standalone .topbar {
    height: calc(var(--topbar-h) + var(--safe-top)) !important;
    padding-top: var(--safe-top) !important;
}

/* Mobile shell */
@media (max-width: 768px) {
    #wrapper,
    #content-wrapper,
    #content {
        width: 100%;
        min-width: 0;
    }

    #content-wrapper {
        min-height: 100vh;
        min-height: 100dvh;
        padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom));
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 1030;
        padding-right: max(12px, var(--safe-right)) !important;
        padding-left: max(12px, var(--safe-left)) !important;
        background: rgba(255, 255, 255, 0.92) !important;
        -webkit-backdrop-filter: saturate(160%) blur(18px);
        backdrop-filter: saturate(160%) blur(18px);
    }

    [data-theme="dark"] .topbar {
        background: rgba(22, 22, 24, 0.92) !important;
    }

    .container-fluid {
        width: 100%;
        min-width: 0;
        padding-right: max(14px, var(--safe-right));
        padding-bottom: max(18px, var(--safe-bottom));
        padding-left: max(14px, var(--safe-left));
    }

    #page_content.loading::after {
        left: 50%;
    }

    #accordionSidebar,
    #accordionSidebar.toggled,
    #accordionSidebar.show-mobile {
        top: 0;
        bottom: auto;
        width: min(86vw, 320px) !important;
        min-width: min(86vw, 320px) !important;
        max-width: min(86vw, 320px) !important;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        padding-left: var(--safe-left);
        box-sizing: border-box;
        visibility: hidden;
        z-index: 1080;
        transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
                    box-shadow 280ms ease,
                    visibility 0s linear 280ms;
    }

    #accordionSidebar.show-mobile {
        visibility: visible;
        transition-delay: 0s;
    }

    /* One dimmed, fading scrim. The earlier display:none/block toggle made the
       drawer pop open with nothing behind it. */
    .sidebar-overlay {
        display: block;
        left: min(86vw, 320px);
        width: auto;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        z-index: 1070;
        transition: opacity 280ms ease, visibility 280ms;
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

    /* `hidden` lands the same tick the class drops, so keep it paintable and
       let visibility carry the fade-out. */
    .sidebar-overlay[hidden] {
        display: block;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        touch-action: none;
    }

    #accordionSidebar.toggled .sidebar-brand,
    #accordionSidebar.show-mobile.toggled .sidebar-brand {
        justify-content: flex-start;
        padding: 14px 16px !important;
    }

    #accordionSidebar.toggled .sidebar-brand img,
    #accordionSidebar.show-mobile.toggled .sidebar-brand img {
        width: auto;
        height: 18px;
    }

    #accordionSidebar.toggled .sidebar-group-label,
    #accordionSidebar.show-mobile.toggled .sidebar-group-label {
        display: block !important;
    }

    #accordionSidebar.toggled .sidebar-divider,
    #accordionSidebar.show-mobile.toggled .sidebar-divider {
        margin: 8px 16px !important;
    }

    #accordionSidebar.toggled .nav-item,
    #accordionSidebar.show-mobile.toggled .nav-item {
        margin: 2px 10px;
    }

    #accordionSidebar.toggled .nav-item .nav-link,
    #accordionSidebar.show-mobile.toggled .nav-item .nav-link {
        justify-content: flex-start;
        gap: 12px;
        padding: 10px 12px !important;
        border-radius: var(--radius-lg);
    }

    #accordionSidebar.toggled .nav-item .nav-link span,
    #accordionSidebar.show-mobile.toggled .nav-item .nav-link span {
        display: inline !important;
    }

    #accordionSidebar #sidebar_nav {
        min-height: 0;
        padding-bottom: max(24px, var(--safe-bottom));
        touch-action: pan-y;
    }

    #accordionSidebar .nav-item .nav-link {
        min-height: 44px;
    }

    #sidebarToggleTop,
    .topbar-action-btn,
    .topbar-user {
        min-width: 44px;
        min-height: 44px;
    }

    #sidebarToggleTop {
        width: auto;
        height: 44px;
        margin-left: -8px;
        padding: 0 8px;
    }

    .topbar-user {
        justify-content: center;
        padding: 7px;
    }

    .topbar-user img {
        width: 30px;
        height: 30px;
    }

    .topbar-breadcrumb {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        font-size: 0.8rem;
    }

    .topbar-breadcrumb a {
        display: none;
    }

    .topbar-breadcrumb .separator {
        display: none;
    }

    .topbar-breadcrumb .current {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .pwa-status-bar {
        position: sticky;
        top: var(--topbar-h);
        justify-content: flex-start;
        min-height: 44px;
        padding: 8px max(12px, var(--safe-right)) 8px max(12px, var(--safe-left));
        text-align: left;
    }

    html.pwa-standalone .pwa-status-bar {
        top: calc(var(--topbar-h) + var(--safe-top));
    }

    .pwa-status-bar > span {
        flex: 1;
    }

    .pwa-status-action,
    .pwa-status-dismiss {
        min-height: 44px;
    }

    .mobile-bottom-nav {
        height: calc(var(--mobile-nav-h) + var(--safe-bottom));
        padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
        background: rgba(255, 255, 255, 0.94);
        -webkit-backdrop-filter: saturate(170%) blur(20px);
        backdrop-filter: saturate(170%) blur(20px);
    }

    [data-theme="dark"] .mobile-bottom-nav {
        background: rgba(22, 22, 24, 0.94);
    }

    .mobile-nav-item {
        flex: 1 1 0;
        justify-content: center;
        min-width: 0;
        min-height: 48px;
        padding: 5px 4px;
    }

    .mobile-nav-item i {
        font-size: 1.05rem;
        transition: transform 100ms ease, color var(--ease);
    }

    .mobile-nav-item span {
        max-width: 100%;
        overflow: hidden;
        font-size: 0.6875rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-nav-item:active i {
        transform: scale(0.9);
    }

    .toast-container {
        right: max(12px, var(--safe-right));
        bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 12px);
        left: max(12px, var(--safe-left));
        align-items: stretch;
    }

    .ww-toast {
        width: 100%;
        min-height: 48px;
        padding: 12px 14px;
        border-radius: var(--radius-lg);
    }

    .ww-toast .toast-close {
        min-width: 44px;
        min-height: 44px;
        margin: -10px -10px -10px auto;
        font-size: 1.25rem;
    }

    .pwa-install-close,
    #notificationPreferencesModal .modal-header .close {
        min-width: 44px;
        min-height: 44px;
    }

    .btn,
    .btn-sm,
    .btn-icon,
    .btn-icon.sm,
    .filter-pill,
    .internal-toggle,
    .report-type-btn,
    .report-mode-btn,
    .report-preset {
        min-height: 44px;
    }

    .btn-icon,
    .btn-icon.sm {
        min-width: 44px;
        width: 44px;
        padding: 0;
    }

    .form-control,
    select.form-control,
    .bootstrap-select > .dropdown-toggle {
        min-height: 44px;
        font-size: 16px;
    }

    textarea.form-control {
        min-height: 112px;
    }

    .dropdown-item {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 9px 12px;
    }

    .modal-dialog {
        width: auto;
        max-width: calc(100vw - 24px);
        margin: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
    }

    .modal-content {
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
        overflow: hidden;
    }

    .modal-body {
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .app-shell-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .app-shell-card {
        min-height: 104px;
    }

    .app-page-skeleton-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sticky-footer {
        display: none;
    }
}

@media (max-width: 390px) {
    .topbar-breadcrumb a,
    .topbar-breadcrumb .separator {
        display: none;
    }

    .topbar-breadcrumb .current {
        max-width: 31vw;
    }

    .app-shell-grid {
        grid-template-columns: 1fr;
    }

    .app-page-skeleton-grid {
        grid-template-columns: 1fr;
    }
}

@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .topbar-action-btn:active,
    .topbar-user:active,
    #accordionSidebar .nav-item .nav-link:active {
        background: var(--bg-active) !important;
        transform: scale(0.98);
    }

    .card:hover,
    .kpi-card:hover {
        border-color: var(--border);
    }
}

/* ══════════════════════════════════════════════
   ACTIVITY CENTER
   ══════════════════════════════════════════════ */
.notification-center-trigger {
    position: relative;
}

.notification-count {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border: 2px solid var(--bg);
    border-radius: 999px;
    background: var(--red);
    color: var(--semantic-fg);
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 13px;
    text-align: center;
}

.tax-tab.active,
.view-toggle.active,
.ac-tag {
    color: var(--accent-fg) !important;
}

.mcp-code-block {
    color: var(--fg);
}

.notification-overlay {
    position: fixed;
    z-index: 1045;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.notification-center {
    position: fixed;
    z-index: 1046;
    top: 0;
    right: 0;
    display: flex;
    width: min(430px, 100vw);
    height: 100dvh;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg);
    box-shadow: -20px 0 50px rgba(15, 23, 42, 0.16);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform 180ms ease, visibility 180ms ease;
}

.notification-center.is-open {
    transform: translateX(0);
    visibility: visible;
}

.notification-center-header {
    display: flex;
    min-height: 82px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: calc(20px + var(--safe-top)) 20px 16px;
    border-bottom: 1px solid var(--border);
}

.notification-center-header h2,
#notificationPreferencesModal .modal-title {
    margin: 0;
    color: var(--fg);
    font-size: 1.1rem;
    font-weight: 750;
}

.notification-center-header p,
#notificationPreferencesModal .modal-header p {
    margin: 3px 0 0;
    color: var(--fg-secondary);
    font-size: 0.78rem;
}

.notification-center-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.notification-text-button,
.notification-icon-button {
    min-height: 38px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--fg-secondary);
}

.notification-text-button {
    padding: 0 9px;
    font-size: 0.76rem;
    font-weight: 650;
}

.notification-icon-button {
    width: 38px;
    padding: 0;
}

.notification-text-button:hover,
.notification-icon-button:hover {
    background: var(--bg-hover);
    color: var(--fg);
}

.notification-center-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.notification-center-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.notification-item {
    display: flex;
    width: 100%;
    min-height: 82px;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 18px;
    border: 0;
    border-bottom: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--fg);
    text-align: left;
    transition: background var(--ease);
}

.notification-item:hover,
.notification-item:focus-visible {
    background: var(--bg-hover);
}

.notification-item.is-unread {
    background: color-mix(in srgb, var(--accent-light) 62%, var(--bg));
}

.notification-item-icon {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--accent-light);
    color: var(--accent);
}

.notification-item-icon.is-expense {
    background: var(--red-bg);
    color: var(--red);
}

.notification-item-icon.is-finance,
.notification-item-icon.is-accounting,
.notification-item-icon.is-budget,
.notification-item-icon.is-tax {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.notification-item-icon.is-email {
    background: var(--blue-bg);
    color: var(--blue);
}

.notification-item-content {
    display: block;
    min-width: 0;
    flex: 1;
}

.notification-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.notification-item-top strong {
    overflow: hidden;
    color: var(--fg);
    font-size: 0.86rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-item-top time {
    flex: 0 0 auto;
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.notification-item-body {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 4px;
    color: var(--fg-secondary);
    font-size: 0.78rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.notification-empty {
    display: flex;
    min-height: 320px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px 28px;
    color: var(--fg-secondary);
    text-align: center;
}

.notification-empty > i {
    margin-bottom: 14px;
    color: var(--accent);
    font-size: 2rem;
}

.notification-empty h3 {
    margin: 0 0 5px;
    color: var(--fg);
    font-size: 0.95rem;
}

.notification-empty p {
    max-width: 290px;
    margin: 0 0 16px;
    font-size: 0.8rem;
    line-height: 1.5;
}

.notification-loading {
    display: grid;
    gap: 11px;
    padding: 18px;
}

.notification-loading .skeleton {
    display: block;
    height: 68px;
    border-radius: var(--radius-lg);
}

.notification-preference-head,
.notification-preference-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px 64px;
    align-items: center;
    gap: 8px;
}

.notification-preference-head {
    padding: 0 12px 8px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.notification-preference-head span:not(:first-child) {
    text-align: center;
}

.notification-preference-row {
    min-height: 54px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-subtle);
    color: var(--fg);
    font-size: 0.84rem;
    font-weight: 600;
}

.notification-switch {
    position: relative;
    display: block;
    width: 42px;
    height: 24px;
    margin: 0 auto;
}

.notification-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.notification-switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border-strong);
    cursor: pointer;
    transition: background var(--ease);
}

.notification-switch span::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
    content: "";
    transition: transform var(--ease);
}

.notification-switch input:checked + span {
    background: var(--accent);
}

.notification-switch input:checked + span::after {
    transform: translateX(18px);
}

.notification-switch input:focus-visible + span {
    outline: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
    outline-offset: 2px;
}

body.notification-center-open {
    overflow: hidden;
}

@media (max-width: 767.98px) {
    .notification-center {
        top: auto;
        bottom: calc(var(--mobile-nav-h) + var(--safe-bottom));
        left: 0;
        width: 100%;
        height: min(78dvh, 680px);
        border-top: 1px solid var(--border);
        border-right: 0;
        border-left: 0;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -18px 45px rgba(15, 23, 42, 0.18);
        transform: translateY(105%);
    }

    .notification-center.is-open {
        transform: translateY(0);
    }

    .notification-center-header {
        min-height: 74px;
        padding: 16px 14px 13px;
    }

    .notification-center-footer {
        padding-bottom: 12px;
    }

    .notification-text-button,
    .notification-icon-button {
        min-height: 44px;
    }

    .notification-icon-button {
        width: 44px;
    }

    .notification-item {
        min-height: 76px;
        padding: 13px 14px;
    }

    #notificationPreferencesModal .modal-dialog {
        align-items: flex-end;
    }
}

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

/* ── NATIVE EMAIL ── */
.email-page {
    --email-pane-height: max(620px, calc(100dvh - 150px));
    min-width: 0;
}

.email-page-status:empty {
    display: none;
}

.email-page-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    margin-bottom: 12px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    color: var(--fg-secondary);
    font-size: .84rem;
}

.email-page-status.is-error,
.email-inline-error,
.email-form-error {
    color: var(--red);
}

.email-mini-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: email-spin .7s linear infinite;
}

@keyframes email-spin {
    to { transform: rotate(360deg); }
}

.email-eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: .69rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.email-connect-card {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
    max-width: 920px;
    min-height: 480px;
    margin: 24px auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

.email-connect-card[hidden] {
    display: none;
}

.email-connect-copy,
.email-connect-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(28px, 5vw, 56px);
}

.email-connect-copy {
    background:
        radial-gradient(circle at 90% 10%, var(--accent-muted), transparent 46%),
        var(--bg-subtle);
}

.email-connect-copy h2 {
    margin-bottom: 10px;
    font-size: clamp(1.65rem, 4vw, 2.4rem);
    line-height: 1.1;
}

.email-connect-copy > p:last-child {
    max-width: 460px;
    margin: 0;
    color: var(--fg-secondary);
    line-height: 1.65;
}

.email-connect-icon {
    display: grid;
    width: 58px;
    height: 58px;
    margin-bottom: 24px;
    place-items: center;
    border-radius: 18px;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 1.35rem;
    box-shadow: 0 12px 28px var(--accent-muted);
}

.email-connect-form {
    border-left: 1px solid var(--border);
}

.email-password-field {
    position: relative;
}

.email-password-field .form-control {
    padding-right: 52px;
}

.email-password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    width: 46px;
    height: 100%;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--fg-muted);
}

.email-connect-submit {
    min-height: 46px;
    margin-top: 4px;
}

.email-form-error {
    margin: 0 0 12px;
    font-size: .8rem;
    line-height: 1.45;
}

.email-app[hidden] {
    display: none;
}

.email-workspace {
    display: grid;
    grid-template-columns: 190px minmax(280px, 340px) minmax(0, 1fr);
    height: var(--email-pane-height);
    min-height: 620px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
}

.email-folder-pane,
.email-list-pane,
.email-reader-pane {
    min-width: 0;
    min-height: 0;
}

.email-folder-pane {
    padding: 14px 10px;
    border-right: 1px solid var(--border);
    background: var(--bg-subtle);
    overflow-y: auto;
}

.email-account-block {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 4px;
}

.email-account-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    background: var(--accent-muted);
    color: var(--accent);
}

.email-account-block > span:nth-child(2) {
    min-width: 0;
}

.email-account-block strong,
.email-account-block small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-account-block strong {
    color: var(--fg);
    font-size: .76rem;
}

.email-account-block small {
    margin-top: 1px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.email-folders {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.email-folder-button {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 8px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--fg-secondary);
    font-size: .79rem;
    text-align: left;
    transition: background var(--ease), color var(--ease);
}

.email-folder-button:hover {
    background: var(--bg-hover);
    color: var(--fg);
}

.email-folder-button.active {
    background: var(--accent-muted);
    color: var(--accent);
    font-weight: 650;
}

.email-folder-badge {
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 0.6875rem;
    text-align: center;
}

.email-list-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg);
}

.email-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 14px 14px 10px;
}

.email-list-header h2 {
    margin: 0;
    font-size: 1.08rem;
}

.email-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 12px 10px;
}

.email-search > i {
    position: absolute;
    left: 12px;
    color: var(--fg-muted);
    font-size: .78rem;
    pointer-events: none;
}

.email-search input {
    width: 100%;
    min-height: 40px;
    padding: 8px 40px 8px 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-subtle);
    color: var(--fg);
    font-size: .81rem;
    outline: none;
}

.email-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.email-search button {
    position: absolute;
    right: 2px;
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--fg-muted);
}

.email-list-status:empty {
    display: none;
}

.email-list-status {
    padding: 0 12px 10px;
}

.email-inline-error {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-radius: 9px;
    background: var(--red-bg);
    font-size: .76rem;
}

.email-list-loading {
    display: grid;
    gap: 8px;
}

.email-list-skeleton {
    height: 76px;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
}

.email-message-list {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.email-message-item {
    position: relative;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    gap: 9px;
    width: 100%;
    min-height: 92px;
    padding: 13px 12px;
    border: 0;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg);
    color: var(--fg-secondary);
    text-align: left;
    transition: background var(--ease);
}

.email-message-item:hover,
.email-message-item.selected {
    background: var(--bg-hover);
}

.email-message-item.selected::after {
    position: absolute;
    top: 10px;
    right: 0;
    bottom: 10px;
    width: 3px;
    border-radius: 3px 0 0 3px;
    background: var(--accent);
    content: "";
}

.email-unread-dot {
    width: 7px;
    height: 7px;
    margin-top: 7px;
    border-radius: 50%;
    background: transparent;
}

.email-message-item.unread .email-unread-dot {
    background: var(--accent);
}

.email-message-main {
    display: block;
    min-width: 0;
}

.email-message-line {
    display: flex;
    gap: 8px;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 3px;
}

.email-message-line strong {
    min-width: 0;
    overflow: hidden;
    color: var(--fg-secondary);
    font-size: .79rem;
    font-weight: 550;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-message-item.unread .email-message-line strong,
.email-message-item.unread .email-message-subject {
    color: var(--fg);
    font-weight: 700;
}

.email-message-line time {
    flex: 0 0 auto;
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.email-message-subject,
.email-message-preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-message-subject {
    margin-bottom: 3px;
    color: var(--fg-secondary);
    font-size: .78rem;
}

.email-message-preview {
    color: var(--fg-muted);
    font-size: .72rem;
}

.email-list-attachment {
    margin-top: 31px;
    color: var(--fg-muted);
    font-size: .7rem;
}

.email-list-empty,
.email-reader-empty,
.email-reader-error {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 20px;
    color: var(--fg-muted);
    text-align: center;
}

.email-list-empty {
    min-height: 260px;
}

.email-list-empty > i,
.email-reader-empty > span {
    display: grid;
    width: 54px;
    height: 54px;
    margin-bottom: 14px;
    place-items: center;
    border-radius: 17px;
    background: var(--bg-muted);
    color: var(--fg-muted);
    font-size: 1.2rem;
}

.email-list-empty h3,
.email-reader-empty h2,
.email-reader-error h2 {
    margin: 0 0 5px;
    font-size: .95rem;
}

.email-list-empty p,
.email-reader-empty p,
.email-reader-error p {
    max-width: 280px;
    margin: 0;
    font-size: .77rem;
}

.email-load-more {
    min-height: 42px;
    flex: 0 0 auto;
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--accent);
    font-size: .78rem;
    font-weight: 650;
}

.email-reader-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg);
}

.email-reader-loading {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    color: var(--fg-muted);
    font-size: .82rem;
}

.email-reader-header {
    padding: 18px 22px 16px;
    border-bottom: 1px solid var(--border);
}

.email-reader-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 38px;
    margin-bottom: 12px;
}

.email-reader-actions {
    display: flex;
    gap: 2px;
}

.email-reader-back {
    display: none;
}

.email-reader-header h2 {
    margin: 0 0 18px;
    font-family: var(--ww-body);
    font-size: clamp(1.05rem, 1.6vw, 1.25rem);
    font-weight: 650;
    line-height: var(--lh-snug);
    letter-spacing: -0.012em;
    overflow-wrap: anywhere;
}

.email-sender-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.email-sender-avatar {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    background: var(--accent-muted);
    color: var(--accent);
    font-size: .86rem;
    font-weight: 700;
}

.email-sender-details {
    min-width: 0;
}

.email-sender-details strong,
.email-sender-details small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-sender-details strong {
    color: var(--fg);
    font-size: .82rem;
}

.email-sender-details small,
.email-sender-row time {
    color: var(--fg-muted);
    font-size: .7rem;
}

.email-recipient-details {
    margin: 8px 0 0 48px;
    color: var(--fg-muted);
    font-size: var(--t-xs);
}

.email-recipient-details summary {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    cursor: pointer;
    list-style: none;
}

/* The default disclosure triangle reads as a stray glyph next to the address. */
.email-recipient-details summary::-webkit-details-marker {
    display: none;
}

.email-recipient-details summary::after {
    content: "\203a";
    font-size: 1.1em;
    line-height: 1;
    transition: transform 160ms var(--ww-ease-out);
}

.email-recipient-details[open] summary::after {
    transform: rotate(90deg);
}

.email-recipient-details p {
    margin: 5px 0 0;
}

.email-reader-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding: clamp(20px, 3vw, 36px);
    color: var(--fg);
    font-size: var(--t-base);
    line-height: var(--lh-relaxed);
    overflow-wrap: anywhere;
}

/* Plain-text mail should read like prose, not like a code block. */
.email-text-body {
    max-width: 68ch;
}

.email-text-body {
    white-space: pre-wrap;
}

/* The frame cannot report its own height (opaque sandbox, no scripts), so it
   fills the reading area instead of sitting in a fixed box with space under it. */
.email-html-frame-shell {
    display: flex;
    max-width: 100%;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.email-image-privacy {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    margin-bottom: 12px;
    padding: 8px 10px 8px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-subtle);
    color: var(--fg-secondary);
    font-size: .74rem;
    line-height: 1.4;
}

.email-image-privacy[hidden] {
    display: none;
}

.email-image-privacy span {
    display: inline-flex;
    gap: 7px;
    align-items: center;
}

.email-image-privacy i {
    color: var(--accent);
}

.email-image-privacy .btn {
    min-width: 104px;
    min-height: 44px;
    flex: 0 0 auto;
}

.email-html-frame {
    display: block;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 240px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.email-text-body blockquote {
    margin-left: 0;
    padding-left: 14px;
    border-left: 3px solid var(--border-strong);
    color: var(--fg-secondary);
}

.email-attachments {
    margin: 0 22px 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-subtle);
}

.email-attachments h3 {
    margin-bottom: 10px;
    font-size: .76rem;
}

.email-attachments > div {
    display: grid;
    gap: 7px;
}

.email-attachment {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 24px;
    gap: 8px;
    align-items: center;
    min-height: 48px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--fg-secondary);
    text-align: left;
}

.email-attachment span,
.email-attachment strong,
.email-attachment small {
    display: block;
    min-width: 0;
}

.email-attachment strong {
    overflow: hidden;
    color: var(--fg);
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-attachment small {
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.email-reader-reply-bar {
    display: flex;
    gap: 8px;
    padding: 0 22px 24px;
}

.email-mobile-toolbar {
    display: none;
}

.email-compose-backdrop {
    position: fixed;
    z-index: 2100;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px;
    background: var(--bg-overlay);
}

.email-compose-backdrop[hidden] {
    display: none;
}

.email-compose-sheet {
    display: flex;
    flex-direction: column;
    width: min(620px, calc(100vw - 48px));
    height: min(720px, calc(100dvh - 48px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

.email-compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 17px;
    border-bottom: 1px solid var(--border);
}

.email-compose-header h2 {
    margin: 0;
    font-size: 1rem;
}

.email-compose-fields {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
}

.email-compose-row {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 48px;
    padding: 0 15px;
    border-bottom: 1px solid var(--border-subtle);
}

.email-compose-row[hidden] {
    display: none;
}

.email-compose-row label {
    margin: 0;
    color: var(--fg-muted);
}

.email-compose-row input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--fg);
    font-size: .84rem;
}

.email-compose-row button {
    min-height: 38px;
    padding: 0 6px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: .73rem;
}

#email_compose_body {
    width: 100%;
    min-height: 300px;
    padding: 18px;
    border: 0;
    resize: none;
    outline: 0;
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    font-size: .88rem;
    line-height: 1.65;
}

.email-attachment-summary {
    padding: 0 18px;
    color: var(--fg-muted);
    font-size: .74rem;
}

.email-compose-fields .email-form-error {
    margin: 10px 18px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--red-bg);
}

.email-compose-footer {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
}

.email-attach-button {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 44px;
    margin: 0;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--fg-secondary);
    cursor: pointer;
}

.email-attach-button:hover {
    background: var(--bg-hover);
    color: var(--fg);
}

.email-send-button {
    min-width: 100px;
    min-height: 44px;
}

html.email-compose-open {
    overflow: hidden;
}

[data-theme="dark"] .email-connect-card,
[data-theme="dark"] .email-compose-sheet {
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}

/* ── COMPACT DATA VIEWS ── */
.page-view-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px !important;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-muted);
}

.page-view-switch .view-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--fg-muted);
    box-shadow: none;
}

.page-view-switch .view-toggle.active {
    background: var(--bg);
    color: var(--accent) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}

[data-theme="dark"] .page-view-switch .view-toggle.active {
    color: var(--accent) !important;
}

.exp-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 12px;
}

.exp-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.exp-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
    transform: translateY(-1px);
}

.exp-card-main {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 15px 16px 13px;
    border: 0;
    background: transparent;
    color: var(--fg);
    font: inherit;
    text-align: left;
}

.exp-card-heading,
.exp-card-meta,
.exp-card-details,
.exp-card-detail,
.exp-card-note,
.exp-card-editor {
    display: flex;
    min-width: 0;
}

.exp-card-heading {
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
}

.exp-card-title {
    min-width: 0;
    overflow: hidden;
    color: var(--fg);
    font-size: .88rem;
    font-weight: 650;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exp-card-amount {
    flex: 0 0 auto;
    color: var(--accent);
    font-size: .92rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.exp-card-meta {
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    margin-top: 8px;
}

.exp-card-chip,
.exp-card-id {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    min-height: 20px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.6875rem;
    line-height: 1.2;
}

.exp-card-chip {
    background: var(--bg-muted);
    color: var(--fg-secondary);
}

.exp-card-id {
    padding-inline: 3px;
    color: var(--fg-muted);
}

.exp-card-details {
    flex-direction: column;
    gap: 5px;
    margin-top: 11px;
}

.exp-card-detail,
.exp-card-note {
    gap: 7px;
    align-items: flex-start;
    color: var(--fg-secondary);
    font-size: .75rem;
    line-height: 1.4;
}

.exp-card-detail > i,
.exp-card-note > i {
    width: 13px;
    flex: 0 0 13px;
    margin-top: 2px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    text-align: center;
}

.exp-card-detail > span,
.exp-card-note > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exp-card-editor {
    margin-top: 9px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.exp-card-actions,
.project-card-actions {
    display: flex;
    align-items: stretch;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
}

.exp-card-actions .btn,
.project-card-actions .btn {
    display: inline-flex;
    min-height: 38px;
    flex: 1;
    gap: 5px;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 0;
    color: var(--fg-muted);
    font-size: .69rem;
}

.exp-card-actions .btn + .btn,
.project-card-actions .btn + .btn {
    border-left: 1px solid var(--border-subtle);
}

.exp-card-actions .btn:hover,
.project-card-actions .btn:hover {
    background: var(--bg-hover);
    color: var(--fg);
}

.exp-card-actions .btn-del:hover,
.project-card-actions .btn-del-project:hover {
    color: var(--red);
}

.expense-card-loading,
.expense-card-empty,
.project-card-loading,
.project-card-empty {
    display: flex;
    grid-column: 1 / -1;
    min-height: 160px;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--fg-muted);
    text-align: center;
}

.expense-card-loading,
.project-card-loading {
    min-height: 110px;
    flex-direction: row;
    font-size: .8rem;
}

.expense-card-empty > i,
.project-card-empty > i {
    font-size: 1.35rem;
    opacity: .55;
}

.expense-card-empty p,
.project-card-empty p {
    margin: 0;
    font-size: .8rem;
}

.projects-toolbar-controls,
.projects-search-wrap {
    min-height: 36px;
}

#projects_search {
    height: 36px;
}

.project-card {
    position: relative;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.project-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
    transform: translateY(-1px);
}

.project-card-main {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 15px 16px 13px;
    border: 0;
    background: transparent;
    color: var(--fg);
    font: inherit;
    text-align: left;
}

.project-card-main > span {
    display: flex;
}

.project-card-eyebrow {
    padding-right: 90px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    line-height: 1.3;
}

.project-card-title {
    max-width: calc(100% - 88px);
    margin-top: 3px;
    overflow: hidden;
    color: var(--fg);
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card-client {
    gap: 6px;
    align-items: center;
    min-width: 0;
    margin-top: 4px;
    overflow: hidden;
    color: var(--fg-muted);
    font-size: .7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card-client i {
    font-size: 0.6875rem;
}

.project-card-financials {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    margin-top: 13px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--border-subtle);
}

.project-card-metric {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
    padding: 7px 8px;
    background: var(--bg-subtle);
}

.project-card-metric small {
    color: var(--fg-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
}

.project-card-metric strong {
    overflow: hidden;
    color: var(--fg);
    font-size: .73rem;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.is-positive {
    color: var(--green) !important;
}

.is-negative {
    color: var(--red) !important;
}

.project-card-payment {
    gap: 9px;
    align-items: center;
    margin-top: 10px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.project-card-progress {
    display: block !important;
    height: 5px;
    flex: 1;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg-muted);
}

.project-card-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.project-card-margin {
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
}

.project-card-margin strong {
    margin-left: 3px;
    color: var(--fg-secondary);
    font-variant-numeric: tabular-nums;
}

.project-card-status {
    position: absolute;
    top: 7px;
    right: 9px;
}

.project-status-control {
    position: relative;
    display: inline-flex;
    min-width: 84px;
    min-height: 32px;
    align-items: center;
    justify-content: center;
    margin: 0;
    cursor: pointer;
}

.project-status-pill {
    display: inline-flex;
    min-height: 20px;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
}

.project-status-control select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: .01;
}

.project-status-control:focus-within {
    border-radius: 999px;
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.project-card-actions .btn:nth-child(3),
.project-card-actions .btn:nth-child(4) {
    max-width: 44px;
}

/* Reports stay dense without reducing mobile tap areas. */
.report-config-panel {
    padding: 12px;
}

.report-type-strip-wrap {
    margin: -12px -12px 10px;
    padding: 12px 12px 0;
}

.report-type-btn {
    min-height: 34px;
    padding: 5px 11px;
    font-size: .72rem;
}

.report-controls {
    gap: 8px;
}

.report-mode-btn {
    min-height: 34px;
    padding: 5px 9px;
    font-size: .7rem;
}

.report-date-inputs .form-control,
.report-filter-select {
    min-height: 36px;
    padding-block: 5px;
}

.report-preset {
    min-height: 34px;
    padding: 4px 9px;
    font-size: 0.6875rem;
}

.report-generate-btn {
    min-height: 36px;
    padding: 6px 14px;
    font-size: .75rem;
}

#report_optional_filters:empty {
    display: none;
}

/* ── USER WORK EMAIL ADMIN ── */
.user-identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
}

.user-avatar-initials {
    display: flex;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-muted);
    color: var(--fg-muted);
    font-size: 0.6875rem;
    font-weight: 700;
}

.user-identity-copy {
    min-width: 0;
}

.user-display-name {
    overflow: hidden;
    color: var(--fg);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-mobile-mailbox {
    display: none;
    min-width: 0;
    margin-top: 3px;
}

.user-mailbox-status {
    display: inline-flex;
    max-width: 210px;
    min-width: 0;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    color: var(--fg-muted);
    font-size: .7rem;
    font-weight: 550;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mailbox-status-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: var(--border-strong);
}

.user-mailbox-status.is-connected {
    color: var(--green);
}

.user-mailbox-status.is-connected .mailbox-status-dot {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-bg);
}

.user-mailbox-status.is-loading .mailbox-status-dot {
    border: 1px solid var(--border-strong);
    border-top-color: var(--accent);
    background: transparent;
    animation: mailbox-spin .7s linear infinite;
}

.user-mailbox-status.is-error {
    color: var(--yellow);
}

.user-mailbox-status.is-error .mailbox-status-dot {
    background: var(--yellow);
}

.user-action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.user-action-buttons .btn-manage-mailbox {
    width: auto;
    gap: 6px;
    padding: 0 8px;
    color: var(--accent);
}

.mailbox-manage-label {
    font-size: 0.6875rem;
    font-weight: 650;
}

.mailbox-user-form-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-subtle);
    color: var(--fg-muted);
    font-size: .7rem;
    line-height: 1.45;
}

.mailbox-user-form-note i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--accent);
}

.mailbox-user-form-note strong {
    color: var(--fg-secondary);
}

.mailbox-admin-modal .modal-dialog {
    width: calc(100% - 32px);
    max-width: 640px;
}

.mailbox-admin-header {
    align-items: flex-start;
}

.mailbox-admin-header > div {
    min-width: 0;
}

.mailbox-admin-header .close {
    display: inline-flex;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    margin: -10px -10px -10px 12px;
}

.mailbox-admin-eyebrow {
    margin: 0 0 2px;
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

#workEmailModalSubtitle {
    margin: 3px 0 0;
    overflow: hidden;
    color: var(--fg-muted);
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mailbox-admin-modal .modal-body {
    padding: 20px;
}

.mailbox-admin-loading {
    display: flex;
    min-height: 180px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--fg-muted);
    font-size: .82rem;
}

.mailbox-admin-spinner {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mailbox-spin .7s linear infinite;
}

@keyframes mailbox-spin {
    to { transform: rotate(360deg); }
}

.mailbox-admin-summary {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
}

.mailbox-admin-summary.is-connected {
    border-color: color-mix(in srgb, var(--green) 30%, var(--border));
    background: var(--green-bg);
}

.mailbox-status-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--bg-muted);
    color: var(--fg-muted);
}

.mailbox-admin-summary.is-connected .mailbox-status-icon {
    background: color-mix(in srgb, var(--green) 14%, transparent);
    color: var(--green);
}

.mailbox-admin-summary.is-attention {
    border-color: color-mix(in srgb, var(--yellow) 32%, var(--border));
    background: var(--yellow-bg);
}

.mailbox-admin-summary.is-attention .mailbox-status-icon {
    background: color-mix(in srgb, var(--yellow) 14%, transparent);
    color: var(--yellow);
}

.mailbox-admin-summary > div {
    min-width: 0;
}

.mailbox-admin-summary span,
.mailbox-admin-summary strong,
.mailbox-admin-summary small {
    display: block;
}

.mailbox-admin-summary > div > span {
    margin-bottom: 2px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mailbox-admin-summary strong {
    overflow: hidden;
    color: var(--fg);
    font-size: .9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mailbox-admin-summary small {
    margin-top: 3px;
    color: var(--fg-muted);
    font-size: .7rem;
    line-height: 1.4;
}

.mailbox-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.mailbox-action-card {
    display: grid;
    min-width: 0;
    min-height: 124px;
    grid-template-columns: 36px minmax(0, 1fr) 14px;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    color: var(--fg);
    text-align: left;
    transition: border-color var(--ease), background var(--ease), transform 100ms ease;
}

.mailbox-action-card:hover {
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

.mailbox-action-card:active {
    transform: scale(.99);
}

.mailbox-action-card:focus-visible,
.mailbox-back-button:focus-visible,
.mailbox-mode-option:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mailbox-action-card > span:nth-child(2) {
    min-width: 0;
}

.mailbox-action-card strong,
.mailbox-action-card small {
    display: block;
}

.mailbox-action-card strong {
    margin-top: 1px;
    font-size: .78rem;
    line-height: 1.35;
}

.mailbox-action-card small {
    margin-top: 5px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    line-height: 1.45;
}

.mailbox-action-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg-muted);
    color: var(--fg-muted);
}

.mailbox-action-card.is-primary .mailbox-action-icon {
    background: var(--accent-muted);
    color: var(--accent);
}

.mailbox-action-card.is-danger .mailbox-action-icon {
    background: var(--red-bg);
    color: var(--red);
}

.mailbox-action-arrow {
    align-self: center;
    color: var(--fg-faint);
    font-size: 0.6875rem;
}

.mailbox-password-note,
.mailbox-admin-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-subtle);
    color: var(--fg-muted);
}

.mailbox-password-note > i,
.mailbox-admin-message > i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--accent);
}

.mailbox-password-note p,
.mailbox-admin-message p {
    margin: 0;
    font-size: .7rem;
    line-height: 1.45;
}

.mailbox-password-note strong,
.mailbox-admin-message strong {
    color: var(--fg-secondary);
}

.mailbox-admin-message.is-error {
    border-color: color-mix(in srgb, var(--red) 28%, var(--border));
    background: var(--red-bg);
    color: var(--red);
}

.mailbox-admin-message.is-error > i,
.mailbox-admin-message.is-error strong {
    color: var(--red);
}

.mailbox-admin-message.is-warning {
    border-color: color-mix(in srgb, var(--yellow) 32%, var(--border));
    background: var(--yellow-bg);
    color: var(--fg-secondary);
}

.mailbox-admin-message.is-warning > i {
    color: var(--yellow);
}

.mailbox-full-button {
    width: 100%;
    min-height: 44px;
    margin-top: 4px;
}

.mailbox-back-button {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    margin: -10px 0 4px -10px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--fg-muted);
    font-size: .75rem;
    font-weight: 600;
}

.mailbox-back-button:hover {
    background: var(--bg-hover);
    color: var(--fg);
}

.mailbox-form-heading {
    margin: 0 0 18px;
}

.mailbox-form-heading h6,
.mailbox-confirm-panel h6 {
    margin: 0 0 5px;
    color: var(--fg);
    font-size: .95rem;
    font-weight: 700;
}

.mailbox-form-heading p,
.mailbox-confirm-panel p {
    margin: 0;
    color: var(--fg-muted);
    font-size: .76rem;
    line-height: 1.5;
}

.mailbox-optional {
    color: var(--fg-muted);
    font-size: 0.6875rem;
    font-weight: 500;
}

.mailbox-mode-group {
    min-width: 0;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
}

.mailbox-mode-group legend {
    margin-bottom: 8px;
    color: var(--fg-secondary);
    font-size: .72rem;
    font-weight: 600;
}

.mailbox-mode-option {
    display: flex;
    min-height: 72px;
    align-items: flex-start;
    gap: 11px;
    margin: 0 0 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
}

.mailbox-mode-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.mailbox-mode-option input {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin-top: 1px;
    accent-color: var(--accent);
}

.mailbox-mode-option span,
.mailbox-mode-option strong,
.mailbox-mode-option small {
    display: block;
}

.mailbox-mode-option span {
    min-width: 0;
}

.mailbox-mode-option strong {
    color: var(--fg);
    font-size: .75rem;
    line-height: 1.35;
}

.mailbox-mode-option small {
    margin-top: 3px;
    color: var(--fg-muted);
    font-size: 0.6875rem;
    line-height: 1.4;
}

.mailbox-inline-error {
    margin: 0 0 10px;
    padding: 9px 11px;
    border-radius: var(--radius);
    background: var(--red-bg);
    color: var(--red);
    font-size: .72rem;
    line-height: 1.4;
}

.mailbox-inline-error[hidden],
#mailboxCurrentPasswordGroup[hidden] {
    display: none;
}

.mailbox-confirm-panel {
    padding: 8px 2px 16px;
    text-align: center;
}

.mailbox-confirm-panel p + p {
    margin-top: 8px;
}

.mailbox-confirm-icon {
    display: inline-flex;
    width: 54px;
    height: 54px;
    align-items: center;
    justify-content: center;
    margin-bottom: 13px;
    border-radius: 16px;
    background: var(--accent-muted);
    color: var(--accent);
    font-size: 1rem;
}

.mailbox-confirm-panel.is-danger .mailbox-confirm-icon {
    background: var(--red-bg);
    color: var(--red);
}

.mailbox-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

.mailbox-confirm-actions .btn {
    min-height: 44px;
}

@media (max-width: 767.98px) {
    .user-mobile-mailbox {
        display: block;
    }

    .user-name-cell {
        min-width: 132px;
    }

    .user-action-buttons {
        gap: 0;
    }

    .user-action-buttons .btn-icon {
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
    }

    .mailbox-manage-label {
        display: none;
    }

    .mailbox-admin-modal .modal-dialog {
        display: flex;
        width: 100%;
        height: 100%;
        max-width: 100%;
        align-items: flex-end;
        margin: 0;
    }

    .mailbox-admin-modal .modal-content {
        width: 100%;
        max-height: calc(100dvh - max(10px, var(--safe-top)));
        padding-bottom: var(--safe-bottom);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 22px 22px 0 0;
    }

    .mailbox-admin-modal .modal-body {
        padding: 16px;
    }

    .mailbox-action-grid {
        grid-template-columns: 1fr;
    }

    .mailbox-action-card {
        min-height: 86px;
        align-items: center;
    }

    .mailbox-action-card strong {
        margin-top: 0;
    }

    .mailbox-admin-summary {
        padding: 14px;
    }

    .mailbox-confirm-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
/* iOS zooms focused form controls when their computed text is below 16px. */
@media screen and (max-width: 991.98px) {
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ----- App lock (js/lock.js) ----- */
html.ww-locked, html.ww-locked body { overflow: hidden; }
.ww-lock {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
    background: var(--ww-black, #0a0a0a);
    color: var(--ww-offwhite, #f5f5f0);
}
html[data-theme="light"] .ww-lock { background: var(--ww-page-light, #f7f7f4); color: var(--ww-black, #0a0a0a); }
.ww-lock[hidden] { display: none; }
.ww-lock-card { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ww-lock-logo { margin-bottom: 8px; }
.ww-lock h1 { font-family: var(--ww-display, inherit); font-size: 26px; margin: 0; color: inherit; }
.ww-lock-sub { margin: 0 0 12px; opacity: 0.6; font-size: 15px; }
.ww-lock-unlock {
    width: 100%;
    min-height: 54px;
    border: 0;
    border-radius: 14px;
    background: var(--ww-red, #f0050b);
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}
.ww-lock-unlock:disabled { opacity: 0.6; }
.ww-lock-unlock i { font-size: 22px; }
.ww-lock-error { min-height: 20px; margin: 0; color: var(--ww-red, #f0050b); font-size: 14px; }
.ww-lock-password { background: none; border: 0; color: inherit; opacity: 0.65; font-size: 14px; text-decoration: underline; cursor: pointer; }
