/* ═══════════════════════════════════════════════════════════════════════
   Ethereal Assurance CRM — Design System
   One stylesheet for every authenticated screen. Page files should only
   add layout specific to that page; components live here.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    /* Brand (from logo) */
    --brand-navy: #1e2a5e;
    --brand-cyan: #13b0d9;

    /* Primary — royal blue between the logo's navy and cyan */
    --primary-950: #141c45;
    --primary-900: #1f2f71;
    --primary-800: #213792;
    --primary-700: #2640b5;
    --primary-600: #2f4fd8;
    --primary-500: #4a6aec;
    --primary-400: #6f8cf5;
    --primary-300: #9fb5fb;
    --primary-200: #c6d4fe;
    --primary-100: #e0e8ff;
    --primary-50:  #f0f4ff;

    /* Legacy aliases kept so existing inline styles keep resolving */
    --blue-950: var(--primary-950);
    --blue-900: var(--primary-900);
    --blue-800: var(--primary-800);
    --blue-700: var(--primary-700);
    --blue-600: var(--primary-600);
    --blue-500: var(--primary-500);
    --blue-400: var(--primary-400);
    --blue-300: var(--primary-300);
    --blue-200: var(--primary-200);
    --blue-100: var(--primary-100);
    --blue-50:  var(--primary-50);

    --accent-600: #0e93b8;
    --accent-500: #13b0d9;
    --accent-100: #d4f3fb;
    --accent-50:  #ecfafe;

    --red-900: #7f1d1d;
    --red-800: #991b1b;
    --red-700: #b91c1c;
    --red-600: #dc2626;
    --red-500: #ef4444;
    --red-400: #f87171;
    --red-300: #fca5a5;
    --red-200: #fecaca;
    --red-100: #fee2e2;
    --red-50:  #fef2f2;

    --emerald-700: #047857;
    --emerald-600: #059669;
    --emerald-500: #10b981;
    --emerald-200: #a7f3d0;
    --emerald-100: #d1fae5;
    --emerald-50:  #ecfdf5;

    --amber-700: #b45309;
    --amber-600: #d97706;
    --amber-500: #f59e0b;
    --amber-200: #fde68a;
    --amber-100: #fef3c7;
    --amber-50:  #fffbeb;

    /* Neutrals — cool slate */
    --white:    #ffffff;
    --surface:  #f5f6f8;
    --surface-2:#eef0f4;
    --gray-25:  #fbfcfd;
    --gray-50:  #f7f8fa;
    --gray-100: #f1f3f6;
    --gray-150: #e9ecf1;
    --gray-200: #e1e5eb;
    --gray-300: #cbd1db;
    --gray-400: #9aa3b2;
    --gray-500: #6b7485;
    --gray-600: #4c5465;
    --gray-700: #353c4b;
    --gray-800: #1f2532;
    --gray-900: #121722;
    --gray-950: #0a0d14;

    /* Sidebar */
    --sidebar-width: 248px;
    --sidebar-bg: #0e1433;
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-text: rgba(226,232,255,0.62);
    --sidebar-text-hover: #ffffff;
    --sidebar-hover: rgba(255,255,255,0.05);
    --sidebar-active-bg: rgba(255,255,255,0.08);
    --sidebar-label: rgba(226,232,255,0.38);

    /* Elevation */
    --shadow-xs:  0 1px 2px rgba(16,24,40,0.05);
    --shadow-sm:  0 1px 2px rgba(16,24,40,0.05), 0 1px 3px rgba(16,24,40,0.06);
    --shadow:     0 2px 4px -1px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
    --shadow-md:  0 4px 8px -2px rgba(16,24,40,0.08), 0 2px 4px -2px rgba(16,24,40,0.05);
    --shadow-lg:  0 12px 16px -4px rgba(16,24,40,0.08), 0 4px 6px -2px rgba(16,24,40,0.03);
    --shadow-xl:  0 20px 24px -4px rgba(16,24,40,0.10), 0 8px 8px -4px rgba(16,24,40,0.04);
    --shadow-2xl: 0 24px 48px -12px rgba(16,24,40,0.22);
    --shadow-card: 0 1px 2px rgba(16,24,40,0.04);
    --shadow-card-hover: 0 1px 3px rgba(16,24,40,0.06), 0 6px 16px -4px rgba(16,24,40,0.06);
    --shadow-glow: var(--ring);
    --ring: 0 0 0 3px rgba(47,79,216,0.16);
    --ring-danger: 0 0 0 3px rgba(220,38,38,0.14);

    /* Spacing */
    --sp-0: 0.125rem;
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;

    /* Radius */
    --radius-xs:  4px;
    --radius-sm:  6px;
    --radius:     8px;
    --radius-md:  8px;
    --radius-lg:  10px;
    --radius-xl:  12px;
    --radius-2xl: 16px;
    --radius-full: 9999px;

    /* Controls */
    --control-h: 36px;
    --control-h-sm: 30px;

    /* Motion */
    --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-fast: 120ms var(--ease-in-out);
    --transition:      160ms var(--ease-in-out);
    --transition-slow: 260ms var(--ease-out);
    --transition-spring: 320ms var(--ease-spring);
}

