/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --nav-height: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand-logo {
    height: 30px;
    width: auto;
    display: block;
    transition: opacity 0.18s ease;
}
.nav-brand:hover .nav-brand-logo { opacity: 0.78; }
@media (max-width: 640px) {
    .nav-brand-logo { height: 26px; }
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link { color: var(--text-muted); font-size: 0.875rem; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-user { color: var(--text); font-weight: 500; font-size: 0.875rem; }
.nav-logout { color: var(--danger); }

/* Hamburger menu button */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text);
}
.nav-toggle svg { display: block; }

/* === Layout === */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Wide container for data-heavy pages like reports */
.container.container-wide {
    max-width: 1440px;
}

/* Full-width fluid container */
.container.container-fluid {
    max-width: none;
    padding-left: 2rem;
    padding-right: 2rem;
}

/* === Breadcrumbs === */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text-muted); }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* === Cards === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h2 { font-size: 1.1rem; margin-bottom: 1rem; }

/* ─────────────────────────────────────────────────────────
   Glass aesthetic — applied to every authenticated page via
   body.glass-app. Keeps the dashboard's `body.glass-home`
   intact (more specific, adds dashboard-only nuances).
   Three pieces only: page background, frosted navbar,
   glass card surface. Forms / tables / buttons stay solid
   and readable inside the glass cards.
   ───────────────────────────────────────────────────────── */
body.glass-app {
    background:
        radial-gradient(820px 520px at 6% -8%, rgba(99,102,241,0.12), transparent 60%),
        radial-gradient(780px 640px at 96% 6%, rgba(56,189,248,0.10), transparent 60%),
        radial-gradient(900px 600px at 50% 115%, rgba(168,85,247,0.08), transparent 60%),
        linear-gradient(180deg, #f6f8fc 0%, #eef2f8 100%);
    background-attachment: fixed;
    min-height: 100vh;
}
body.glass-app .navbar {
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: saturate(180%) blur(22px);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}
body.glass-app .card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 8px 24px -16px rgba(15, 23, 42, 0.12);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-header-row h2 { margin-bottom: 0; }

/* === Module Grid === */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: border-color 0.15s, box-shadow 0.15s;
    color: var(--text);
}

.module-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37,99,235,0.1);
    text-decoration: none;
}

.module-card-wrap { position: relative; }
.module-card-wrap .module-card { display: block; height: 100%; }

.module-icon { font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.55; line-height: 1; }
.module-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.module-card p { color: var(--text-muted); font-size: 0.875rem; }

/* Info button */
.module-info-btn {
    position: absolute; top: 0.75rem; right: 0.75rem;
    width: 24px; height: 24px; border-radius: 50%;
    background: #f1f5f9; border: 1px solid #e2e8f0; color: #94a3b8;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; z-index: 2; padding: 0;
}
.module-info-btn:hover, .module-info-btn.active {
    background: var(--primary); border-color: var(--primary); color: #fff;
}

/* Tooltip */
.module-info-tip {
    display: none; position: absolute; top: 2.5rem; right: 0.5rem;
    background: #1e293b; color: #f1f5f9; font-size: 0.82rem; line-height: 1.45;
    padding: 0.65rem 0.85rem; border-radius: 8px; z-index: 10;
    width: 260px; max-width: calc(100vw - 2rem);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    pointer-events: none;
}
.module-info-tip.show { display: block; pointer-events: auto; }
.module-info-tip::before {
    content: ''; position: absolute; top: -6px; right: 12px;
    border-left: 6px solid transparent; border-right: 6px solid transparent;
    border-bottom: 6px solid #1e293b;
}

/* === Tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f8fafc;
    position: sticky;
    top: 0;
}

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .row-total { font-weight: 600; background: #f1f5f9; }
.data-table .row-warning { background: #fffbeb; }
.data-table .row-inactive { opacity: 0.5; }

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.actions-cell { white-space: nowrap; }

/* === Info Bar === */
.info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.info-item { display: flex; flex-direction: column; }
.info-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.info-value { font-weight: 600; }

/* === Forms === */
/* Modern fields app-wide (Oct 2026): soft border that darkens on hover, blue
   focus ring, chevron on selects, calm placeholders, clear disabled state.
   Sizes are unchanged so existing layouts don't shift. */
