/* ================================================================
   เจริญพร Admin Dashboard
   Design system: Geist-inspired (Vercel) + Stripe KPI + Linear restraint
   Light default · Dark via [data-theme="dark"]
   Updated 2026-06-25 — full redesign
   ================================================================ */

/* ---------- TOKENS: LIGHT (default) ---------- */
:root {
    /* Surfaces — Vercel Geist Light scale */
    --bg:           #FAFAFA;     /* page canvas (never pure #fff) */
    --surface:      #FFFFFF;     /* cards, panels */
    --surface-2:    #F4F4F5;     /* nested / hover surface */
    --surface-3:    #EAEAEA;     /* deep nesting */
    --overlay:      rgba(0,0,0,0.40);

    /* Borders — hairline workhorse */
    --border:       #EAEAEA;
    --border-strong:#D4D4D4;

    /* Text */
    --text:         #0A0A0A;     /* headings, KPI big numbers */
    --text-muted:   #525252;     /* body, secondary */
    --text-dim:     #8F8F8F;     /* captions, deltas-vs */

    /* Brand & semantic */
    --primary:      #F7B045;     /* amber — brand (keep) */
    --primary-hover:#E89A2C;
    --primary-rgb:  247, 176, 69;

    --accent:       #0070F3;     /* Geist blue — secondary action */
    --accent-rgb:   0, 112, 243;

    --success:      #16A34A;     /* green */
    --success-rgb:  22, 163, 74;

    --warning:      #D97706;     /* amber-orange */
    --warning-rgb:  217, 119, 6;

    --error:        #DC2626;     /* red */
    --error-rgb:    220, 38, 38;

    /* Elevation — single shadow token in light, none in dark */
    --shadow-sm:    0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.02);
    --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg:    0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

    /* Layout */
    --sidebar-w:    260px;
    --radius:       8px;
    --radius-sm:    6px;
    --radius-lg:    12px;
    --radius-pill:  9999px;

    /* Typography */
    --font:         'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --font-heading: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
}

/* ---------- TOKENS: DARK ---------- */
[data-theme="dark"] {
    --bg:           #0A0A0A;
    --surface:      #111111;
    --surface-2:    #1A1A1A;
    --surface-3:    #232323;
    --overlay:      rgba(0,0,0,0.65);

    --border:       #1F1F1F;
    --border-strong:#2E2E2E;

    --text:         #EDEDED;
    --text-muted:   #A1A1A1;
    --text-dim:     #707070;

    --primary:      #F7B045;
    --primary-hover:#FFCA6A;
    --accent:       #3B82F6;
    --accent-rgb:   59, 130, 246;
    --success:      #22C55E;
    --success-rgb:  34, 197, 94;
    --warning:      #FBBF24;
    --warning-rgb:  251, 191, 36;
    --error:        #EF4444;
    --error-rgb:    239, 68, 68;

    --shadow-sm:    0 1px 2px rgba(0,0,0,0.5);
    --shadow:       0 1px 3px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-lg:    0 8px 24px rgba(0,0,0,0.7), 0 4px 8px rgba(0,0,0,0.5);
}

/* ---------- RESET ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
    transition: background 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }

/* Tabular numbers for currency, IDs, KPI */
.tabular, .rev-value, .card-value, .mini-card-value,
td.num, .num, .kpi-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---------- LOGIN ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 1.5rem;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo {
    width: 56px; height: 56px;
    margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: var(--radius);
    font-size: 1.75rem;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}
.login-title {
    font-family: var(--font-heading);
    font-size: 1.375rem; font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}
.login-subtitle {
    color: var(--text-muted); font-size: 0.875rem;
    margin-bottom: 1.75rem;
}
.login-error {
    color: var(--error); margin-top: 0.875rem;
    font-size: 0.8125rem; min-height: 1.2em;
}