/* ═══ RESET & BASE ═══════════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--surface);
    min-height: 100vh;
    letter-spacing: -0.006em;
    font-feature-settings: 'cv11', 'ss01';
    overflow-x: hidden;
}

img, svg { display: inline-block; vertical-align: middle; }
img { max-width: 100%; }
a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--primary-700); }
strong, b { font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
::selection { background: var(--primary-100); color: var(--primary-900); }

:where(.main) ::-webkit-scrollbar { width: 10px; height: 10px; }
:where(.main) ::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
:where(.main) ::-webkit-scrollbar-thumb:hover { background-color: var(--gray-400); }
:where(.main) ::-webkit-scrollbar-track { background: transparent; }

/* ═══ APP SHELL ══════════════════════════════════════════════════════ */
.dashboard { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    /* Only transform animates, so the slide runs on the compositor and
       never re-lays out the page behind it. */
    transition: transform 240ms var(--ease-out);
    will-change: transform;
    contain: layout paint;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 6px; }

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 18px 16px;
    margin-bottom: 4px;
    text-decoration: none;
    flex-shrink: 0;
}
.brand:hover { color: inherit; }
.brand-logo-badge {
    width: 34px; height: 34px;
    flex-shrink: 0;
    border-radius: 9px;
    background: #ffffff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 2px 6px rgba(0,0,0,0.25);
    transition: transform var(--transition);
}
.brand:hover .brand-logo-badge { transform: scale(1.04); }
.brand-logo-badge img,
.brand img.brand-logo-img { height: 22px; width: auto; max-width: 22px; object-fit: contain; }
.brand-info { display: flex; flex-direction: column; min-width: 0; }
.brand-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.015em;
    line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-subtitle {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--sidebar-label);
    line-height: 1.3;
    margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Navigation */
.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px 12px;
    flex: 1;
}
.nav-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--sidebar-label);
    padding: 14px 10px 6px;
    letter-spacing: 0.01em;
}
.nav-sep {
    height: 1px;
    background: var(--sidebar-border);
    margin: 10px 8px;
    flex-shrink: 0;
}
.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    user-select: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.nav a svg, .nav a .nav-icon {
    width: 16px; height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text-hover); }
.nav a:hover svg { opacity: 1; }
.nav a.active {
    background: var(--sidebar-active-bg);
    color: #ffffff;
}
.nav a.active svg { opacity: 1; color: var(--brand-cyan); }
.nav a.active::before {
    content: '';
    position: absolute;
    left: -10px; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-cyan);
}
.nav a:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: -2px; }

