/* =====================================================================
   Instagram Intelligence Suite — Premium Design System
   Self-contained, production CSS. No external framework at runtime.
   Sections:
     1. Design tokens (light/dark)
     2. Reset & base
     3. Typography & utilities
     4. App shell (sidebar + topbar + main)
     5. Components (cards, buttons, badges, tables, forms, menus)
     6. Feedback (skeletons, empty states, toasts)
     7. Command palette & modals
     8. Responsive
   ===================================================================== */

/* ------------------------------------------------------------------ */
/* 1. Design tokens                                                    */
/* ------------------------------------------------------------------ */
:root {
    /* Brand */
    --color-primary: #4F46E5;
    --color-primary-600: #4338CA;
    --color-primary-700: #3730A3;
    --color-primary-soft: rgba(79, 70, 229, 0.10);
    --color-secondary: #7C3AED;
    --color-success: #22C55E;
    --color-success-soft: rgba(34, 197, 94, 0.12);
    --color-warning: #F59E0B;
    --color-warning-soft: rgba(245, 158, 11, 0.14);
    --color-danger: #EF4444;
    --color-danger-soft: rgba(239, 68, 68, 0.12);
    --color-info: #0EA5E9;
    --color-info-soft: rgba(14, 165, 233, 0.12);

    --gradient-brand: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    --gradient-brand-soft: linear-gradient(135deg, rgba(79,70,229,0.12) 0%, rgba(124,58,237,0.12) 100%);

    /* Surfaces (light) */
    --bg-app: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-surface-2: #F1F5F9;
    --bg-elevated: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-hover: #F1F5F9;
    --bg-active: var(--color-primary-soft);

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --text-inverse: #FFFFFF;

    /* Borders */
    --border-color: #E2E8F0;
    --border-strong: #CBD5E1;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 999px;

    /* Shadows — soft premium */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.14);
    --shadow-glow: 0 8px 24px rgba(79, 70, 229, 0.28);

    /* Layout */
    --sidebar-width: 264px;
    --sidebar-collapsed: 76px;
    --topbar-height: 68px;
    --content-max: 1440px;

    /* Motion */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 120ms;
    --dur: 220ms;
    --dur-slow: 400ms;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg-app: #0B1120;
    --bg-surface: #0F172A;
    --bg-surface-2: #1E293B;
    --bg-elevated: #1E293B;
    --bg-sidebar: #0F172A;
    --bg-hover: #1E293B;
    --bg-active: rgba(99, 102, 241, 0.18);

    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;

    --border-color: #1E293B;
    --border-strong: #334155;

    --color-primary-soft: rgba(99, 102, 241, 0.16);
    --gradient-brand-soft: linear-gradient(135deg, rgba(99,102,241,0.16) 0%, rgba(139,92,246,0.16) 100%);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

/* ------------------------------------------------------------------ */
/* 2. Reset & base                                                     */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; font-size: 16px; }