/* ---------- FORMS ---------- */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem; font-weight: 500;
    margin-bottom: 0.375rem;
}
input, select, textarea {
    width: 100%; padding: 0.625rem 0.875rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:hover, select:hover, textarea:hover { border-color: var(--text-dim); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

/* FIX 2026-06-26: prevent global input width:100% from breaking checkboxes/radios */
input[type="checkbox"], input[type="radio"] {
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

textarea { min-height: 96px; resize: vertical; }
.password-wrap { position: relative; }
.pwd-toggle {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    font-size: 1.05rem; padding: 4px;
    color: var(--text-muted);
}
.pwd-toggle:hover { color: var(--text); }
.form-row { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; }

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}
.btn-primary:hover { background: var(--text-muted); border-color: var(--text-muted); }

.btn-accent {
    background: var(--primary);
    color: #1A1A1A;
    border-color: var(--primary);
}
.btn-accent:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-success {
    background: var(--success); color: #FFF; border-color: var(--success);
}
.btn-danger {
    background: var(--error); color: #FFF; border-color: var(--error);
}
.btn-warning {
    background: var(--warning); color: #FFF; border-color: var(--warning);
}
.btn-outline {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-outline:hover {
    background: var(--surface-2);
    border-color: var(--text-dim);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 0.9375rem; }
.btn-full { width: 100%; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- APP LAYOUT ---------- */
.app { display: flex; min-height: 100vh; background: var(--bg); }

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}
.sidebar-header {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}
.sidebar-logo {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}
.sidebar-brand {
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.sidebar-close {
    display: none;
    background: none; border: none;
    color: var(--text-muted);
    font-size: 1.25rem; cursor: pointer;
    margin-left: auto;
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem;
}
.nav-item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border-left: none;
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item.active {
    color: var(--text);
    background: var(--surface-2);
    font-weight: 600;
}
.nav-item .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    opacity: 0.85;
}
.nav-item.active .nav-icon { opacity: 1; }

/* Phase A.2 (2026-06-27): Sidebar category dividers */
.nav-divider {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    padding: 1rem 0.75rem 0.4rem;
    font-weight: 700;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}
.nav-divider:first-of-type { border-top: none; margin-top: 0.25rem; }
.sidebar-footer {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem;
}
.sidebar-user { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}
.sidebar-user-role {
    font-size: 0.6875rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Theme toggle button (icon) */
#theme-toggle-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    padding: 0; min-width: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#theme-toggle-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ---------- MAIN CONTENT ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg);
}
.top-bar {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
    min-height: 56px;
}
.hamburger {
    display: none;
    background: none; border: none;
    color: var(--text); font-size: 1.25rem;
    cursor: pointer;
}
.page-title {
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.top-bar-right {
    margin-left: auto;
    display: flex; align-items: center;
    gap: 0.75rem;
}

.alert-badge {
    display: inline-flex; align-items: center;
    background: rgba(var(--error-rgb), 0.08);
    color: var(--error);
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(var(--error-rgb), 0.18);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
}
.alert-badge:hover { background: rgba(var(--error-rgb), 0.12); }

.page-content { padding: 1.5rem; max-width: 1440px; }

/* ---------- CARDS (KPI tiles) ---------- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
    border-color: var(--border-strong);
}
.card-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}
.card-value {
    font-family: var(--font-heading);
    font-size: 1.625rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.card-change {
    display: inline-flex; align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.375rem;
}
.card-change.up { color: var(--success); }
.card-change.down { color: var(--error); }
.card-change.neutral { color: var(--text-dim); }

.card-wide { grid-column: span 2; }
.card-full { grid-column: 1 / -1; }

/* ---------- TABLES ---------- */
.table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
th {
    text-align: left;
    padding: 0.625rem 1rem;
    font-size: 0.6875rem;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}
td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
tr:nth-child(even) td { background: transparent; }
tr:nth-child(even):hover td { background: var(--surface-2); }

.status-badge {
    display: inline-flex; align-items: center;
    gap: 0.3rem;
    padding: 0.1875rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.02em;
}
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-active,
.status-confirmed {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success);
}
.status-expired,
.status-rejected {
    background: rgba(var(--error-rgb), 0.1);
    color: var(--error);
}
.status-pending {
    background: rgba(var(--warning-rgb), 0.12);
    color: var(--warning);
}

/* ---------- PAGINATION ---------- */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 0.375rem;
    margin-top: 1rem;
}
.pagination button {
    padding: 0.375rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
    transition: all 0.15s;
}
.pagination button.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}
.pagination button:hover:not(.active) {
    border-color: var(--border-strong);
    color: var(--text);
}

/* ---------- FILTERS ---------- */
.filters {
    display: flex; align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.search-input {
    flex: 1; min-width: 220px;
    padding: 0.5rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
}
.search-input:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}
.filter-btn {
    padding: 0.375rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s;
}
.filter-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}
.filter-btn:hover:not(.active) {
    background: var(--surface-2);
    border-color: var(--text-dim);
    color: var(--text);
}