/* Signed-in user */
.agent-profile {
    margin: auto 10px 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--sidebar-border);
    background: rgba(255,255,255,0.03);
    flex-shrink: 0;
}
.agent-profile > div:last-child { min-width: 0; overflow: hidden; }
.agent-avatar {
    width: 30px; height: 30px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-500), var(--brand-cyan));
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    letter-spacing: 0.02em;
}
.agent-label { font-size: 0.6875rem; color: var(--sidebar-label); line-height: 1.2; }
.agent-name {
    font-size: 0.8125rem; font-weight: 500; color: #ffffff; line-height: 1.35;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(10,13,20,0.45);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms var(--ease-out);
    will-change: opacity;
}
body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

body.sidebar-collapsed .sidebar { transform: translateX(-100%); }

/* Main column */
.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 28px 32px 40px;
    /* No margin transition: animating it re-flows the full leads table on
       every frame. The column snaps while the sidebar slides over it. */
}
body.sidebar-collapsed .main { margin-left: 0; }

/* Content enters once on load. `backwards` fill means no transform remains
   afterwards, so position:fixed children (menus, modals) are never trapped. */
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.main > *:not(.modal):not(.import-loading) { animation: pageIn 360ms var(--ease-out) backwards; }
.main > *:nth-child(2) { animation-delay: 30ms; }
.main > *:nth-child(3) { animation-delay: 60ms; }
.main > *:nth-child(4) { animation-delay: 90ms; }
.main > *:nth-child(n+5) { animation-delay: 120ms; }

/* Topbar / page header */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 40px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right,
.topbar > .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar h1 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.025em;
    line-height: 1.2;
}
.page-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-subtitle { font-size: 0.8125rem; color: var(--gray-500); line-height: 1.4; }

.hamburger {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    box-shadow: var(--shadow-xs);
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.hamburger:hover { background: var(--gray-50); color: var(--gray-900); border-color: var(--gray-300); }
.hamburger:active { transform: scale(0.96); }

.footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-150);
    font-size: 0.75rem;
    color: var(--gray-400);
    text-align: left;
}

/* ═══ BUTTONS ════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--control-h);
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast), transform 80ms ease;
}
.btn svg { flex-shrink: 0; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary-600); color: #ffffff; box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,0.12); }
.btn-primary:hover:not(:disabled) { background: var(--primary-700); color: #ffffff; }

.btn-secondary,
.btn-outline { background: var(--white); color: var(--gray-700); border-color: var(--gray-200); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled),
.btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); }

.btn-danger { background: var(--red-600); color: #ffffff; box-shadow: var(--shadow-xs); }
.btn-danger:hover:not(:disabled) { background: var(--red-700); color: #ffffff; }

.btn-danger-soft { background: var(--white); color: var(--red-600); border-color: var(--gray-200); }
.btn-danger-soft:hover:not(:disabled) { background: var(--red-50); border-color: var(--red-200); color: var(--red-700); }

.btn-success { background: var(--emerald-600); color: #ffffff; box-shadow: var(--shadow-xs); }
.btn-success:hover:not(:disabled) { background: var(--emerald-700); color: #ffffff; }

.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-900); }

.btn-sm { height: var(--control-h-sm); padding: 0 10px; font-size: 0.75rem; border-radius: var(--radius-sm); }
.btn-lg { height: 42px; padding: 0 18px; font-size: 0.875rem; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-sm.btn-icon { width: var(--control-h-sm); }
.btn-block { width: 100%; }

/* ═══ CARD ═══════════════════════════════════════════════════════════ */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-150);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.01em;
    flex-wrap: wrap;
}
.card-title { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; font-weight: 600; color: var(--gray-900); min-width: 0; }
.card-title svg { color: var(--gray-400); flex-shrink: 0; }
.card-subtitle { font-size: 0.75rem; font-weight: 400; color: var(--gray-500); }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--gray-150); background: var(--gray-25); }