body {
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
svg { flex-shrink: 0; }
ul { list-style: none; }

/* Custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); background-clip: content-box; }

::selection { background: var(--color-primary-soft); color: var(--color-primary-700); }

:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ */
/* 3. Typography & utilities                                           */
/* ------------------------------------------------------------------ */
.h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.h2 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.h3 { font-size: 1.125rem; font-weight: 650; letter-spacing: -0.01em; }
.page-title { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.page-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 4px; }
.eyebrow { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.text-muted { color: var(--text-secondary); }
.text-faint { color: var(--text-tertiary); }
.text-gradient { background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.mono { font-family: var(--font-mono); }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.grid { display: grid; }

/* Responsive layout grids — replace ad-hoc inline grid-template-columns so
   every multi-column page collapses cleanly on tablet/mobile in one place. */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-main-side { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.grid-side-main { display: grid; grid-template-columns: 1fr 1.6fr; gap: 18px; align-items: start; }
.grid-fixed-side { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.grid-4, .grid-stats-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-stats-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 900px) {
    .grid-main-side, .grid-side-main, .grid-fixed-side { grid-template-columns: 1fr; }
    .grid-stats-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-4, .grid-stats-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-stats-3 { grid-template-columns: 1fr; }
}

.hidden { display: none !important; }
.w-full { width: 100%; }
.w-3\.5 { width: 14px !important; }
.h-3\.5 { height: 14px !important; }
.w-4 { width: 16px !important; }
.h-4 { height: 16px !important; }
.w-5 { width: 20px !important; }
.h-5 { height: 20px !important; }
.mr-1 { margin-right: 4px !important; }
.mr-2 { margin-right: 8px !important; }
.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 20px; } .mb-6 { margin-bottom: 28px; }
.my-2 { margin-top: 8px; margin-bottom: 8px; } .my-4 { margin-top: 16px; margin-bottom: 16px; }
.text-center { text-align: center; }
.relative { position: relative; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ */
/* 4. App shell                                                        */
/* ------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: width var(--dur) var(--ease);
}
.app-shell.is-collapsed .sidebar { width: var(--sidebar-collapsed); }

.sidebar__brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--gradient-brand);
    display: grid; place-items: center;
    color: #fff; flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}
.brand-name { font-weight: 750; font-size: 1.02rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand-name span { color: var(--text-tertiary); font-weight: 500; }
.app-shell.is-collapsed .brand-name,
.app-shell.is-collapsed .sidebar__section-label,
.app-shell.is-collapsed .nav-link span,
.app-shell.is-collapsed .nav-link .nav-badge,
.app-shell.is-collapsed .sidebar__footer-text { display: none; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.sidebar__section-label { padding: 16px 12px 8px; font-size: 0.68rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.sidebar__section-label:first-child { padding-top: 4px; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 550; font-size: 0.9rem;
    position: relative;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
    margin-bottom: 2px;
    white-space: nowrap;
}
.nav-link svg { width: 19px; height: 19px; stroke-width: 2; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.is-active { background: var(--bg-active); color: var(--color-primary); font-weight: 650; }
:root[data-theme="dark"] .nav-link.is-active { color: #A5B4FC; }
.nav-link.is-active::before {
    content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--color-primary);
}
.nav-badge {
    margin-left: auto; font-size: 0.68rem; font-weight: 700;
    background: var(--color-primary-soft); color: var(--color-primary);
    padding: 2px 8px; border-radius: var(--radius-full);
}

.app-shell.is-collapsed .nav-link { justify-content: center; padding: 11px; }
.app-shell.is-collapsed .nav-link.is-active::before { display: none; }

.sidebar__footer { padding: 12px; border-top: 1px solid var(--border-color); flex-shrink: 0; }
.upgrade-card {
    background: var(--gradient-brand-soft);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
}
.sidebar__footer-text { font-size: 0.8rem; }
.app-shell.is-collapsed .upgrade-card { display: none; }

/* Main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
    height: var(--topbar-height);
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border-color);
}
.icon-btn {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    display: grid; place-items: center;
    color: var(--text-secondary);
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
    position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-danger); border: 2px solid var(--bg-surface); }

.topbar-search {
    display: flex; align-items: center; gap: 10px;
    width: min(420px, 42vw);
    height: 42px; padding: 0 14px;
    background: var(--bg-surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    transition: border var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.topbar-search:hover { border-color: var(--border-color); }
.topbar-search svg { width: 18px; height: 18px; }
.topbar-search .kbd { margin-left: auto; }
.topbar-search span { font-size: 0.9rem; }

.kbd {
    font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
    padding: 2px 7px; border-radius: 6px;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-tertiary); box-shadow: var(--shadow-xs);
}

/* RapidAPI Topbar Widget */
.rapidapi-topbar-widget {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.rapidapi-quota-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 13px;
    border-radius: 9999px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 650;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.rapidapi-quota-pill:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.rapidapi-quota-pill .api-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.rapidapi-quota-pill .api-status-label {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.rapidapi-switch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 13px;
    border-radius: 9999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
    user-select: none;
    white-space: nowrap;
}
.rapidapi-switch-btn svg {
    width: 12px;
    height: 12px;
    margin-right: 6px;
    transition: transform var(--dur-fast) var(--ease);
}
.rapidapi-switch-btn:hover svg {
    transform: rotate(180deg);
}
.rapidapi-switch-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}
.rapidapi-switch-btn:active {
    transform: scale(0.97);
}
.rapidapi-switch-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Content area */
.content { flex: 1; padding: 28px 24px 48px; }
.content-inner { max-width: var(--content-max); margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ */
/* 5. Components                                                       */
/* ------------------------------------------------------------------ */

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card--pad { padding: 22px; }
.card--hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--border-strong); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border-color); }
.card__title { font-weight: 650; font-size: 1rem; }
.card__body { padding: 22px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
    transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
    animation: rise var(--dur-slow) var(--ease) both;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.stat-card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stat-icon {
    width: 46px; height: 46px; border-radius: var(--radius-md);
    display: grid; place-items: center; color: #fff;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon--primary { background: linear-gradient(135deg, #4F46E5, #6366F1); }
.stat-icon--violet  { background: linear-gradient(135deg, #7C3AED, #A855F7); }
.stat-icon--success { background: linear-gradient(135deg, #16A34A, #22C55E); }
.stat-icon--warning { background: linear-gradient(135deg, #D97706, #F59E0B); }
.stat-icon--info    { background: linear-gradient(135deg, #0284C7, #0EA5E9); }
.stat-icon--danger  { background: linear-gradient(135deg, #DC2626, #EF4444); }
.stat-card__value { font-size: 2rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1; }
.stat-card__label { color: var(--text-secondary); font-size: 0.88rem; margin-top: 8px; }
.stat-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 650; padding: 3px 8px; border-radius: var(--radius-full); }
.stat-trend svg { width: 14px; height: 14px; }
.stat-trend--up { color: var(--color-success); background: var(--color-success-soft); }
.stat-trend--down { color: var(--color-danger); background: var(--color-danger-soft); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px;
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 0.9rem;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
    white-space: nowrap; user-select: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { box-shadow: var(--shadow-glow); }
.btn--secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-color); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3); }
.btn--sm { height: 34px; padding: 0 13px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn--lg { height: 48px; padding: 0 24px; font-size: 0.95rem; }
.btn--icon { width: 42px; padding: 0; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.8rem; font-weight: 600;
    padding: 4px 12px; border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
    max-width: fit-content;
    box-sizing: border-box;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge:has(svg)::before { display: none; }
.badge svg, .badge .icon {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    flex-shrink: 0;
    vertical-align: middle;
    display: inline-block;
}
.badge--success { color: var(--color-success); background: var(--color-success-soft); }
.badge--warning { color: var(--color-warning); background: var(--color-warning-soft); }
.badge--danger  { color: var(--color-danger);  background: var(--color-danger-soft); }
.badge--info    { color: var(--color-info);    background: var(--color-info-soft); }
.badge--neutral { color: var(--text-secondary); background: var(--bg-surface-2); }
.badge--primary { color: var(--color-primary); background: var(--color-primary-soft); }

.page-head, .page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; color: var(--text-primary); }
.page-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }
.page-header__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-header__actions .badge { height: 34px; padding: 0 14px; font-size: 0.82rem; }
#reels-api-status-badge {
    height: 34px !important;
    padding: 0 14px !important;
    font-size: 0.82rem !important;
    display: inline-flex !important;
    align-items: center !important;
    max-width: fit-content !important;
    white-space: nowrap !important;
    border-radius: 9999px !important;
    box-sizing: border-box !important;
}
#reels-api-status-badge::before {
    display: none !important;
}
#reels-api-status-badge svg {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    max-width: 14px !important;
    margin-right: 5px !important;
    flex-shrink: 0 !important;
}

/* Avatar */
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--bg-surface-2); display: grid; place-items: center; font-weight: 650; color: var(--text-secondary); font-size: 0.85rem; flex-shrink: 0; }
.avatar--sm { width: 30px; height: 30px; font-size: 0.75rem; }
.avatar--gradient { background: var(--gradient-brand); color: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-color); background: var(--bg-surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-surface-2);
    text-align: left; font-weight: 650; font-size: 0.76rem;
    letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-tertiary);
    padding: 13px 18px; white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}
.table tbody td { padding: 14px 18px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.input, .select, .textarea {
    height: 44px; padding: 0 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary); font-size: 0.92rem;
    transition: border var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
    width: 100%;
}
.textarea { height: auto; padding: 12px 14px; min-height: 100px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.input-group { position: relative; }
.input-group > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-tertiary); }
.input-group .input { padding-left: 42px; }

/* Dropdown menu */
.menu {
    position: absolute; min-width: 220px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 60;
    opacity: 0; visibility: hidden; transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), visibility var(--dur-fast);
}
.menu.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.menu__item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 550; color: var(--text-secondary); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); width: 100%; }
.menu__item svg { width: 17px; height: 17px; }
.menu__item:hover { background: var(--bg-hover); color: var(--text-primary); }
.menu__item--danger { color: var(--color-danger); }
.menu__item--danger:hover { background: var(--color-danger-soft); }
.menu__divider { height: 1px; background: var(--border-color); margin: 6px 4px; }
.menu__header { padding: 10px 11px; }