/* ---------- TABS ---------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab {
    padding: 0.625rem 1rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--text);
    border-bottom-color: var(--text);
    font-weight: 600;
}

/* ---------- MODAL ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 560px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}
.modal-close {
    background: none; border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 1.25rem; }

/* ---------- TOAST ---------- */
.toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    display: flex; flex-direction: column;
    gap: 0.5rem;
    z-index: 300;
}
.toast {
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    animation: slideIn 0.25s ease;
    max-width: 380px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.toast-success {
    border-color: rgba(var(--success-rgb), 0.3);
    background: rgba(var(--success-rgb), 0.06);
    color: var(--success);
}
.toast-error {
    border-color: rgba(var(--error-rgb), 0.3);
    background: rgba(var(--error-rgb), 0.06);
    color: var(--error);
}
.toast-info {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--text);
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ---------- NOTIFICATION CARDS (top-right alert stream) ---------- */
.notif-panel {
    position: fixed; top: 1rem; right: 1rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    z-index: 999; max-width: 380px; width: 100%;
    pointer-events: none;
}
.notif-card {
    pointer-events: all;
    display: flex; gap: 0.75rem; align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.75rem 0.875rem;
    box-shadow: var(--shadow-lg);
    animation: notifSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, opacity 0.25s;
    position: relative;
}
.notif-card:hover { transform: translateY(-1px); }
.notif-card.notif-slip { border-left-color: var(--success); }
.notif-card.notif-sos  { border-left-color: var(--error);
    animation: notifSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1), notifGlow 1.5s ease infinite; }
.notif-card.notif-anomaly { border-left-color: var(--warning); }
.notif-card.notif-hide { opacity: 0; transform: translateX(120%); }

.notif-img {
    width: 64px; height: 80px; object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface-2);
}
.notif-body { flex: 1; min-width: 0; }
.notif-title {
    font-weight: 600; font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.2rem;
    display: flex; align-items: center; gap: 0.375rem;
}
.notif-title .notif-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: notifPulse 1.5s infinite;
}
.notif-sos .notif-dot { background: var(--error); }
.notif-anomaly .notif-dot { background: var(--warning); }
.notif-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.45; }
.notif-desc b { color: var(--text); font-weight: 600; }
.notif-time {
    font-size: 0.6875rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.notif-close {
    position: absolute; top: 0.25rem; right: 0.375rem;
    background: none; border: none;
    color: var(--text-dim);
    font-size: 1rem; cursor: pointer; padding: 2px;
    line-height: 1;
    border-radius: var(--radius-sm);
}
.notif-close:hover { color: var(--text); background: var(--surface-2); }
.notif-noimg {
    width: 40px; height: 40px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

@keyframes notifSlide {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes notifPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(1.3); }
}
@keyframes notifGlow {
    0%, 100% { box-shadow: var(--shadow-lg); }
    50%      { box-shadow: 0 0 0 3px rgba(var(--error-rgb), 0.15), var(--shadow-lg); }
}

@media (max-width: 600px) {
    .notif-panel { max-width: 100%; right: 0.5rem; left: 0.5rem; top: 0.5rem; }
    .notif-img { width: 52px; height: 64px; }
}

/* ---------- CHART CONTAINER ---------- */
.chart-container {
    position: relative;
    height: 220px;
    max-height: 280px;
    margin: 0.5rem 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
}
.chart-tall {
    height: 300px;
    max-height: 360px;
}

/* ---------- UPLOAD DROP ZONE ---------- */
.upload-zone {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 1.75rem;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 1rem;
    background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    color: var(--text);
    background: rgba(var(--primary-rgb), 0.04);
}
.upload-zone .icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.7; }
.upload-zone p { font-size: 0.875rem; font-weight: 500; }
.upload-zone .hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.3rem; }