.count-pill {
    display: inline-flex; align-items: center;
    height: 20px; padding: 0 8px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 0.6875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ═══ KPI STATS ══════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stats-grid:empty { display: none; }
.stat-card {
    position: relative;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-card-hover); border-color: var(--gray-300); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.stat-card-label { font-size: 0.75rem; font-weight: 500; color: var(--gray-500); }
.stat-icon {
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gray-100); color: var(--gray-500);
}
.stat-card.blue .stat-icon  { background: var(--primary-50); color: var(--primary-600); }
.stat-card.green .stat-icon { background: var(--emerald-50); color: var(--emerald-600); }
.stat-card.amber .stat-icon { background: var(--amber-50); color: var(--amber-600); }
.stat-card.red .stat-icon,
.stat-card.crimson .stat-icon { background: var(--red-50); color: var(--red-600); }
.stat-card.cyan .stat-icon { background: var(--accent-50); color: var(--accent-600); }
.stat-card-value {
    font-size: 1.625rem;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-card-sub { font-size: 0.75rem; color: var(--gray-500); margin-top: 6px; }

/* ═══ FORMS ══════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group > label,
.form-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
}
.form-hint { font-size: 0.75rem; color: var(--gray-500); }
.req { color: var(--red-600); margin-left: 2px; }

.form-control {
    width: 100%;
    max-width: 100%;
    height: var(--control-h);
    padding: 0 12px;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--gray-900);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:hover { border-color: var(--gray-300); }
.form-control:focus { border-color: var(--primary-500); box-shadow: var(--ring); }
.form-control:disabled { background: var(--gray-50); color: var(--gray-400); cursor: not-allowed; }
textarea.form-control { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.55; resize: vertical; }

select.form-control,
.select-control {
    padding-right: 32px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7485' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

input[type="number"].form-control::-webkit-inner-spin-button,
input[type="number"].form-control::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"].form-control { -moz-appearance: textfield; appearance: textfield; }

input[type="checkbox"], input[type="radio"] {
    width: 15px; height: 15px;
    accent-color: var(--primary-600);
    cursor: pointer;
    vertical-align: middle;
}

/* Two-column form layout used by create / edit forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full,
.form-grid .form-group.full { grid-column: 1 / -1; }
.form-section-title {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-900);
    padding-top: 8px;
}
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--gray-150); }
.form-section-title:first-child { padding-top: 0; }

/* ═══ FILTER BAR ═════════════════════════════════════════════════════ */
.filter-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    margin-bottom: 16px;
}
.filter-header {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-150);
}
.filter-header,
.filter-header-left { font-size: 0.8125rem; font-weight: 600; color: var(--gray-900); }
.filter-header-left { display: flex; align-items: center; gap: 8px; }
.filter-header > svg, .filter-header-left svg { width: 14px; height: 14px; color: var(--gray-400); flex-shrink: 0; }
.filter-header > span { margin-right: auto; }
.filter-header-right { font-size: 0.75rem; font-weight: 400; color: var(--gray-500); }
.filter-body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; flex: 1 1 160px; min-width: 0; }
.filter-group.grow, .filter-group.search-group { flex: 2 1 240px; }
.filter-group label { font-size: 0.75rem; font-weight: 500; color: var(--gray-600); }
.filter-group select,
.filter-group input[type="date"],
.filter-group input[type="text"]:not(.search-wrapper input) {
    width: 100%;
    height: var(--control-h);
    padding: 0 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background-color: var(--white);
    color: var(--gray-900);
    font-size: 0.8125rem;
    box-shadow: var(--shadow-xs);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.filter-group select {
    appearance: none; -webkit-appearance: none;
    padding-right: 32px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7485' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.filter-group input[type="date"] { cursor: pointer; }
.filter-group select:hover, .filter-group input:hover { border-color: var(--gray-300); }
.filter-group select:focus, .filter-group input:focus { border-color: var(--primary-500); box-shadow: var(--ring); }
.filter-actions { display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; }

.btn-filter-apply,
.btn-filter-reset {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: var(--control-h);
    padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.btn-filter-apply { background: var(--primary-600); color: #ffffff; border: 1px solid transparent; box-shadow: var(--shadow-xs); }
.btn-filter-apply:hover { background: var(--primary-700); }
.btn-filter-reset { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-200); box-shadow: var(--shadow-xs); }
.btn-filter-reset:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); }

.pills-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.active-pill {
    display: inline-flex; align-items: center; gap: 4px;
    height: 24px; padding: 0 10px;
    border-radius: var(--radius-full);
    background: var(--primary-50); color: var(--primary-700);
    border: 1px solid var(--primary-100);
    font-size: 0.75rem; font-weight: 500;
}
.active-pill .pill-close { cursor: pointer; opacity: 0.6; margin-left: 2px; }
.active-pill .pill-close:hover { opacity: 1; }

/* Quick date chips */
.date-presets-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 16px 14px; }
.preset-tag { font-size: 0.75rem; color: var(--gray-500); margin-right: 2px; }
.date-pill-sm,
.chip {
    height: 28px;
    padding: 0 11px;
    border-radius: var(--radius-full);
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.date-pill-sm:hover, .chip:hover { background: var(--gray-50); color: var(--gray-900); border-color: var(--gray-300); }
.date-pill-sm.active, .chip.active { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-200); }