/* Segmented / chips */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-full); background: var(--bg-surface-2); border: 1px solid var(--border-color); font-size: 0.82rem; font-weight: 550; color: var(--text-secondary); transition: all var(--dur-fast) var(--ease); }
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip.is-active { background: var(--color-primary-soft); border-color: transparent; color: var(--color-primary); }

/* Progress */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--bg-surface-2); overflow: hidden; }
.progress__bar { height: 100%; border-radius: inherit; background: var(--gradient-brand); transition: width var(--dur-slow) var(--ease); }

/* Divider */
.divider { height: 1px; background: var(--border-color); border: none; margin: 20px 0; }

/* ------------------------------------------------------------------ */
/* 6. Feedback: skeletons, empty states, toasts                        */
/* ------------------------------------------------------------------ */
.skeleton { position: relative; overflow: hidden; background: var(--bg-surface-2); border-radius: var(--radius-sm); }
.skeleton::after {
    content: ""; position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg-surface) 60%, transparent), transparent);
    animation: shimmer 1.5s infinite;
}
.skeleton--text { height: 12px; margin: 6px 0; }
.skeleton--title { height: 20px; width: 40%; }
.skeleton--circle { border-radius: 50%; }

.empty-state { text-align: center; padding: 56px 24px; }
.empty-state__icon {
    width: 72px; height: 72px; border-radius: var(--radius-xl);
    background: var(--gradient-brand-soft);
    display: grid; place-items: center; margin: 0 auto 20px;
    color: var(--color-primary);
}
.empty-state__icon svg { width: 32px; height: 32px; }
.empty-state h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); max-width: 420px; margin: 0 auto 20px; }