/* ---------- GROUP CATEGORY ---------- */
.category-section { margin-bottom: 1.75rem; }
.category-header {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.875rem; font-weight: 600; color: var(--text);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.category-count {
    background: var(--surface-2);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- DM DESCRIPTION ---------- */
.dm-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.dm-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 1rem 0;
}

/* ---------- SECTION ---------- */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0;
    border-bottom: none;
    letter-spacing: -0.005em;
}
.alert-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.alert-box-item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}
.alert-box-item:last-child { border-bottom: none; }

/* ---------- DETAIL PANEL ---------- */
.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-sm);
}
.detail-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value {
    color: var(--text);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ---------- PENDING CARD ---------- */
.pending-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    margin-bottom: 0.625rem;
    display: flex; align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; gap: 0.625rem;
    box-shadow: var(--shadow-sm);
}
.pending-info {
    display: flex; flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    font-size: 0.875rem;
}

/* ---------- MINI CARDS (4-col) ---------- */
.mini-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.mini-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow-sm);
}
.mini-card-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.375rem;
}
.mini-card-value {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ---------- FUNNEL ---------- */
.funnel { margin: 1.25rem 0; }
.funnel-step {
    display: flex; align-items: center;
    gap: 0.875rem;
    margin-bottom: 0.625rem;
}
.funnel-bar {
    height: 28px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center;
    padding: 0 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1A1A1A;
    transition: width 0.5s ease;
    font-variant-numeric: tabular-nums;
}
.funnel-label {
    min-width: 160px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.funnel-pct {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 56px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- LOADING ---------- */
.loading {
    display: flex; align-items: center; justify-content: center;
    padding: 2.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- EMPTY STATE ---------- */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ================================================================
   DASHBOARD HOME — Hero section + metric tiles + analytics
   ================================================================ */
.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(320px, 480px);
    gap: 1rem;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.hero-kicker {
    color: var(--text-dim);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.375rem;
}
.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(1.25rem, 2.5vw, 1.625rem);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}
.hero-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}
.dashboard-filter-panel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
}
.quick-filters {
    display: flex; gap: 0.375rem; flex-wrap: wrap;
    margin-bottom: 0.625rem;
}
.dashboard-filters { margin-bottom: 0; }
.dashboard-filters select { min-width: 140px; width: auto; }
.filter-inline {
    display: flex; gap: 0.5rem;
    flex: 1; min-width: 220px;
}
.filter-inline input { min-width: 140px; }
.metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.metric-card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
}
.metric-card::after {
    content: none;
}
.metric-card.primary {
    background: var(--surface);
}
.metric-card.success {
    background: var(--surface);
}
.dashboard-grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.compact-overview .card { background: var(--surface); }

@media (max-width: 980px) {
    .dashboard-hero, .dashboard-grid-2 { grid-template-columns: 1fr; }
    .filter-inline { width: 100%; }
}

/* ================================================================
   TOTAL REVENUE SUMMARY (top of dashboard)
   Stripe-style: big number + delta pill + comparison
   ================================================================ */
.rev-summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}
.rev-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.rev-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}
.rev-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 2px;
    background: var(--text-dim);
    opacity: 0.35;
}
/* Color-coded accent line (subtle, not garish) */
.rev-card.today::before    { background: var(--warning); opacity: 0.9; }
.rev-card.month::before    { background: var(--accent);  opacity: 0.9; }
.rev-card.year::before     { background: var(--success); opacity: 0.9; }
.rev-card.alltime::before  { background: var(--text);    opacity: 0.7; }