/* Search input with icon */
.search-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.search-btn-icon {
    position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center;
    padding: 0; margin: 0;
    background: transparent; border: none;
    color: var(--gray-400);
    z-index: 2;
    transition: color var(--transition-fast);
}
.search-btn-icon:hover, .search-wrapper:focus-within .search-btn-icon { color: var(--primary-600); }
.search-wrapper input,
.filter-group .search-wrapper input[type="text"] {
    width: 100%;
    height: var(--control-h);
    padding: 0 32px 0 34px !important;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-900);
    font-size: 0.8125rem;
    box-shadow: var(--shadow-xs);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-wrapper input::placeholder { color: var(--gray-400); }
.search-wrapper input:hover { border-color: var(--gray-300); }
.search-wrapper input:focus { border-color: var(--primary-500); box-shadow: var(--ring); }
.search-clear-btn {
    position: absolute; right: 8px; top: 50%;
    transform: translateY(-50%);
    width: 20px; height: 20px;
    display: none; align-items: center; justify-content: center;
    padding: 0;
    border: none;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-500);
    z-index: 2;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.search-clear-btn:hover { background: var(--gray-200); color: var(--gray-900); }

/* ═══ TABLES ═════════════════════════════════════════════════════════ */
/* position:relative keeps absolutely positioned descendants (e.g. .sr-only
   header labels) inside the scroll container instead of widening the page. */
.table-wrapper {
    position: relative;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
thead th {
    height: 38px;
    padding: 0 14px;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-150);
}
tbody td {
    padding: 12px 14px;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
    line-height: 1.4;
    transition: background 100ms ease;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-25); }