/* Toasts */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 12px; max-width: 380px; }
.toast {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    animation: toast-in var(--dur) var(--ease) both;
}
.toast--success { border-left-color: var(--color-success); }
.toast--warning { border-left-color: var(--color-warning); }
.toast--error   { border-left-color: var(--color-danger); }
.toast__icon svg { width: 20px; height: 20px; }
.toast--success .toast__icon { color: var(--color-success); }
.toast--warning .toast__icon { color: var(--color-warning); }
.toast--error .toast__icon { color: var(--color-danger); }
.toast__title { font-weight: 650; font-size: 0.9rem; }
.toast__msg { color: var(--text-secondary); font-size: 0.85rem; margin-top: 2px; }

/* ------------------------------------------------------------------ */
/* 7. Command palette & modal overlay                                  */
/* ------------------------------------------------------------------ */
.overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 12vh;
    opacity: 0; visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.overlay.is-open { opacity: 1; visibility: visible; }

.cmdk {
    width: min(620px, 92vw);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: translateY(-12px) scale(0.98);
    transition: transform var(--dur) var(--ease);
}
.overlay.is-open .cmdk { transform: translateY(0) scale(1); }
.cmdk__input-row { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.cmdk__input-row svg { width: 20px; height: 20px; color: var(--text-tertiary); }
.cmdk__input { flex: 1; border: none; outline: none; background: transparent; font-size: 1.02rem; }
.cmdk__list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmdk__group-label { padding: 10px 12px 6px; font-size: 0.7rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); }
.cmdk__item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-md); font-size: 0.92rem; font-weight: 550; color: var(--text-secondary); cursor: pointer; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.cmdk__item svg { width: 18px; height: 18px; }
.cmdk__item:hover, .cmdk__item.is-highlighted { background: var(--bg-hover); color: var(--text-primary); }
.cmdk__item .kbd { margin-left: auto; }

.modal { width: min(520px, 92vw); background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); transform: translateY(-12px) scale(0.98); transition: transform var(--dur) var(--ease); }
.overlay.is-open .modal { transform: translateY(0) scale(1); }
.modal__header { padding: 20px 22px; border-bottom: 1px solid var(--border-color); }
.modal__body { padding: 22px; }
.modal__footer { padding: 16px 22px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* Mobile nav backdrop */
.nav-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility var(--dur); }
.nav-backdrop.is-open { opacity: 1; visibility: visible; }