.form-group { margin-bottom: 1rem; }
.form-group label, .form-group > legend { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.8rem; color: #334155; letter-spacing: 0.01em; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="tel"], input[type="search"], input[type="url"],
input[type="time"], input[type="month"], input[type="datetime-local"],
select, textarea.form-control, .form-group textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d5dce6;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.35;
    background-color: #fff;
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
/* full width only for the types that always were (newer types keep their size) */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], select, textarea.form-control, .form-group textarea { width: 100%; }
textarea.form-control, .form-group textarea { resize: vertical; min-height: 4.5rem; }
select {
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    cursor: pointer;
}
select[multiple] { background-image: none; padding-right: 0.75rem; }
input::placeholder, textarea::placeholder { color: #9aa6b6; }
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: #b4bfcd; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
input:disabled, select:disabled, textarea:disabled, input[readonly] { background-color: #f4f6f9; color: #64748b; cursor: not-allowed; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
input[type="date"]::-webkit-calendar-picker-indicator, input[type="time"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
input[type="number"]::-webkit-inner-spin-button { opacity: .5; }

.input-sm {
    width: 140px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.file-input {
    border: 2px dashed var(--border);
    padding: 1rem;
    border-radius: var(--radius);
    width: 100%;
    cursor: pointer;
}

.form-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.input-grow { flex: 1; }
.inline-form { display: inline-flex; align-items: center; gap: 0.25rem; }

.form-inline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.3rem 0;
}

.checkbox-list { display: flex; flex-direction: column; gap: 0.25rem; }

/* === Allocation === */
.allocation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.input-suffix {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.input-suffix input { width: 100px; }
.input-suffix span { color: var(--text-muted); font-weight: 500; }

.alloc-total {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: #f1f5f9; text-decoration: none; }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-outline { background: transparent; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* === Document Tabs === */
.doc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.doc-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.doc-tab:hover {
    color: var(--text);
}

.doc-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-count {
    display: inline-block;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
    margin-left: 0.25rem;
}

.doc-tab.active .tab-count {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

/* === Trend Controls === */
.trend-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trend-controls label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.trend-controls select {
    width: auto;
    min-width: 160px;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* === Flash Messages === */
.flash-messages { margin-bottom: 1rem; }

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid;
}

.flash-success { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.flash-error { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.flash-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.flash-info { background: #dbeafe; border-color: #bfdbfe; color: #1e40af; }

/* === Misc === */
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

/* === Login === */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }

/* === KPI Cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 0.75rem 1rem; border-top: 3px solid #3b82f6;
    text-align: center;
}
.kpi-label { font-size: 0.7rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 1.25rem; font-weight: 700; margin-top: 0.15rem; }

/* === Multi-select Dropdown === */
.ms-filter {
    position: relative;
    display: inline-block;
    /* Own stacking context so the dropdown sits cleanly above
       sibling glass cards (which create stacking contexts via
       backdrop-filter). */
    isolation: isolate;
}
.ms-toggle {
    padding: 0.4rem 0.65rem; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; background: #fff; font-size: 0.8rem; min-width: 130px;
    user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 200px;
}
.ms-arrow { float: right; margin-left: 0.35rem; }
.ms-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    /* High enough to clear any glass card / backdrop-filter
       stacking context on the page. */
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
    /* Padding gives the first/last options breathing room from
       the rounded-corner clip — without this, the top option's
       text can appear cut against the border-radius. */
    padding: 0.25rem 0;
    box-sizing: border-box;
}
.ms-filter.open .ms-dropdown { display: block; }
.ms-dropdown.open { display: block; }
.ms-option {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer; font-size: 0.85rem;
    line-height: 1.3;
}
.ms-option:hover { background: #f1f5f9; }
.ms-option input[type="checkbox"] { width: 14px; height: 14px; margin: 0; flex-shrink: 0; }
.ms-label { font-size: 0.8rem; font-weight: 600; display: block; margin-bottom: 0.2rem; }

/* === Filter Bar === */
/* `position: relative; z-index: 10` lifts the filter card above sibling
   cards in the body's stacking order. Glass cards create their own
   stacking contexts via `backdrop-filter`, so any absolutely-positioned
   dropdown inside a filter card would otherwise be trapped beneath the
   next sibling card (e.g. the data table that follows). */
.filter-card { margin-bottom: 1.25rem; padding: 0.75rem 1rem; position: relative; z-index: 10; }
.filter-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.filter-actions { display: flex; gap: 0.35rem; }
.months-select { width: auto; min-width: 80px; }
.active-filters { margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 0.35rem; font-size: 0.8rem; align-items: center; }

/* === Card Header Bar === */
.card-header-bar { padding: 0.6rem 1rem; background: #f8fafc; border-bottom: 1px solid var(--border); }

/* === Change Indicators === */
.chg { font-size: 0.7rem; font-weight: 600; }
.chg-up { color: #16a34a; }
.chg-down { color: #dc2626; }

/* === CSS Bar Chart === */
.chart-card { margin-bottom: 1.5rem; overflow: hidden; }
.chart-legend { display: flex; gap: 0.75rem; font-size: 0.75rem; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.chart-area {
    padding: 1rem; display: flex; align-items: flex-end; gap: 0.25rem;
    height: 180px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.chart-col { flex: 1; min-width: 28px; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; }
.chart-bars { flex: 1; display: flex; align-items: flex-end; gap: 1px; width: 100%; }
.chart-bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 2px; }
.chart-bar-rev { background: #16a34a; }
.chart-bar-cost { background: #dc2626; }
.chart-label { font-size: 0.6rem; color: #888; white-space: nowrap; }

/* === Report Hub === */
.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.report-card {
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 1.25rem; text-decoration: none; color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
    cursor: pointer;
}
.report-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.report-card-primary {
    border-color: var(--primary);
    border-width: 2px;
    background: linear-gradient(135deg, #f0f4ff 0%, #fff 100%);
}
.report-card-icon { font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.6; }
.report-card h2 { font-size: 1.1rem; margin: 0 0 0.4rem 0; }
.report-card p { font-size: 0.82rem; color: #666; line-height: 1.45; flex: 1; margin: 0; }
.report-card-action { margin-top: 0.75rem; font-size: 0.82rem; font-weight: 600; color: var(--primary); }

/* === Stats Bar === */
.stats-bar {
    display: flex; flex-wrap: wrap; gap: 1.5rem;
    padding: 0.75rem 1rem; background: #f8fafc; border: 1px solid var(--border);
    border-radius: 8px; margin-bottom: 1.25rem;
}
.stat-item { text-align: center; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: #333; display: block; }
.stat-label { font-size: 0.7rem; color: #888; text-transform: uppercase; letter-spacing: 0.03em; }

/* === Section Toggle (collapsible details) === */
.section-toggle {
    font-size: 1.05rem; font-weight: 600; color: #333;
    cursor: pointer; padding: 0.5rem 0; list-style: none;
}
.section-toggle::-webkit-details-marker { display: none; }
.section-toggle::before { content: '▸ '; color: #888; display: inline; }
details[open] .section-toggle::before { content: '▾ '; }

/* === Business Grid === */
.biz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.biz-card {
    display: block; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; padding: 1rem; text-decoration: none; color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
}
.biz-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.biz-card h3 { font-size: 1rem; margin: 0 0 0.5rem 0; }
.biz-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.biz-stats { display: flex; gap: 1rem; }
.biz-stat-val { font-weight: 700; font-size: 1.05rem; color: #333; display: block; }
.biz-stat-lbl { font-size: 0.7rem; color: #888; }

/* === Sticky Column (pivot tables) === */
.sticky-col {
    position: sticky; left: 0; z-index: 2;
    background: #fff;
}
thead .sticky-col { background: #f8fafc; z-index: 3; }

/* === Table-specific helpers === */
.zero-cell { color: #ccc; }
.col-total { background: #f8fafc; }
.totals-row { border-top: 2px solid var(--border); }
.totals-row td { font-weight: 700; }
.totals-row .sticky-col { background: #f8fafc; }
.company-summary { display: flex; gap: 0.75rem; font-size: 0.8rem; color: #555; flex-wrap: wrap; }

/* === Responsive === */

/* Tables: always full width, scroll wrapper handles overflow */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
}

.table-scroll .data-table {
    width: 100%;
    min-width: 100%;
}

/* Sticky first column on horizontal scroll */
.table-scroll .data-table.sticky-first th:first-child,
.table-scroll .data-table.sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
}
.table-scroll .data-table.sticky-first thead th:first-child {
    background: #f8fafc;
    z-index: 3;
}

/* Wide desktop (1200px+): let wide containers breathe */
@media (min-width: 1200px) {
    .container.container-wide {
        max-width: 1440px;
    }
    .container.container-fluid {
        padding-left: 2.5rem;
        padding-right: 2.5rem;
    }
}

/* Extra-wide desktop (1600px+) */
@media (min-width: 1600px) {
    .container.container-wide {
        max-width: 1600px;
    }
}

/* Tablet breakpoint */
@media (max-width: 768px) {
    body { font-size: 15px; }

    .container { padding: 0.75rem; }
    .container.container-wide,
    .container.container-fluid { padding-left: 0.75rem; padding-right: 0.75rem; }

    /* Navbar: show hamburger, hide nav-right by default */
    .navbar {
        padding: 0 0.75rem;
        height: var(--nav-height);
        flex-wrap: wrap;
    }

    .nav-toggle { display: block; }

    .nav-right {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 0;
        border-top: 1px solid var(--border);
    }

    .nav-right.open { display: flex; }

    .navbar.menu-open { height: auto; }

    .nav-user { display: block; font-size: 0.8rem; color: var(--text-muted); }

    /* Page header stacks */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .page-header h1 { font-size: 1.25rem; }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
    .header-actions .btn {
        justify-content: center;
        white-space: normal;
        text-align: center;
        font-size: 0.78rem;
        padding: 0.5rem 0.4rem;
        line-height: 1.2;
    }

    /* Cards tighter */
    .card { padding: 1rem; }

    /* Info bar stacks into two columns */
    .info-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    /* Module grid single column */
    .module-grid {
        grid-template-columns: 1fr;
    }

    /* Forms single column */
    .form-inline-grid { grid-template-columns: 1fr; }
    .allocation-grid { grid-template-columns: 1fr 1fr; }
    .input-suffix input { width: 100%; flex: 1; }

    /* Tables: more compact on mobile */
    .data-table th,
    .data-table td {
        padding: 0.4rem 0.4rem;
        font-size: 0.78rem;
    }

    /* Numeric cells tighter */
    .data-table .num {
        padding-left: 0.25rem;
        padding-right: 0.35rem;
    }

    /* Hide lower-priority columns on mobile */
    .hide-mobile { display: none !important; }

    /* Actions cell: wrap on mobile */
    .actions-cell {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .actions-cell form { display: inline; }

    /* View toggle buttons */
    .view-tab {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.75rem !important;
    }

    /* Admin: inline password reset form stacks */
    .inline-form {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .input-sm { width: 100px; }

    /* Buttons: larger touch targets */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Form row stacks */
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    /* Doc tabs scroll on mobile */
    .doc-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .doc-tab { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

    /* Charts shorter on mobile */
    .chart-container { height: 250px; }

    /* Login card: full width with less padding */
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
        max-width: none;
    }

    /* Flash messages */
    .flash { font-size: 0.8rem; padding: 0.6rem 0.75rem; }

    /* Trend controls stack */
    .trend-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    .trend-controls select {
        width: 100%;
    }

    /* Card header row stacks */
    .card-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Filter bar stacks */
    .filter-bar-inner {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    .filter-bar-inner > div {
        min-width: 100% !important;
        flex: none !important;
    }

    /* KPI cards: 2 column grid */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .kpi-card { padding: 0.6rem 0.5rem; }
    .kpi-label { font-size: 0.6rem; }
    .kpi-value { font-size: 1.05rem; }

    /* Multi-select filters: compact */
    .ms-toggle { min-width: 110px; max-width: 160px; font-size: 0.75rem; padding: 0.35rem 0.5rem; }
    .ms-dropdown { min-width: 180px; }
    .filter-card { padding: 0.5rem 0.75rem; }
    .filter-form { gap: 0.4rem; }
    .months-select { min-width: 65px; font-size: 0.8rem; }

    /* Chart compact */
    .chart-area { height: 140px; padding: 0.75rem 0.5rem; gap: 0.15rem; }
    .chart-col { min-width: 22px; }
    .chart-label { font-size: 0.55rem; }

    /* Report hub */
    .report-cards { grid-template-columns: 1fr; gap: 0.75rem; }
    .report-card { padding: 1rem; }
    .report-card h2 { font-size: 1rem; }
    .stats-bar { gap: 1rem; padding: 0.6rem 0.75rem; }
    .stat-value { font-size: 1.1rem; }
    .biz-grid { grid-template-columns: 1fr; }

    /* Company summary */
    .company-summary { font-size: 0.7rem; gap: 0.5rem; }
    .card-header-bar { padding: 0.5rem 0.75rem; }

    /* Mobile: file uploads don't work well — hide upload forms, file inputs,
       and any element explicitly marked as desktop-only upload UI. */
    form[enctype="multipart/form-data"],
    input[type="file"],
    .file-input,
    .upload-only {
        display: none !important;
    }
}

/* Extra small screens (iPhone SE etc.) */
@media (max-width: 380px) {
    .container { padding: 0.5rem; }
    .card { padding: 0.75rem; }
    .page-header h1 { font-size: 1.1rem; }
    .nav-brand { font-size: 1rem; }
    .nav-link { font-size: 0.8rem; }
    .btn { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
    .allocation-grid { grid-template-columns: 1fr; }

    .info-bar { grid-template-columns: 1fr; }

    .header-actions {
        grid-template-columns: 1fr;
    }

    .data-table th,
    .data-table td {
        padding: 0.3rem 0.3rem;
        font-size: 0.73rem;
    }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.35rem; }
    .kpi-value { font-size: 0.95rem; }
    .ms-toggle { min-width: 90px; max-width: 140px; }
}