.data-table tbody tr:hover td { background: #f8f9fc; }

th.col-check, td.col-check,
thead th:has(> input[type="checkbox"]),
tbody td:has(> input.rowCheck) { width: 44px; padding-right: 0; }
th.col-num, td.col-num { width: 56px; color: var(--gray-400); font-variant-numeric: tabular-nums; }
th.col-actions, td.col-actions { text-align: right; white-space: nowrap; }
/* Keep row actions reachable when a wide table scrolls horizontally */
.table-wrapper th.col-actions,
.table-wrapper td.col-actions { position: sticky; right: 0; z-index: 1; }
.table-wrapper th.col-actions { background: var(--gray-50); }
.table-wrapper td.col-actions { background: var(--white); }
.table-wrapper tbody tr:hover td.col-actions { background: #f8f9fc; }
.table-wrapper td.col-actions:has(.action-dropdown.show) { z-index: 30; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono, .font-mono { font-family: var(--font-mono); font-size: 0.95em; }

/* Empty / loading row */
td.empty,
.empty {
    padding: 48px 24px !important;
    text-align: center !important;
    color: var(--gray-500);
    font-size: 0.8125rem;
}
tbody tr:hover td.empty { background: transparent; }
.empty-icon { display: block; font-size: 1.75rem; line-height: 1; margin-bottom: 12px; opacity: 0.35; }
.empty-title { font-size: 0.875rem; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.empty-text { font-size: 0.8125rem; color: var(--gray-500); line-height: 1.55; }

/* Lead identity cells */
.customer-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.customer-avatar {
    width: 32px; height: 32px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-100);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.customer-info { display: flex; flex-direction: column; min-width: 0; }
.customer-name { font-weight: 500; color: var(--gray-900); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.customer-sub { font-size: 0.75rem; color: var(--gray-500); line-height: 1.3; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.phone-cell { display: inline-block; max-width: 150px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; color: var(--gray-700); font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-cell { white-space: nowrap; line-height: 1.3; }
.date-main { color: var(--gray-800); }
.date-sub { font-size: 0.75rem; color: var(--gray-500); margin-top: 1px; }
.tag-transferred { display: inline-block; margin-top: 2px; font-size: 0.6875rem; font-weight: 500; color: var(--primary-600); }
.cell-muted { color: var(--gray-400); }
.link-sm { display: inline-block; margin-top: 4px; font-size: 0.75rem; font-weight: 500; color: var(--primary-600); }
.link-sm:hover { text-decoration: underline; }

/* ═══ BADGES ═════════════════════════════════════════════════════════ */
.badge,
.badge-lead {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: var(--radius-full); flex-shrink: 0; background: currentColor; opacity: 0.85; }
.badge-dot { width: 6px; height: 6px; border-radius: var(--radius-full); flex-shrink: 0; }

.badge-primary, .badge.new                       { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-100); }
.badge-success, .badge.confirmed                 { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-100); }
.badge-warning, .badge.pending                   { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-100); }
.badge-danger, .badge.denied                     { background: var(--red-50); color: var(--red-700); border-color: var(--red-100); }
.badge-neutral, .badge.neutral, .badge.expired   { background: var(--gray-50); color: var(--gray-600); border-color: var(--gray-200); }
.badge-cyan                                      { background: var(--accent-50); color: var(--accent-600); border-color: var(--accent-100); }

.badge-status-new       { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-100); }
.badge-status-new .badge-dot { background: var(--primary-500); }
.badge-status-verified  { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-100); }
.badge-status-verified .badge-dot { background: var(--emerald-500); }
.badge-status-packaging { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-100); }
.badge-status-packaging .badge-dot { background: var(--amber-500); }
.badge-status-docs      { background: var(--red-50); color: var(--red-700); border-color: var(--red-100); }
.badge-status-docs .badge-dot { background: var(--red-500); }
.badge-status-closed,
.badge-status-default   { background: var(--gray-50); color: var(--gray-600); border-color: var(--gray-200); }
.badge-status-closed .badge-dot,
.badge-status-default .badge-dot { background: var(--gray-400); }

.status-select {
    height: 24px;
    padding: 0 22px 0 10px;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    font-size: 0.75rem; font-weight: 500;
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2.5 3.75L5 6.25L7.5 3.75' stroke='%236b7485' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 7px center;
}
.status-select:focus { outline: none; box-shadow: var(--ring); }
.status-select.active  { background-color: var(--emerald-50); color: var(--emerald-700); }
.status-select.pending { background-color: var(--amber-50); color: var(--amber-700); }
.status-select.closed  { background-color: var(--red-50); color: var(--red-700); }
.status-select.new     { background-color: var(--primary-50); color: var(--primary-700); }
.status-select.neutral { background-color: var(--gray-100); color: var(--gray-600); }

/* ═══ ROW ACTIONS & MENUS ════════════════════════════════════════════ */
.action-menu, .action-wrap { position: relative; display: inline-flex; }
.action-btn {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-500);
    font-size: 1rem;
    line-height: 1;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.action-btn:hover, .action-btn[aria-expanded="true"] { background: var(--gray-100); color: var(--gray-900); border-color: var(--gray-200); }

/* Menus are positioned with position:fixed by js/ui.js so table scroll
   containers never clip them. The absolute fallback applies without JS. */
.action-dropdown,
.export-menu,
.menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 176px;
    padding: 4px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    z-index: 1500;
    text-align: left;
}
.action-dropdown.show,
.export-menu.show,
.menu-panel.show { display: block; animation: menuIn 140ms var(--ease-out); }
@keyframes menuIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
.action-dropdown button,
.export-menu button,
.menu-panel button {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-700);
    font-size: 0.8125rem;
    text-align: left;
    white-space: nowrap;
    transition: background 80ms ease, color 80ms ease;
}
.action-dropdown button:hover,
.export-menu button:hover,
.menu-panel button:hover { background: var(--gray-100); color: var(--gray-900); }
.action-dropdown button.danger { color: var(--red-600); }
.action-dropdown button.danger:hover { background: var(--red-50); color: var(--red-700); }
.dropdown-sep { height: 1px; margin: 4px 2px; background: var(--gray-150); }
.export-wrapper { position: relative; display: inline-block; }