/* ------------------------------------------------------------------ */
/* 7b. Auth screens                                                    */
/* ------------------------------------------------------------------ */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth__aside {
    position: relative; overflow: hidden;
    background: linear-gradient(150deg, #4338CA 0%, #4F46E5 42%, #7C3AED 100%);
    color: #fff; padding: 56px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth__aside::before {
    content: ""; position: absolute; inset: 0;
    background:
        radial-gradient(900px 500px at 85% -10%, rgba(255,255,255,0.18), transparent 60%),
        radial-gradient(700px 400px at -10% 110%, rgba(255,255,255,0.14), transparent 55%);
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__brand { display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 1.1rem; }
.auth__brand .brand-mark { box-shadow: none; background: rgba(255,255,255,0.16); backdrop-filter: blur(4px); }
.auth__headline { font-size: 2.6rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; max-width: 15ch; }
.auth__sub { color: rgba(255,255,255,0.82); font-size: 1.02rem; margin-top: 16px; max-width: 42ch; }
.auth__features { display: flex; flex-direction: column; gap: 14px; margin-top: 32px; }
.auth__feature { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.92); font-weight: 500; }
.auth__feature-icon { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.16); display: grid; place-items: center; flex-shrink: 0; }
.auth__feature-icon svg { width: 18px; height: 18px; }
.auth__footnote { color: rgba(255,255,255,0.7); font-size: 0.85rem; }

.auth__main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; position: relative; }
.auth__theme { position: absolute; top: 20px; right: 24px; }
.auth__card { width: 100%; max-width: 400px; animation: rise var(--dur-slow) var(--ease) both; }
.auth__logo { transition: background-color var(--dur-fast) var(--ease); }
:root[data-theme="dark"] .auth__logo { background-color: #FFFFFF; border-radius: 12px; padding: 10px; }
.auth__title { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; }
.auth__desc { color: var(--text-secondary); margin-top: 6px; margin-bottom: 28px; }
.auth__form { display: flex; flex-direction: column; gap: 18px; }
.auth__row { display: flex; align-items: center; justify-content: space-between; }
.auth__meta { text-align: center; margin-top: 22px; color: var(--text-secondary); font-size: 0.9rem; }
.auth__link { color: var(--color-primary); font-weight: 600; }
.auth__link:hover { text-decoration: underline; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--text-secondary); cursor: pointer; user-select: none; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--color-primary); cursor: pointer; }

.password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); padding: 4px; border-radius: 6px; }
.password-toggle:hover { color: var(--text-secondary); }