.rev-label {
    font-size: 0.6875rem;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.rev-value {
    font-size: 1.625rem;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-heading);
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin-bottom: 0.375rem;
    font-variant-numeric: tabular-nums;
}
.rev-sub {
    display: inline-flex; align-items: center; gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.rev-delta {
    display: inline-flex; align-items: center;
    gap: 0.15rem;
    padding: 0.125rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
}
.rev-delta.up   { background: rgba(var(--success-rgb), 0.1); color: var(--success); }
.rev-delta.down { background: rgba(var(--error-rgb), 0.1); color: var(--error); }
.rev-delta.neutral { background: var(--surface-2); color: var(--text-muted); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .hamburger { display: block; }
    .main-content { margin-left: 0; }
    .page-content { padding: 1rem; }
    .top-bar { padding: 0.625rem 1rem; }
    .cards-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .card-wide { grid-column: span 1; }
    .form-row { flex-direction: column; }
    .filters { flex-direction: column; }
    .search-input { min-width: auto; width: 100%; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .rev-card { padding: 1rem; }
    .rev-value { font-size: 1.375rem; }
}
@media (max-width: 600px) {
    .dashboard-hero { padding: 1rem; border-radius: var(--radius); }
    .dashboard-filters select,
    .filter-inline input,
    .dashboard-filters .btn { width: 100%; }
    .filter-inline { flex-direction: column; }
    .chart-tall { height: 240px; max-height: 240px; }
}

/* ===== Sprint 3.3: Mobile responsive ===== */
@media (max-width: 768px) {
    /* Hide sidebar by default, toggle via burger */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
        width: 240px;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Overlay when drawer open */
    body.has-mobile-overlay::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }

    /* Main: full width on mobile */
    .main-content {
        margin-left: 0 !important;
        padding-bottom: 64px;  /* leave room for bottom nav */
    }
    .top-bar {
        padding: 0.5rem 0.75rem;
    }
    .page-content {
        padding: 0.75rem;
    }
    .page-title {
        font-size: 1rem !important;
    }

    /* Burger button shown on mobile */
    .mobile-burger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface);
        color: var(--text);
        font-size: 1.1rem;
        margin-right: 0.5rem;
        cursor: pointer;
    }

    /* Mini cards: stack 2 columns instead of 4 */
    .mini-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .mini-card-value {
        font-size: 1.25rem !important;
    }

    /* Tables: shrink + horizontal scroll */
    .table-wrap, table {
        font-size: 0.78rem;
    }
    table th, table td {
        padding: 0.35rem !important;
    }

    /* Cards: smaller padding */
    .card {
        padding: 0.75rem;
    }

    /* Modal: full-screen on mobile */
    .modal-content {
        max-width: 95vw !important;
        max-height: 92vh !important;
    }
    .modal-body {
        max-height: 75vh;
    }

    /* Bottom nav (mobile only) */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-bottom-nav .nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 0.7rem;
        color: var(--text-muted);
        cursor: pointer;
        gap: 0.15rem;
        background: transparent;
        border: none;
        padding: 0.25rem;
    }
    .mobile-bottom-nav .nav-btn.active {
        color: var(--accent);
    }
    .mobile-bottom-nav .nav-btn .icon {
        font-size: 1.2rem;
    }

    /* Filters: scroll horizontally */
    .filters {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }
    .filter-btn {
        flex-shrink: 0;
    }

    /* Top bar Export button: hide text label on mobile */
    .top-bar-right .btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    /* Customer 360: stack columns on mobile */
    .customer360-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Desktop: hide mobile burger + bottom nav */
@media (min-width: 769px) {
    .mobile-burger { display: none; }
    .mobile-bottom-nav { display: none; }
}


/* ===== Sprint 3.1: Cmd+K Palette ===== */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    backdrop-filter: blur(2px);
}
.cmdk-overlay.open { display: flex; }

.cmdk-modal {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    font-family: var(--font-sans);
}
.cmdk-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    background: transparent;
    color: var(--text);
    border: none;
    border-bottom: 1px solid var(--border);
    outline: none;
}
.cmdk-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.cmdk-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem 1rem 0.25rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    transition: background 0.1s;
}
.cmdk-item:hover, .cmdk-item.active {
    background: var(--surface-2);
}
.cmdk-item .icon {
    width: 24px;
    text-align: center;
    font-size: 1rem;
}
.cmdk-item .label { flex: 1; }
.cmdk-item .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.cmdk-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.cmdk-hint-bar {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
}
.cmdk-hint-bar kbd {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    margin: 0 0.15rem;
}