/* Inline row buttons (agent table) */
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }

/* ═══ MODAL ══════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgba(10,13,20,0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeIn 160ms ease-out;
    overflow-y: auto;
}
.modal.show,
.modal.open { display: flex; }
body.modal-open { overflow: hidden; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    margin: auto;
    padding: 24px;
    background: var(--white);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-2xl);
    animation: modalIn 220ms var(--ease-out);
}
.modal-content.modal-lg { max-width: 720px; }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
.modal-content h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin-bottom: 4px;
}
.modal-content > p,
.modal-subtitle { font-size: 0.8125rem; color: var(--gray-500); line-height: 1.55; margin-bottom: 18px; }
.modal-close {
    position: absolute; top: 16px; right: 16px;
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--gray-400);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 24px -24px -24px;
    padding: 14px 24px;
    border-top: 1px solid var(--gray-150);
    background: var(--gray-25);
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}
/* Sticky offsets are measured from the content edge, so cancel the padding */
.modal-content.has-sticky-footer .modal-footer { position: sticky; bottom: -24px; z-index: 1; }

/* Key/value grid used in detail popups */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.detail-grid .span-2 { grid-column: 1 / -1; }
.detail-label { display: block; font-size: 0.75rem; color: var(--gray-500); margin-bottom: 2px; }
.detail-value { font-size: 0.875rem; color: var(--gray-900); word-break: break-word; }

/* ═══ TABS (segmented) ═══════════════════════════════════════════════ */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--gray-100);
    border: 1px solid var(--gray-150);
    border-radius: var(--radius-lg);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented > button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--gray-600);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.segmented > button:hover { color: var(--gray-900); }
.segmented > button.active { background: var(--white); color: var(--gray-900); box-shadow: var(--shadow-sm); }

/* ═══ ALERTS ═════════════════════════════════════════════════════════ */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid;
    font-size: 0.8125rem;
    line-height: 1.5;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-800); }
.alert-success { background: var(--emerald-50); border-color: var(--emerald-100); color: var(--emerald-700); }
.alert-warning { background: var(--amber-50); border-color: var(--amber-200); color: var(--amber-700); }
.alert-danger  { background: var(--red-50); border-color: var(--red-200); color: var(--red-800); }