/* Alerts (inline) */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); font-size: 0.88rem; font-weight: 500; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert--success { color: #15803D; background: var(--color-success-soft); border-color: rgba(34,197,94,0.25); }
.alert--error   { color: #B91C1C; background: var(--color-danger-soft); border-color: rgba(239,68,68,0.25); }
.alert--warning { color: #B45309; background: var(--color-warning-soft); border-color: rgba(245,158,11,0.25); }
.alert--info    { color: #0369A1; background: var(--color-info-soft); border-color: rgba(14,165,233,0.25); word-break: break-all; }
:root[data-theme="dark"] .alert--success { color: #86EFAC; }
:root[data-theme="dark"] .alert--error { color: #FCA5A5; }
:root[data-theme="dark"] .alert--warning { color: #FCD34D; }
:root[data-theme="dark"] .alert--info { color: #7DD3FC; }

@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .auth__aside { display: none; }
    /* Align near the top on small screens instead of dead-centering in the
       full viewport height, which reads as excessive empty space. */
    .auth__main { align-items: flex-start; padding-top: 88px; min-height: 100vh; }
}

@media (max-width: 420px) {
    .auth__main { padding-top: 64px; padding-left: 20px; padding-right: 20px; }
}

/* ------------------------------------------------------------------ */
/* 7c. Import engine                                                   */
/* ------------------------------------------------------------------ */
.dropzone {
    display: block;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    padding: 48px 24px;
    text-align: center;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
    cursor: pointer;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.dropzone__icon {
    width: 68px; height: 68px; border-radius: var(--radius-xl);
    background: var(--gradient-brand-soft); color: var(--color-primary);
    display: grid; place-items: center; margin: 0 auto 18px;
}
.dropzone__icon svg { width: 30px; height: 30px; }
.dropzone h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.dropzone p { color: var(--text-secondary); font-size: 0.9rem; }
.dropzone__file { margin-top: 16px; display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: var(--radius-md); background: var(--bg-surface-2); font-size: 0.88rem; font-weight: 550; }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.step { display: flex; align-items: center; gap: 10px; color: var(--text-tertiary); font-weight: 600; font-size: 0.88rem; }
.step__num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-surface-2); font-size: 0.8rem; border: 1px solid var(--border-color); }
.step.is-active { color: var(--color-primary); }
.step.is-active .step__num { background: var(--color-primary); color: #fff; border-color: transparent; }
.step.is-done .step__num { background: var(--color-success); color: #fff; border-color: transparent; }
.step__line { flex: 1; height: 2px; background: var(--border-color); min-width: 20px; }

/* Mapping grid */
.map-row { display: grid; grid-template-columns: 220px 1fr 1.2fr; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border-color); }
.map-row:last-child { border-bottom: none; }
.map-field { display: flex; flex-direction: column; gap: 3px; }
.map-field__label { font-weight: 650; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.map-field__note { font-size: 0.76rem; color: var(--text-tertiary); }
.map-required { color: var(--color-danger); font-weight: 700; }
.map-samples { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--text-tertiary); min-width: 0; }
.map-samples code { background: var(--bg-surface-2); padding: 2px 7px; border-radius: 6px; font-size: 0.75rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; max-width: 100%; }
.map-auto { font-size: 0.72rem; font-weight: 650; color: var(--color-success); display: inline-flex; align-items: center; gap: 4px; }

/* Summary tiles */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.summary-tile { padding: 16px; border-radius: var(--radius-md); background: var(--bg-surface-2); text-align: center; }
.summary-tile__value { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; }
.summary-tile__label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.summary-tile--success .summary-tile__value { color: var(--color-success); }
.summary-tile--info .summary-tile__value { color: var(--color-info); }
.summary-tile--warning .summary-tile__value { color: var(--color-warning); }
.summary-tile--danger .summary-tile__value { color: var(--color-danger); }

@media (max-width: 720px) {
    .map-row { grid-template-columns: 1fr; gap: 8px; }
    .map-samples { flex-direction: row; flex-wrap: wrap; }
}

/* ------------------------------------------------------------------ */
/* 7d. Search & data tables                                            */
/* ------------------------------------------------------------------ */
.search-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-input-wrap { position: relative; flex: 1; min-width: 240px; }
.search-input-wrap > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-tertiary); }
.search-input-wrap .input { padding-left: 42px; height: 46px; }
.search-input-wrap .search-spinner { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: none; }
.search-input-wrap.is-loading .search-spinner { display: block; }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-bar .select { height: 38px; width: auto; min-width: 130px; padding: 0 32px 0 12px; font-size: 0.85rem; font-weight: 550; }

/* Sortable table headers */
.table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table th.sortable:hover { color: var(--text-secondary); }
.table th .sort-ind { display: inline-flex; margin-left: 4px; opacity: 0.4; vertical-align: middle; }
.table th.is-sorted .sort-ind { opacity: 1; color: var(--color-primary); }
.table td .avatar { flex-shrink: 0; }
.data-table tbody tr { cursor: default; }
.data-table tbody tr.is-selected { background: var(--color-primary-soft); }
.data-table tbody tr.is-selected:hover { background: var(--color-primary-soft); }

/* Selection bar */
.selection-bar {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 18px; border-radius: var(--radius-md);
    background: var(--gradient-brand); color: #fff;
    box-shadow: var(--shadow-glow);
    margin-bottom: 16px;
    animation: rise var(--dur) var(--ease) both;
}
.selection-bar strong { font-weight: 700; }
.selection-bar .btn--secondary { background: rgba(255,255,255,0.16); border-color: transparent; color: #fff; }
.selection-bar .btn--secondary:hover { background: rgba(255,255,255,0.26); }
.selection-bar .btn--ghost { color: rgba(255,255,255,0.85); }
.selection-bar .btn--ghost:hover { background: rgba(255,255,255,0.16); color: #fff; }
.selection-link { color: #fff; text-decoration: underline; font-weight: 600; font-size: 0.85rem; cursor: pointer; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 6px; }
.page-btn { min-width: 38px; height: 38px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); background: var(--bg-surface); font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); transition: all var(--dur-fast) var(--ease); }
.page-btn:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text-primary); }
.page-btn.is-active { background: var(--color-primary); border-color: transparent; color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { padding: 0 4px; color: var(--text-tertiary); }

/* Right-side drawer */
.drawer-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(15,23,42,0.45); backdrop-filter: blur(3px); opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility var(--dur); }
.drawer-backdrop.is-open { opacity: 1; visibility: visible; }
.drawer {
    position: fixed; top: 0; right: 0; z-index: 91;
    width: min(440px, 92vw); height: 100vh;
    background: var(--bg-surface); border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    transition: transform var(--dur) var(--ease);
    display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer__header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-color); }
.drawer__body { padding: 22px; overflow-y: auto; flex: 1; }

@media (max-width: 640px) {
    /* Let each select keep enough width to show its label instead of
       shrinking to an unreadable sliver; wrap onto new lines instead. */
    .filter-bar .select { flex: 1 1 150px; min-width: 150px; }
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar .btn { width: 100%; }
}

/* ------------------------------------------------------------------ */
/* 7e. Bulk operations                                                 */
/* ------------------------------------------------------------------ */
.op-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.op-card {
    text-align: left; padding: 18px; border-radius: var(--radius-lg);
    border: 1.5px solid var(--border-color); background: var(--bg-surface);
    transition: all var(--dur-fast) var(--ease); cursor: pointer; position: relative;
}
.op-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.op-card.is-selected { border-color: var(--color-primary); background: var(--color-primary-soft); }
.op-card.is-selected::after { content: ""; position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; border-radius: 50%; background: var(--color-primary); box-shadow: inset 0 0 0 3px var(--bg-surface); }
.op-card__icon { width: 44px; height: 44px; border-radius: var(--radius-md); display: grid; place-items: center; color: #fff; margin-bottom: 12px; }
.op-card__title { font-weight: 650; font-size: 0.95rem; }
.op-card__desc { color: var(--text-secondary); font-size: 0.8rem; margin-top: 3px; }

.bulk-progress-wrap { display: flex; align-items: center; gap: 16px; }
.progress--lg { height: 12px; flex: 1; }
.bulk-stat { text-align: center; min-width: 70px; }
.bulk-stat__value { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1; }
.bulk-stat__label { font-size: 0.72rem; color: var(--text-secondary); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.04em; }

.terminal {
    background: #0B1120; border: 1px solid #1E293B; border-radius: var(--radius-md);
    font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.7;
    padding: 14px 16px; max-height: 280px; overflow-y: auto; color: #94A3B8;
}
.terminal__line { white-space: nowrap; }
.terminal__line .ok { color: #4ADE80; }
.terminal__line .err { color: #F87171; }
.terminal__line .tgt { color: #E2E8F0; }
.terminal__line .arrow { color: #64748B; }

/* ------------------------------------------------------------------ */
/* 7f. Error Center                                                     */
/* ------------------------------------------------------------------ */
.error-console {
    background: #0B1120; border: 1px solid #1E293B; border-radius: var(--radius-lg);
    overflow: hidden;
}
.error-console__bar {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; border-bottom: 1px solid #1E293B;
    background: #0F172A;
}
.error-console__dot { width: 11px; height: 11px; border-radius: 50%; }
.error-console__title { margin-left: 8px; font-family: var(--font-mono); font-size: 0.78rem; color: #64748B; }
.error-console__body { max-height: 560px; overflow-y: auto; padding: 6px; }

.log-row { border-radius: var(--radius-sm); transition: background var(--dur-fast) var(--ease); cursor: pointer; }
.log-row:hover { background: rgba(148, 163, 184, 0.08); }
.log-row.is-active { background: rgba(99, 102, 241, 0.14); }
.log-row__main { display: flex; align-items: center; gap: 10px; padding: 9px 10px; font-family: var(--font-mono); font-size: 0.82rem; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px currentColor; }
.log-module { flex-shrink: 0; background: rgba(148,163,184,0.14) !important; color: #CBD5E1 !important; }
.log-message { flex: 1; min-width: 0; color: #E2E8F0; }
.log-time { flex-shrink: 0; font-size: 0.74rem; white-space: nowrap; color: #64748B !important; }
.log-delete { width: 28px; height: 28px; color: #475569; flex-shrink: 0; }
.log-delete:hover { color: #F87171; background: rgba(248,113,113,0.12); }

.severity-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.severity-tile { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--border-color); background: var(--bg-surface); }
.severity-tile__icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0; }
.severity-tile__value { font-size: 1.4rem; font-weight: 750; line-height: 1; }
.severity-tile__label { font-size: 0.76rem; color: var(--text-secondary); margin-top: 3px; }

/* ------------------------------------------------------------------ */
/* 7g. Activity timeline & settings                                    */
/* ------------------------------------------------------------------ */
.activity-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border-color); transition: background var(--dur-fast) var(--ease); }
.activity-row:last-child { border-bottom: none; }
.activity-row:hover { background: var(--bg-hover); }
.activity-row__icon { width: 38px; height: 38px; border-radius: var(--radius-md); background: var(--color-primary-soft); color: var(--color-primary); display: grid; place-items: center; flex-shrink: 0; }
.activity-row__icon svg { width: 18px; height: 18px; }
.activity-row__body { flex: 1; min-width: 0; }
.activity-row__desc { font-weight: 600; font-size: 0.9rem; line-height: 1.4; }
.activity-row__meta { display: flex; align-items: center; gap: 10px; margin-top: 5px; font-size: 0.78rem; color: var(--text-tertiary); flex-wrap: wrap; }
.activity-row__time { flex-shrink: 0; font-size: 0.78rem; white-space: nowrap; padding-top: 2px; }

/* Settings */
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); font-weight: 550; font-size: 0.88rem; color: var(--text-secondary); }
.settings-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.settings-nav a.is-active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 650; }
.settings-section { scroll-margin-top: 90px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--border-color); }
.settings-row:last-child { border-bottom: none; }
.settings-row__label { font-weight: 600; font-size: 0.9rem; }
.settings-row__desc { color: var(--text-secondary); font-size: 0.8rem; margin-top: 3px; max-width: 44ch; }
.settings-row__control { flex-shrink: 0; width: 220px; }
.settings-row__control .input, .settings-row__control .select { width: 100%; }

@media (max-width: 560px) {
    .settings-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .settings-row__control { width: 100%; }
}

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background var(--dur-fast) var(--ease); cursor: pointer; }
.switch__track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--dur-fast) var(--ease); box-shadow: var(--shadow-xs); }
.switch input:checked + .switch__track { background: var(--color-primary); }
.switch input:checked + .switch__track::before { transform: translateX(18px); }

/* ------------------------------------------------------------------ */
/* 8. Animations                                                       */
/* ------------------------------------------------------------------ */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--color-primary-soft); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 0.7s linear infinite; }

.animate-rise { animation: rise var(--dur-slow) var(--ease) both; }
.stagger > * { animation: rise var(--dur-slow) var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0.04s; }
.stagger > *:nth-child(2) { animation-delay: 0.09s; }
.stagger > *:nth-child(3) { animation-delay: 0.14s; }
.stagger > *:nth-child(4) { animation-delay: 0.19s; }
.stagger > *:nth-child(5) { animation-delay: 0.24s; }
.stagger > *:nth-child(6) { animation-delay: 0.29s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------------ */
/* 9. Responsive                                                       */
/* ------------------------------------------------------------------ */
.menu-toggle { display: none; }

@media (max-width: 1024px) {
    .topbar-search { width: 220px; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed; left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform var(--dur) var(--ease);
        box-shadow: var(--shadow-xl);
    }
    .app-shell.nav-open .sidebar { transform: translateX(0); }
    .app-shell.is-collapsed .sidebar { width: var(--sidebar-width); }
    .app-shell.is-collapsed .brand-name, .app-shell.is-collapsed .nav-link span, .app-shell.is-collapsed .sidebar__section-label { display: block; }
    .menu-toggle { display: grid; }
    .topbar-search span, .topbar-search .kbd { display: none; }
    .topbar-search { width: 42px; justify-content: center; padding: 0; }
    .content { padding: 20px 16px 40px; }
    /* The desktop collapse toggle is meaningless once the sidebar is
       already an off-canvas drawer opened via the hamburger. */
    [data-action="collapse-sidebar"] { display: none; }
}

@media (max-width: 560px) {
    .page-head { flex-direction: column; align-items: stretch; }
    .stat-card__value { font-size: 1.6rem; }
    .topbar { padding: 0 14px; gap: 10px; }
    .hide-mobile { display: none !important; }
    .rapidapi-topbar-widget { gap: 6px; }
    .rapidapi-quota-pill, .rapidapi-switch-btn { height: 28px; padding: 0 9px; font-size: 0.72rem; }
}

/* Multi-select Dropdown */
.multi-select-dropdown { position: relative; display: inline-block; min-width: 180px; }
.multi-select-trigger { width: 100%; text-align: left; cursor: pointer; user-select: none; }
.multi-select-menu {
    position: absolute; top: calc(100% + 6px); left: 0; min-width: 240px; max-width: 320px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); z-index: 100; padding: 8px;
    display: flex; flex-direction: column; gap: 6px;
}
.multi-select-search { padding-bottom: 4px; border-bottom: 1px solid var(--border-color); }
.multi-select-options { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.multi-select-option {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.85rem; transition: background 0.15s ease; user-select: none;
}
.multi-select-option:hover { background: var(--bg-hover); }
.multi-select-option input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--color-primary); cursor: pointer; }