/* ═══ TOASTS ═════════════════════════════════════════════════════════ */
.toast-stack {
    position: fixed;
    right: 20px; bottom: 20px;
    z-index: 3000;
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    max-width: 380px;
    padding: 11px 14px;
    background: var(--gray-900);
    color: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    font-size: 0.8125rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn 240ms var(--ease-out);
    transition: opacity 200ms ease, transform 200ms ease;
}
.toast.leaving { opacity: 0; transform: translateY(6px); }
.toast-icon { width: 18px; height: 18px; border-radius: var(--radius-full); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--emerald-500); }
.toast.error .toast-icon { background: var(--red-500); }
.toast.info .toast-icon { background: var(--primary-500); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ═══ SPINNERS & SKELETON ════════════════════════════════════════════ */
.spinner, .spinner-sm {
    display: inline-block;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary-600);
    animation: spin 700ms linear infinite;
    flex-shrink: 0;
}
.spinner { width: 32px; height: 32px; border-width: 3px; }
.spinner-sm { width: 14px; height: 14px; }
.spinner-light,
.btn-primary .spinner-sm, .btn-success .spinner-sm, .btn-danger .spinner-sm { border-color: rgba(255,255,255,0.35); border-top-color: #ffffff; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-50) 50%, var(--gray-100) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ═══ MISC ═══════════════════════════════════════════════════════════ */
.info-btn {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full);
    border: 1px solid var(--primary-100);
    background: var(--primary-50); color: var(--primary-600);
    font-size: 0.6875rem; font-weight: 700;
}
.info-btn:hover { background: var(--primary-600); color: #ffffff; }

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--gray-500); }
.d-flex       { display: flex; }
.align-items-center      { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.mb-2  { margin-bottom: var(--sp-2); }
.mb-3  { margin-bottom: var(--sp-3); }
.mb-4  { margin-bottom: var(--sp-4); }
.mt-2  { margin-top: var(--sp-2); }
.mt-3  { margin-top: var(--sp-3); }
.mt-4  { margin-top: var(--sp-4); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Keyboard focus — visible only for keyboard users */
:focus { outline: none; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible,
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ═══ RESPONSIVE ═════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
    .main { padding: 24px 24px 36px; }
}

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Sidebar becomes an off-canvas drawer */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.sidebar-open .sidebar,
    body.sidebar-collapsed .sidebar { transform: none; box-shadow: var(--shadow-2xl); }
    .main,
    body.sidebar-collapsed .main { margin-left: 0; }
}

@media (max-width: 768px) {
    .main { padding: 16px 16px 32px; }
    .topbar { margin-bottom: 16px; gap: 12px; }
    .topbar h1 { font-size: 1.125rem; }
    .page-subtitle { display: none; }
    .topbar-right, .topbar > .actions { width: 100%; }
    .topbar-right > .btn, .topbar > .actions > .btn { flex: 1 1 auto; }
    .card-header { padding: 12px 16px; }
    .card-body { padding: 16px; }
    .filter-body { padding: 12px; gap: 10px; }
    .filter-group, .filter-group.grow, .filter-group.search-group { flex: 1 1 100%; }
    .filter-actions { width: 100%; }
    .filter-actions > * { flex: 1; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
    .table-wrapper > table { min-width: 720px; }
    thead th { padding: 0 12px; }
    tbody td { padding: 10px 12px; }
    .modal { padding: 12px; align-items: flex-end; }
    .modal-content { padding: 20px; max-height: calc(100vh - 24px); border-radius: var(--radius-xl); }
    .modal-footer { margin: 20px -20px -20px; padding: 12px 20px; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
    .modal-content.has-sticky-footer .modal-footer { bottom: -20px; }
    .modal-footer > .btn { flex: 1; }
    .toast-stack { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
    .toast { max-width: none; }
}

@media (max-width: 480px) {
    .stats-grid { gap: 8px; }
    .stat-card { padding: 14px; }
    .stat-card-value { font-size: 1.375rem; }
    .footer { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .sidebar, .sidebar-overlay, .hamburger, .action-btn, .footer, .btn, .filter-card, .toast-stack { display: none !important; }
    .main { margin-left: 0 !important; padding: 0 !important; }
    body { background: #ffffff !important; }
    .card, .stat-card { box-shadow: none !important; border: 1px solid var(--gray-300) !important; }
}
