@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* LifeMatch - Design System (LifeTrial CRM Pattern)
   Brand: Navy #1A5276 | Teal #17A589
   Reference: LifeTrial TopBar.tsx + LifeScan pattern
   Supports: Light + Dark themes */

/* ===== 1. CSS VARIABLES (Light Theme) ===== */
:root {
    --brand-navy: #1A5276;
    --brand-navy-dark: #0E2F44;
    --brand-navy-light: #2471A3;
    --brand-teal: #17A589;
    --brand-teal-bright: #1ABC9C;
    --brand-teal-dark: #128C73;
    --brand-qualifier: #95A5A6;
    --primary: #1A5276;
    --accent: #17A589;
    --hover: rgba(26, 82, 118, 0.08);
    --selected: rgba(26, 82, 118, 0.16);
    --accent-hover: rgba(23, 165, 137, 0.08);
    --accent-selected: rgba(23, 165, 137, 0.16);
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #2563eb;
    --info-light: #dbeafe;
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #f9fafb;
    --bg-hover: #f3f4f6;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-inverted: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --code-bg: #f3f4f6;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --topbar-h: 56px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

/* ===== 1b. CSS VARIABLES (Dark Theme) ===== */
html[data-theme="dark"] {
    --primary: #17A589;
    --accent: #1ABC9C;
    --hover: rgba(23, 165, 137, 0.08);
    --selected: rgba(23, 165, 137, 0.16);
    --accent-hover: rgba(26, 188, 156, 0.08);
    --accent-selected: rgba(26, 188, 156, 0.16);
    --success: #3fb950;
    --success-light: #1a3a2a;
    --warning: #d29922;
    --warning-light: #3d2e00;
    --danger: #f85149;
    --danger-light: #3d1416;
    --info: #58a6ff;
    --info-light: #0d2240;
    --bg-body: #09090B;
    --bg-surface: #0F0F11;
    --bg-elevated: #18181B;
    --bg-hover: #18181B;
    --border: #27272A;
    --border-light: #18181B;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #71717a;
    --text-inverted: #0d1117;
    --gray-50: #0F0F11;
    --gray-100: #18181B;
    --gray-200: #27272A;
    --gray-300: #3F3F46;
    --gray-400: #71717A;
    --gray-500: #A1A1AA;
    --gray-600: #D4D4D8;
    --gray-700: #E4E4E7;
    --gray-800: #F4F4F5;
    --gray-900: #FAFAFA;
    --code-bg: #18181B;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

/* ===== 2. BASE (Reset, Body, Typography) ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -100%;
    left: 8px;
    z-index: 9999;
    padding: 8px 16px;
    background: var(--primary);
    color: var(--text-inverted);
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: top 0.15s;
}
.skip-link:focus { top: 0; outline: 2px solid var(--accent); outline-offset: 2px; }

h1 { font-size: 26px; font-weight: 700; color: var(--gray-900); }
h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
h3 { font-size: 18px; font-weight: 600; color: var(--gray-800); }
h4 { font-size: 15px; font-weight: 600; color: var(--gray-800); }

code {
    background: var(--code-bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== 3. TOPBAR (56px fixed, LifeTrial CRM pattern) ===== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background 0.2s, border-color 0.2s;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 0;
    flex: 1;
}

.topbar-brand {
    display: flex;
    align-items: baseline;
    text-decoration: none;
    flex-shrink: 0;
    gap: 0;
}

.topbar-brand:hover { text-decoration: none; }

.brand-life {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--brand-navy);
}

.brand-match {
    font-size: 18px;
    font-weight: 300;
    letter-spacing: -0.3px;
    color: var(--brand-teal);
}

.topbar-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    mix-blend-mode: multiply;
}

html[data-theme="dark"] .topbar-logo {
    mix-blend-mode: screen;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== 4. TOPBAR NAV (horizontal links, active, scrollable) ===== */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: visible;
    flex-wrap: nowrap;
}

.topbar-nav a {
    padding: 6px 12px;
    color: var(--gray-500);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}

.topbar-nav a:hover {
    color: var(--gray-800);
    background: var(--hover);
}

.topbar-nav a.active {
    color: var(--brand-teal);
    background: var(--accent-selected);
    font-weight: 600;
}

/* ===== Topbar Nav Dropdowns ===== */
.topbar-nav .nav-dropdown { position: relative; display: inline-block; }
.topbar-nav .nav-dropdown-trigger {
    background: none;
    border: none;
    color: var(--gray-500);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.topbar-nav .nav-dropdown-trigger:hover {
    color: var(--gray-800);
    background: var(--hover);
}
.topbar-nav .nav-dropdown-trigger.active {
    color: var(--brand-teal);
    background: var(--accent-selected);
    font-weight: 600;
}
.topbar-nav .nav-dropdown-trigger .arrow-down {
    font-size: 10px;
    opacity: 0.6;
}
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 200px;
    padding: 4px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.nav-dropdown-menu a:hover {
    background: var(--bg-hover);
    color: var(--brand-teal);
}
.nav-dropdown-menu a.active {
    background: var(--accent-selected);
    color: var(--brand-teal);
    font-weight: 600;
}

/* Mobile nav sections (drawer) */
.mobile-nav-section {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}
.mobile-nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 4px 12px 6px;
}

/* ===== 5. DROPDOWNS (Language with flags, User with avatar) ===== */
.dropdown { position: relative; }

.dropdown-trigger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.dropdown-trigger:hover { background: var(--hover); }

/* Language trigger */
.lang-trigger { padding: 4px 6px; }

.flag-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: block;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    object-fit: cover;
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s;
    color: var(--text-secondary);
}

.theme-toggle:hover { background: var(--hover); }

/* User trigger */
.user-trigger { padding: 4px 8px; gap: 4px; }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.arrow-down {
    font-size: 16px;
    color: var(--gray-400);
    line-height: 1;
}

/* Dropdown menu (shared) */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    overflow: hidden;
}

/* Language dropdown */
.dropdown-lang {
    min-width: 180px;
    padding: 4px 0;
}

.dropdown-lang-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
    transition: background 0.15s;
}

.dropdown-lang-item:hover { background: var(--hover); }
.dropdown-lang-item.active { background: var(--accent-selected); }
.dropdown-lang-item .flag-icon { width: 22px; height: 22px; }

.dropdown-lang-item .lang-check {
    margin-left: auto;
    color: var(--brand-teal);
    font-size: 14px;
    font-weight: 600;
    visibility: hidden;
}

.dropdown-lang-item.active .lang-check { visibility: visible; }

/* User dropdown */
.dropdown-user { min-width: 220px; }
.dropdown-user-header { padding: 14px 16px; }

.dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dropdown-user-info strong { font-size: 14px; color: var(--gray-800); }

.user-role-badge {
    display: inline-block;
    font-size: 10px;
    letter-spacing: 0.5px;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 600;
    width: fit-content;
}

.role-admin { background: var(--danger-light); color: var(--danger); }
.role-super_admin { background: var(--success-light); color: var(--success); }
.role-viewer { background: var(--gray-100); color: var(--gray-500); }
.role-editor { background: var(--warning-light); color: var(--warning); }

.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover { background: var(--hover); color: var(--gray-800); }
.dropdown-item .item-icon { font-size: 16px; color: var(--gray-400); width: 20px; text-align: center; }

/* ===== 6. MOBILE DRAWER (overlay + slide panel 280px) ===== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    font-size: 22px;
    line-height: 1;
}

.mobile-menu-btn:hover { background: var(--hover); }

.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.mobile-drawer-overlay.open { opacity: 1; visibility: visible; }

.mobile-drawer {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    background: var(--bg-surface);
    z-index: 401;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-drawer-overlay.open .mobile-drawer { transform: translateX(0); }

.mobile-drawer-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.mobile-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--gray-500);
    padding: 4px;
}

.mobile-user-info {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-user-info .user-avatar { width: 42px; height: 42px; font-size: 16px; }

.mobile-user-details { display: flex; flex-direction: column; gap: 4px; }
.mobile-user-details strong { font-size: 14px; color: var(--gray-800); }

.mobile-lang-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.mobile-lang-btn {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-600);
    transition: all 0.15s;
}

.mobile-lang-btn.active { border-color: var(--brand-teal); background: var(--accent-selected); }
.mobile-lang-btn .flag-icon { width: 20px; height: 20px; }

.mobile-nav { flex: 1; padding: 8px 0; }

.mobile-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}

.mobile-nav a:hover { background: var(--hover); }

.mobile-nav a.active {
    color: var(--brand-teal);
    font-weight: 600;
    background: var(--accent-selected);
    border-left: 3px solid var(--brand-teal);
}

.mobile-nav-footer {
    border-top: 1px solid var(--gray-200);
    padding: 8px 0;
}

.mobile-nav-footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.mobile-nav-footer a:hover { background: var(--hover); }

/* ===== 7. PAGE LAYOUT (main, max-width 1280px) ===== */
.main-content {
    margin-top: var(--topbar-h);
    padding: 24px 24px;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
}

.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 1.375rem; font-weight: 700; color: var(--gray-900); margin-bottom: 2px; letter-spacing: -0.02em; }
.page-header p { color: var(--gray-500); font-size: 13px; line-height: 1.5; }

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* ===== 8. STATS GRID (explicit breakpoints) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .stats-grid { grid-template-columns: 1fr; } }

/* ===== 9. STAT CARDS (LifeTrial minimalist pattern) ===== */
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: border-color 0.15s ease;
    min-width: 0;
    overflow: hidden;
}

.stat-card:hover { border-color: var(--gray-300); }

.stat-card .stat-info { flex: 1; min-width: 0; }

.stat-card .label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    line-height: 1.3;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-card .stat-value-md {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
}

.stat-card .stat-value-sm {
    font-size: 0.8125rem;
    color: var(--gray-600);
    line-height: 1.4;
}

.stat-card .stat-sub {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
    line-height: 1.3;
}

.stat-card .stat-icon {
    font-size: 16px;
    color: var(--gray-400);
    flex-shrink: 0;
    margin-left: 8px;
    line-height: 1;
}

.stat-card .stat-trend {
    font-size: 11px;
    font-weight: 500;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card .stat-trend.up { color: var(--success); }
.stat-card .stat-trend.down { color: var(--danger); }

/* ===== 10. PANELS (LifeTrial minimalist pattern — no shadows, tight) ===== */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.panel-body { padding: 16px; }
.panel-body-flush { padding: 0; }

/* ===== 11. TABLES (thead, tbody, hover, responsive) ===== */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.table-responsive::-webkit-scrollbar { height: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
    text-align: left;
    padding: 8px 16px;
    background: var(--gray-50);
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--gray-600);
    font-size: 13px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--gray-50); }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:hover { background: var(--hover); }

/* ===== 12. BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
    text-transform: none;
    box-shadow: none;
}

.btn:hover { text-decoration: none; }

.btn:disabled { color: var(--gray-500); background: var(--gray-200); cursor: not-allowed; }

.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--brand-teal); color: var(--text-inverted); }
.btn-primary:hover { background: var(--brand-teal-dark); }
.btn-primary:disabled { background: var(--gray-200); color: var(--gray-500); cursor: not-allowed; }

.btn-secondary { background: var(--brand-navy); color: var(--text-inverted); }
.btn-secondary:hover { background: var(--brand-navy-dark); }
.btn-secondary:disabled { background: var(--gray-200); color: var(--gray-500); cursor: not-allowed; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

.period-selector { display: flex; gap: 4px; align-items: center; }
.period-btn { opacity: 0.65; }
.period-btn.active { opacity: 1; background: var(--primary); border-color: var(--primary); color: #fff; }
.period-btn.active:hover { background: var(--primary-dark, var(--primary)); }

.btn-outline {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
}

.btn-outline:hover { background: var(--bg-hover); border-color: var(--gray-400); }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--gray-500);
    font-size: 13px;
    transition: all 0.15s;
}

.btn-icon:hover { background: var(--accent-hover); color: var(--brand-teal); }

.btn-danger { background: var(--danger); color: var(--text-inverted); }
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: var(--gray-200); color: var(--gray-500); cursor: not-allowed; }

.btn-ghost {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Loading state */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--brand-teal);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    top: 50%;
    left: 50%;
    margin-top: -7px;
    margin-left: -7px;
}

/* ===== 13. BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    text-transform: lowercase;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
/* Plan badges — badge-muted/badge-teal/badge-purple are generic aliases for the same plan colors */
.badge-muted,
.badge-plan-free { background: var(--gray-100); color: var(--gray-600); }
.badge-plan-starter { background: var(--info-light); color: var(--info); }
.badge-teal,
.badge-plan-pro { background: var(--accent-selected); color: var(--brand-teal); }
.badge-purple,
.badge-plan-enterprise { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }

html[data-theme="dark"] .badge-purple,
html[data-theme="dark"] .badge-plan-enterprise {
    background: rgba(124, 58, 237, 0.18);
    color: #a78bfa;
}

/* ===== 14. FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color 0.15s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--gray-400); }

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group input:disabled,
.form-group textarea:disabled,
.form-group select:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-group .form-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.form-group .form-error {
    font-size: 11px;
    color: var(--danger);
    margin-top: 4px;
}

.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
    border-color: var(--danger);
}

/* Form validation state classes */
.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid { border-color: var(--danger) !important; }

.form-control.is-valid,
input.is-valid { border-color: var(--success) !important; }

.invalid-feedback { color: var(--danger); font-size: 11px; margin-top: 4px; display: none; }

.is-invalid + .invalid-feedback { display: block; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* Filter bar */
.filter-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.filter-bar select,
.filter-bar input {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13px; background: var(--bg-surface); color: var(--text-secondary);
}

.filter-bar select:focus,
.filter-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== 15. MODALS ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 500;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg-surface); border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    margin: 16px;
    animation: fadeIn 0.2s ease;
}

.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: var(--bg-surface); border-radius: 12px 12px 0 0;
    z-index: 1;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    background: none; border: none; font-size: 20px; color: var(--gray-400);
    cursor: pointer; line-height: 1; padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 12px 20px; border-top: 1px solid var(--gray-200);
    display: flex; justify-content: flex-end; gap: 8px;
    position: sticky; bottom: 0; background: var(--bg-surface);
    border-radius: 0 0 12px 12px;
}

/* Modal detail sections */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item .detail-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-bottom: 2px;
}

.detail-item .detail-value {
    font-size: 14px;
    color: var(--gray-800);
}

.detail-section { margin-bottom: 16px; }

.detail-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.detail-content {
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.6;
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===== 16. TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 16px);
    right: 16px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 360px;
    width: calc(100vw - 32px);
}

.toast {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
    border: 1px solid transparent;
    overflow: hidden;
    pointer-events: all;
    animation: toastSlideIn 0.32s cubic-bezier(0.21, 1.04, 0.58, 1) both;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.toast-hiding {
    animation: toastSlideOut 0.32s ease forwards;
}

.toast-success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.toast-error   { background: var(--danger-light);  color: var(--danger);  border-color: var(--danger);  }
.toast-info    { background: var(--info-light);    color: var(--info);    border-color: var(--info);    }
.toast-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    opacity: 0.9;
}

.toast-msg {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    padding: 2px;
    border-radius: 4px;
    line-height: 1;
    transition: opacity 0.15s ease, background 0.15s ease;
    margin-left: 4px;
    align-self: flex-start;
}

.toast-close:hover { opacity: 1; background: rgba(0,0,0,.08); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    transform-origin: left center;
    transform: scaleX(1);
    border-radius: 0 0 var(--radius) var(--radius);
}

@keyframes toastSlideIn {
    from { transform: translateX(calc(100% + 16px)); opacity: 0; }
    to   { transform: translateX(0);                opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0);                opacity: 1; }
    to   { transform: translateX(calc(100% + 16px)); opacity: 0; }
}

/* ===== 17. LOGIN PAGE ===== */
.login-page {
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-teal-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
}

.login-header { text-align: center; margin-bottom: 32px; }

.login-header .brand-life { font-size: 26px; }
.login-header .brand-match { font-size: 26px; }

.login-subtitle {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.login-form .form-group { margin-bottom: 16px; }

.login-form .btn-primary {
    width: 100%;
    padding: 11px 16px;
    font-size: 15px;
    font-weight: 600;
    justify-content: center;
}

.login-error {
    background: var(--danger-light); color: var(--danger);
    padding: 10px 16px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 20px; border: 1px solid var(--danger);
}

.login-footer { text-align: center; font-size: 12px; color: var(--gray-400); margin-top: 24px; }

.login-logo { height: 36px; width: auto; }

.login-forgot { text-align: center; margin-top: 12px; }
.login-forgot a { color: var(--primary); font-size: 13px; }

.login-success {
    background: var(--success-light); color: var(--success);
    padding: 10px 16px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 20px; border: 1px solid var(--success);
}

.login-hint { color: var(--text-secondary); font-size: 14px; margin: 0 0 20px; }

.link-accent { color: var(--brand-teal); font-size: 14px; }

.login-lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 6px;
}

.login-lang-btn {
    padding: 4px 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.login-lang-btn:hover { background: rgba(255,255,255,0.25); }
.login-lang-btn.active { background: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.6); }
.login-lang-btn .flag-icon { width: 22px; height: 22px; }

/* ===== 18. TABS ===== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--gray-800);
    background: var(--hover);
}

.tab.active {
    color: var(--brand-teal);
    border-bottom-color: var(--brand-teal);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-500);
    margin-left: 6px;
}

.tab.active .tab-count {
    background: var(--accent-selected);
    color: var(--brand-teal);
}

/* ===== 19. SCORE BAR (colored bar for matching scores) ===== */
.score-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.score-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-100);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.score-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}

.score-bar-fill.score-alta { background: var(--success); }
.score-bar-fill.score-parcial { background: var(--warning); }
.score-bar-fill.score-insuficiente { background: var(--gray-400); }

.score-value {
    font-size: 13px;
    font-weight: 700;
    min-width: 42px;
    text-align: right;
    white-space: nowrap;
}

.score-value.score-alta { color: var(--success); }
.score-value.score-parcial { color: var(--warning); }
.score-value.score-insuficiente { color: var(--gray-400); }

/* Large score display */
.score-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.score-circle.score-alta { background: var(--success-light); color: var(--success); border: 2px solid var(--success); }
.score-circle.score-parcial { background: var(--warning-light); color: var(--warning); border: 2px solid var(--warning); }
.score-circle.score-insuficiente { background: var(--gray-100); color: var(--gray-400); border: 2px solid var(--gray-400); }

/* ===== 20. STUDY RESULT CARDS (border-left colored by confidence) ===== */
.result-category { margin-bottom: 20px; }

.result-category h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-800);
}

.study-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
    min-width: 0;
    overflow: hidden;
}

.study-card:hover { box-shadow: var(--shadow); }

.study-card.cat-alta { border-left: 4px solid var(--success); }
.study-card.cat-parcial { border-left: 4px solid var(--warning); }
.study-card.cat-insuficiente { border-left: 4px solid var(--danger); }
.study-card.cat-eligible { border-left: 4px solid var(--success); }
.study-card.cat-potentially { border-left: 4px solid var(--warning); }
.study-card.cat-not-eligible { border-left: 4px solid var(--danger); }
.study-card.cat-not-relevant { border-left: 4px solid var(--info); }

.study-card .title { font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--gray-800); }

.study-card .meta {
    display: flex; flex-wrap: wrap; gap: 16px;
    font-size: 12px; color: var(--gray-500); margin-bottom: 10px;
}

.study-card .meta strong { color: var(--gray-600); }

.study-card .justification {
    font-size: 13px; color: var(--gray-600); line-height: 1.6;
    padding: 12px; background: var(--gray-50); border-radius: var(--radius-sm); margin-top: 10px;
}

.study-card .criteria-list { margin-top: 10px; }
.study-card .criteria-list .criteria-title { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.study-card .criteria-list ul { list-style: none; padding: 0; margin: 0; }
.study-card .criteria-list li { padding: 3px 0; font-size: 13px; }

.study-card .confirmed-criteria li::before { content: '\2713 '; color: var(--success); font-weight: 700; }
.study-card .pending-criteria li::before { content: '? '; color: var(--warning); font-weight: 700; }
.study-card .excluded-criteria li::before { content: '\2717 '; color: var(--danger); font-weight: 700; }

.study-card .conditions-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.study-card .condition-tag {
    padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 500;
    background: var(--accent-selected); color: var(--brand-teal);
}

.study-card .nct-id {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--gray-400);
}

.study-card .locations-row {
    margin-top: 10px; font-size: 12px; color: var(--gray-500);
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}

.study-card .location-pill {
    padding: 2px 10px; border-radius: 999px; font-size: 11px;
    background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200);
}

.study-card .locations-more { font-size: 11px; color: var(--gray-400); font-style: italic; }

.criteria-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

.results-meta {
    display: flex; gap: 8px; margin-bottom: 12px;
}

.results-meta .meta-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
    background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border);
    flex: 1; justify-content: center;
}

/* ===== 21. PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination a,
.pagination button,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--gray-600);
    background: var(--bg-surface);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination a:hover,
.pagination button:hover {
    background: var(--bg-hover);
    border-color: var(--gray-400);
}

.pagination .active {
    background: var(--brand-teal);
    color: var(--text-inverted);
    border-color: var(--brand-teal);
    font-weight: 600;
}

.pagination .disabled {
    color: var(--gray-300);
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-info {
    font-size: 13px;
    color: var(--gray-500);
    text-align: center;
    margin-top: 8px;
}

/* ===== 22. EMPTY STATES ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.4;
}

.empty-state .empty-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state .empty-desc {
    font-size: 13px;
    color: var(--gray-500);
    max-width: 400px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.empty-state .btn {
    margin-top: 16px;
}

/* ===== 23. INFO BOXES ===== */
.info-box {
    background: var(--info-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.6;
}

.info-box strong { color: var(--gray-800); }
.info-box .info-title { font-size: 15px; font-weight: 600; color: var(--gray-800); margin-bottom: 8px; }

.info-box.info-box-success {
    background: var(--success-light);
    border-color: rgba(22, 163, 74, 0.2);
}
.alert-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.alert-item .badge { min-width: 72px; text-align: center; }

/* Alert cards (dashboard alerts panel) */
.alert-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    margin-bottom: 8px;
    font-size: 13px;
    background: var(--bg-surface);
    line-height: 1.4;
}
.alert-card:last-child { margin-bottom: 0; }
.alert-card.alert-critical {
    border-left-color: var(--danger);
    background: var(--danger-light);
    border-color: rgba(220, 38, 38, 0.15);
}
.alert-card.alert-warning {
    border-left-color: var(--warning);
    background: var(--warning-light);
    border-color: rgba(217, 119, 6, 0.15);
}
.alert-card.alert-ok {
    border-left-color: var(--success);
    background: var(--success-light);
    border-color: rgba(22, 163, 74, 0.15);
}
.alert-card-icon { font-size: 14px; flex-shrink: 0; line-height: 1; }
.alert-card-text { flex: 1; min-width: 0; color: var(--text-primary); }

.info-box.info-box-warning {
    background: var(--warning-light);
    border-color: rgba(217, 119, 6, 0.2);
}

.info-box.info-box-danger {
    background: var(--danger-light);
    border-color: rgba(220, 38, 38, 0.2);
}

.info-box.info-box-teal {
    background: rgba(23, 165, 137, 0.06);
    border-color: rgba(23, 165, 137, 0.2);
}

/* ===== 24. PROGRESS STEPS ===== */
.steps { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    font-size: 14px;
    color: var(--gray-500);
}

.step.active { background: rgba(23, 165, 137, 0.06); border-color: var(--brand-teal); color: var(--gray-800); }
.step.done { background: var(--success-light); border-color: var(--success); color: var(--success); }

.step .icon {
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; flex-shrink: 0;
}

.step .icon.pending { background: var(--gray-200); color: var(--gray-500); }
.step .icon.active { background: var(--brand-teal); color: #fff; }
.step .icon.done { background: var(--success); color: #fff; }

/* ===== 25. SPINNER ===== */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--brand-teal);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

.spinner-lg {
    width: 32px; height: 32px;
    border-width: 3px;
}

.loading-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--brand-teal);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

/* ===== 27. FILE LIST ===== */
.file-list { list-style: none; margin-top: 14px; }

.file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--gray-600);
}

.file-list .remove-file {
    color: var(--danger);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
}

/* ===== 28. EXPORT BAR ===== */
.export-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 0;
}

.export-bar .btn { font-size: 13px; }

/* ===== 30. SESSION CARDS ===== */
.session-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: box-shadow 0.2s;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
}

.session-card:hover { box-shadow: var(--shadow); }

.session-card .session-info { flex: 1; }
.session-card .session-key { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; color: var(--gray-400); }
.session-card .session-date { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.session-card .session-results { font-size: 13px; font-weight: 500; color: var(--gray-700); }

/* ===== 31. TENANT CARDS ===== */
.tenant-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
    overflow: hidden;
}

.tenant-card .tenant-name { font-size: 16px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.tenant-card .tenant-slug { font-size: 12px; color: var(--gray-400); font-family: 'SF Mono', 'Fira Code', monospace; }
.tenant-card .tenant-stats { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--gray-500); }

/* ===== 32. ASSESSMENT BOXES ===== */
.assessment-box {
    padding: 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid;
}

.assessment-box.assessment-success { background: var(--success-light); border-color: rgba(22, 163, 74, 0.2); color: var(--gray-700); }
.assessment-box.assessment-warning { background: var(--warning-light); border-color: rgba(217, 119, 6, 0.2); color: var(--gray-700); }
.assessment-box.assessment-danger { background: var(--danger-light); border-color: rgba(220, 38, 38, 0.2); color: var(--gray-700); }
.assessment-box.assessment-info { background: var(--info-light); border-color: rgba(37, 99, 235, 0.2); color: var(--gray-700); }

/* ===== 33. DURATION INDICATOR ===== */
.duration-indicator { display: inline-flex; align-items: center; gap: 4px; }
.duration-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.duration-fast { background: var(--success); }
.duration-medium { background: var(--warning); }
.duration-slow { background: var(--danger); }

/* ===== 34. SEARCH TERMS ===== */
.search-terms-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    word-break: break-word;
}

.keywords-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* ===== 35. API KEY DISPLAY ===== */
.api-key-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--gray-600);
    word-break: break-all;
}

.api-key-display .key-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.api-key-display .copy-btn { flex-shrink: 0; }

/* ===== 36. ERROR STATE ===== */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    margin: 8px 0;
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    background: var(--danger-light);
    color: var(--danger);
    text-align: center;
}

.error-state-icon {
    font-size: 28px;
    line-height: 1;
}

.error-state-msg {
    font-size: 14px;
    color: var(--danger);
    margin: 0;
}

/* ===== 37. CENTERED SPINNER ===== */
.spinner-center {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--brand-teal);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: block;
    margin: 0 auto;
}

/* ===== 38. RESPONSIVE ===== */
@media (max-width: 900px) {
    .topbar-nav { display: none; }
    .mobile-menu-btn { display: block; }
    .topbar-left { gap: 12px; }
    .main-content { padding: 20px 16px; }
    .detail-grid { grid-template-columns: 1fr; }
    .modal { max-width: 95vw; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }
    .criteria-columns { grid-template-columns: 1fr; }
    .page-header-actions { flex-direction: column; align-items: stretch; }
}

@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--gray-300) transparent;
    }
    table::-webkit-scrollbar { height: 4px; }
    table::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
    .card-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 600px) {
    .topbar { padding: 0 12px; }
    .main-content { padding: 16px 12px; }
    .study-card .meta { flex-direction: column; gap: 4px; }
    .login-card { padding: 32px 24px; }
    /* Modals fullscreen em < 600px */
    .modal {
        margin: 0;
        width: 100vw;
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .modal-header { border-radius: 0; }
    .modal-footer { border-radius: 0; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select, .filter-bar input { width: 100%; }
    .criteria-columns { grid-template-columns: 1fr; }
    .results-meta { flex-wrap: wrap; }
    .results-meta .meta-badge { flex: auto; }
    .tabs { gap: 0; }
    .tab { padding: 8px 14px; font-size: 13px; }
    .pagination { gap: 4px; }
    .pagination a, .pagination button, .pagination span { min-width: 30px; height: 30px; font-size: 12px; }
}

@media (max-width: 480px) {
    /* Font sizes reduzidos */
    h1 { font-size: 20px; }
    h2 { font-size: 18px; }
    h3 { font-size: 15px; }
    h4 { font-size: 13px; }
    .page-header h2 { font-size: 18px; }
    .stat-card .value { font-size: 22px; }
    .panel-header h3 { font-size: 14px; }

    /* Botões full-width */
    .btn { width: 100%; justify-content: center; }
    .btn-sm { width: auto; }
    .btn-icon { width: auto; }
    .step-actions { flex-direction: column; gap: 10px; }
    .step-actions-right { width: 100%; display: flex; flex-direction: column; gap: 8px; }
    .step-actions-right .btn { width: 100%; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
    /* Botões inline em tables/cards não viram full-width */
    td .btn, th .btn { width: auto; }
    .pagination .btn { width: auto; min-width: 30px; }
    .dropdown-trigger { width: auto; }
}

/* Form grid responsive */
@media (max-width: 600px) {
    .panel-body > form > div[style*="grid-template-columns"],
    .modal-body > div[style*="grid-template-columns"],
    .panel-body > form > div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }
}

/* ===== 39. ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 22px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 120px; }

/* ===== CHART CONTAINER ===== */
.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
    transition: opacity 0.2s ease;
}

.chart-container.chart-updating {
    opacity: 0.5;
    pointer-events: none;
}

.chart-container canvas {
    max-width: 100%;
}

/* ===== CHART GRID (2-col on desktop, 1-col on mobile) ===== */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) { .chart-grid { grid-template-columns: 1fr; } }

/* ===== STAT CARD VARIANTS ===== */
.stat-sub {
    font-size: 0.72rem;
    margin-top: 2px;
    color: var(--text-muted);
}

/* ===== STAT ICON COLOR VARIANTS ===== */
.stat-icon-success { color: var(--success) !important; }
.stat-icon-info    { color: var(--info) !important; }
.stat-icon-warning { color: var(--warning) !important; }
.stat-icon-danger  { color: var(--danger) !important; }

/* ===== ACTIVITY FEED LIST ===== */
.activity-feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.activity-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-muted);
    justify-content: center;
}

/* ===== 40. UTILITY CLASSES ===== */
.hidden { display: none !important; }
.text-muted { color: var(--gray-400); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-teal { color: var(--brand-teal); }
.text-sm { font-size: 0.85rem; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-xs { margin-bottom: 4px; }
.text-secondary { color: var(--text-secondary); }
.text-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }
.flex-1 { flex: 1; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.mt-5 { margin-top: 20px; }
.items-end { align-items: flex-end; }
.min-w-160 { min-width: 160px; }
.gap-lg { gap: 24px; }
.p-0 { padding: 0; }
.cursor-pointer { cursor: pointer; }

/* ===== ROW CLICKABLE ===== */
.row-clickable { cursor: pointer; }

/* ===== CHART SUBTITLE ===== */
.chart-subtitle { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); }

/* ===== PANEL PADDED / FOOTER ===== */
.panel-padded { padding: 20px; }
.panel-footer { padding: 12px 20px; border-top: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }

/* ===== PARAMS TABLE ===== */
.params-table { margin: 0; }

/* ===== MODAL BODY PADDED ===== */
.modal-body-padded { padding: 16px; }

/* ===== WIDGET PREVIEW (tenant_detail) ===== */
.widget-tab-grid { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .widget-tab-grid { grid-template-columns: 1fr; } }
.widget-controls-col { display: flex; flex-direction: column; }
.widget-preview-container { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-elevated); min-height: 420px; }
.widget-preview-frame { width: 100%; min-height: 420px; border: none; display: block; }
.color-picker-input { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; background: none; }
.wpreview-logo-input { width: 100%; }
.wpreview-colortext-input { width: 88px; }

/* ===== 41. TABLE UTILITIES ===== */
.table-sm tbody td { padding: 6px 12px; font-size: 12px; }
.table-sm thead th { padding: 6px 12px; font-size: 10px; }
.col-checkbox { width: 40px; }
.detail-row td { padding: 0; }

/* ===== 42. FORM UTILITIES ===== */
.btn-full { width: 100%; justify-content: center; }
.textarea-no-resize { resize: none; }
.textarea-resize-v { resize: vertical; }
.input-sm { padding: 5px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); }
.plan-limit { width: 80px; text-align: right; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; display: block; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-primary); background: var(--bg-surface); transition: border-color 0.15s; font-family: inherit; }
.form-input:focus { outline: none; border-color: var(--primary); }
.form-input:disabled { background: var(--gray-100); cursor: not-allowed; opacity: 0.6; }
.input-flex { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-primary); background: var(--bg-surface); }
.input-readonly { background: var(--bg-elevated); color: var(--text-secondary); cursor: default; }
.input-color-text { width: 100px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-surface); color: var(--text-primary); }

/* ===== 43. STAT STANDALONE LABELS ===== */
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

/* ===== 44. PROGRESS BAR ===== */
.progress-track { background: var(--gray-100); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--brand-teal); transition: width 0.3s ease; width: 0%; }

/* ===== 45. LOGIN THEME TOGGLE ===== */
.login-theme-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
}

/* ===== 46. MISC COMPONENT UTILITIES ===== */
.logo-preview-img { max-height: 40px; max-width: 120px; object-fit: contain; border-radius: 4px; }
.masked-value { filter: blur(4px); user-select: none; cursor: default; transition: filter 0.2s; }
.masked-value:hover { filter: none; }
.webhook-status-box { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg-elevated); }

/* ===== 47. ADDITIONAL BADGES ===== */
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }

/* ===== DETAIL CELL & AUDIT PRE ===== */
.detail-cell {
    padding: 16px;
    background: var(--bg-elevated);
}


.audit-detail-pre {
    margin: 0;
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ===== SETTINGS GRID ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

/* ===== MAINTENANCE OUTPUT ===== */
.maintenance-output {
    white-space: pre-wrap;
    font-size: 12px;
    max-height: 200px;
    overflow: auto;
}



/* ===== STAR RATINGS & FEEDBACK ===== */
.star { font-size: 14px; }
.star-filled { color: var(--warning); }
.star-empty { color: var(--border); }

/* ===== INSIGHTS (feedback) ===== */
.insights-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.insight-card {
    padding: 0;
    overflow: hidden;
}
.insight-card-full {
    grid-column: 1 / -1;
}
.insight-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.insight-icon { font-size: 18px; }
.insight-card-body {
    padding: 16px 20px;
    max-height: 280px;
    overflow-y: auto;
}
.insight-bar-item { }
.insight-bar-track {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}
.insight-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.bar-success { background: var(--success); }
.bar-warning { background: var(--warning); }
.bar-danger  { background: var(--danger); }
.insight-bar-count { min-width: 40px; text-align: right; }


.feedback-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.feedback-detail-comment { grid-column: 1 / -1; }


.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}


.col-icon { width: 30px; }


.apikey-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.apikey-form-tenant { min-width: 200px; flex: 1; }
.apikey-form-env    { min-width: 160px; }

/* ===== ERROR PAGES ===== */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 24px;
    text-align: center;
    background: var(--bg-body);
    color: var(--text-primary);
}

.error-icon {
    color: var(--primary);
    margin-bottom: 16px;
}

.error-code {
    font-size: 96px;
    font-weight: 800;
    line-height: 1;
    margin: 0 0 12px;
    background: linear-gradient(135deg, var(--brand-navy), var(--brand-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-message {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text-primary);
}

.error-detail {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 0 0 32px;
    max-width: 420px;
    line-height: 1.5;
}

.error-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.error-back:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

@media (max-width: 480px) {
    .error-code { font-size: 64px; }
    .error-message { font-size: 18px; }
    .error-detail { font-size: 14px; }
    .error-icon svg { width: 88px; height: 88px; }
}

/* ===== BULK ACTIONS ===== */
.bulk-actions-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-primary);
}

.bulk-actions-bar.visible {
    display: flex;
}

.bulk-actions-bar .bulk-count {
    font-weight: 700;
    color: var(--primary);
}

.bulk-actions-bar .bulk-sep {
    flex: 1;
}

.search-input { width: 100%; max-width: 400px; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-surface); color: var(--text-primary); }
.search-input:focus { border-color: var(--brand-teal); outline: none; }


/* ===== ACTIVITY FEED (LifeTrial minimalist — dense, compact) ===== */
.activity-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border-light); min-height: 44px; transition: background 0.15s ease; }
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-hover); }
.activity-empty { list-style: none; }
.activity-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-teal); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.activity-avatar-icon { background: var(--gray-100); color: var(--gray-700); font-size: 14px; }
.activity-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.activity-text { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.activity-meta { font-size: 11px; color: var(--gray-500); margin-top: 1px; line-height: 1.2; }
.activity-time { font-size: 11px; color: var(--gray-400); flex-shrink: 0; white-space: nowrap; }


/* ===== SESSION DETAIL COMPONENTS ===== */
.session-header-wrap { flex-wrap: wrap; }
.session-title-wrap { flex-wrap: wrap; }
.session-meta { margin-top: 4px; }
.session-tenant-sep { margin-left: 12px; }
.session-actions { flex-wrap: wrap; }
.session-contact-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.session-summary-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-top: 20px; }

.btn-danger-outline { color: var(--danger); border-color: var(--danger); }
.btn-icon-inline { vertical-align: -2px; margin-right: 4px; }

/* Modal utilities */
.modal-md { max-width: 520px; }
.modal-sm { max-width: 480px; }
.modal-lg { max-width: 720px; }
.modal-header { margin-bottom: 0; }
.modal-title { margin: 0; }
.modal-close-btn { background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--gray-400); padding: 4px 6px; border-radius: var(--radius-sm); transition: color 0.15s, background 0.15s; }
.modal-close-btn:hover { color: var(--gray-700); background: var(--gray-100); }
.modal-fields { display: grid; gap: 12px; }
.form-label-sm { font-size: 12px; font-weight: 500; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.form-control { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-primary); font-size: 14px; }
.wi-result-box { margin-top: 16px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-elevated); font-size: 13px; }
.share-url-input { flex: 1; min-width: 0; }
.share-expires { margin-top: 10px; }


.contact-stack { display: flex; flex-direction: column; gap: 8px; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.icon-inline { vertical-align: -2px; margin-right: 4px; flex-shrink: 0; }
.icon-inline-sm { vertical-align: -1px; margin-right: 4px; }
.criteria-item { display: flex; align-items: center; font-size: 13px; padding: 2px 0; }
.study-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.result-card-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; }
.badge-local { font-size: 11px !important; background: var(--success); color: #fff; padding: 2px 8px; }
.study-title { margin-top: 4px; font-weight: 600; }
.score-col { text-align: right; min-width: 160px; }
.score-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.history-container { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.history-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.status-timeline { display: flex; flex-direction: column; gap: 6px; }
.status-timeline-entry { display: flex; align-items: flex-start; gap: 8px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; display: inline-block; }
.feedback-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
.text-xs { font-size: 12px; }
.text-xxs { font-size: 11px; }
.text-10 { font-size: 10px; }
.text-13 { font-size: 13px; }
.label-block { display: block; margin-bottom: 6px; }
.ml-xs { margin-left: 6px; }
.summary-next { margin-top: 16px; }
.text-muted-13 { color: var(--gray-500); font-size: 13px; margin-bottom: 16px; }
.detail-pre { white-space: pre-wrap; }
.badge-gap { margin: 1px; }
.empty-state-compact { padding: 32px 16px; }
.row-label-normal { font-weight: 400; color: var(--text); }
.overflow-x-auto { overflow-x: auto; }
.min-w-140 { min-width: 140px; }
.min-w-180 { min-width: 180px; }
.min-w-200 { min-width: 200px; }
.max-h-340 { max-height: 340px; overflow-y: auto; }
.w-36 { width: 36px; }
.row-current { background: var(--bg-hover); }
.badge-xs { font-size: 10px; height: 18px; padding: 0 6px; }

/* ===== STUDY COMPARE ===== */
.compare-header-wrap { flex-wrap: wrap; }
.compare-table-wrap { padding: 0; overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; }
.compare-legend { font-size: 13px; }

.compare-table th,
.compare-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-size: 13px;
}
.compare-table thead th {
    background: var(--bg-surface);
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.compare-table tbody tr:hover { background: var(--bg-hover); }
.compare-table .row-label {
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 130px;
    background: var(--bg-surface);
}

.criteria-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 0;
}
.criteria-inclusion {
    background: rgba(39,174,96,0.12);
    color: var(--success);
    border: 1px solid rgba(39,174,96,0.25);
}
.criteria-exclusion {
    background: rgba(231,76,60,0.10);
    color: var(--danger);
    border: 1px solid rgba(231,76,60,0.22);
}
.criteria-warn {
    background: rgba(243,156,18,0.10);
    color: var(--warning);
    border: 1px solid rgba(243,156,18,0.22);
}
.criteria-absent {
    color: var(--text-muted);
    opacity: 0.4;
    font-size: 14px;
}

/* ===== 48. PRINT STYLES ===== */
@media print {
  /* 1. Esconder elementos de navegação e interface */
  .topbar,
  .mobile-drawer,
  .btn,
  .modal,
  .toast-container,
  nav,
  .pagination {
    display: none !important;
  }

  /* 2. Main content: largura total, sem margens nem padding */
  .main-content {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 3. Remover sombras e bordas arredondadas */
  * {
    box-shadow: none !important;
    border-radius: 0 !important;
    text-shadow: none !important;
  }

  /* 4. Forçar cor preta para texto */
  body,
  * {
    color: #000 !important;
  }

  /* 5. Forçar fundo branco */
  body,
  html,
  .main-content,
  .panel,
  .stat-card {
    background: #fff !important;
  }

  /* 6. Tabelas: bordas finas visíveis */
  table {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  th,
  td {
    border: 1px solid #000 !important;
    padding: 4px 8px !important;
  }

  /* 7. Page break: evitar quebra dentro de .panel e .stat-card */
  .panel,
  .stat-card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* 8. Logo: mostrar no topo */
  .topbar-logo,
  .login-logo {
    display: block !important;
    margin-bottom: 16px !important;
  }
}

/* ===== 49. SETUP 2FA ===== */
.setup-instructions {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    padding-left: 1.2rem;
    margin-bottom: 1.2rem;
}

.qr-code-img {
    border: 4px solid #fff;
    border-radius: 8px;
    width: 200px;
    height: 200px;
}

.setup-details { margin-bottom: 1.2rem; }

.setup-summary {
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.secret-code {
    margin-top: 0.5rem;
    background: var(--bg-elevated);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    word-break: break-all;
}

/* ===== 50. WELCOME BANNER ===== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary, #1A5276) 0%, #17A589 100%);
    border: none;
    margin-bottom: 24px;
}

.welcome-banner-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
}

.welcome-banner-title {
    color: #fff;
    margin: 0 0 6px;
    font-size: 16px;
}

.welcome-banner-text {
    color: rgba(255, 255, 255, 0.88);
    margin: 0;
    font-size: 14px;
}

.btn-welcome {
    background: #fff;
    color: #1A5276;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Study status color classes (session_detail status timeline) ── */
.sc-recruiting          { color: var(--success); background: var(--success); }
.sc-completed           { color: #3b82f6; background: #3b82f6; }
.sc-terminated          { color: var(--danger); background: var(--danger); }
.sc-suspended           { color: var(--warning); background: var(--warning); }
.sc-withdrawn           { color: var(--text-muted); background: var(--text-muted); }
.sc-not-yet-recruiting  { color: #f59e0b; background: #f59e0b; }
.sc-active-not-recruiting   { color: #14b8a6; background: #14b8a6; }
.sc-enrolling-by-invitation { color: #8b5cf6; background: #8b5cf6; }
.sc-default             { color: var(--text-muted); background: var(--text-muted); }

/* status-dot uses only background; strong text uses only color */
.status-timeline-entry .status-dot[class*="sc-"] { color: transparent; }
.status-timeline-entry strong[class*="sc-"]       { background: transparent; }

/* ===== Landing + Legal Pages ===== */
.public-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
}
.public-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.public-header .logo { height: 32px; display: block; }
.public-header-brand { display: inline-flex; align-items: center; text-decoration: none; }
.public-header-nav { display: flex; gap: 20px; align-items: center; }
.public-header-nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease;
}
.public-header-nav a:hover,
.public-header-nav a.active { color: var(--brand-teal); }
.public-header-actions { display: flex; gap: 12px; align-items: center; }
@media (max-width: 720px) {
    .public-header-nav { display: none; }
    .public-header { gap: 12px; }
}

.public-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    text-align: center;
    color: var(--gray-500);
    font-size: 13px;
    margin-top: auto;
}
.public-footer-inner { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.public-footer-nav { display: flex; flex-wrap: wrap; justify-content: center; }
.public-footer a {
    color: var(--gray-700);
    text-decoration: none;
    margin: 0 12px;
    font-size: 13px;
}
.public-footer a:hover { color: var(--brand-teal); }

.hero {
    padding: 80px 24px;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-body) 100%);
}
.hero h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
    line-height: 1.2;
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
}
.hero p {
    font-size: 18px;
    color: var(--gray-600);
    max-width: 640px;
    margin: 0 auto 32px;
    line-height: 1.6;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 720px) {
    .hero { padding: 56px 20px; }
    .hero h1 { font-size: 32px; }
    .hero p { font-size: 16px; }
}

.features {
    padding: 60px 24px;
    max-width: 1100px;
    margin: 0 auto;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
@media (max-width: 900px) {
    .features-grid { grid-template-columns: 1fr; }
}
.feature-card {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
}
.feature-card .feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
    line-height: 1;
}
.feature-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-900);
}
.feature-card p {
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.5;
    margin: 0;
}

.how-it-works { padding: 60px 24px; background: var(--bg-surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.how-it-works .section-title,
.use-cases .section-title,
.cta-bottom h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 32px;
    text-align: center;
}
.how-steps {
    max-width: 900px;
    margin: 24px auto 0;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.how-step {
    flex: 1;
    min-width: 180px;
    padding: 16px;
    border-left: 3px solid var(--brand-teal);
}
.how-step-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--brand-teal);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.how-step h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 4px 0 6px;
}
.how-step p {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
    margin: 0;
}

.use-cases { padding: 20px 0 60px; }
.cta-bottom { padding: 60px 24px; background: var(--bg-surface); border-top: 1px solid var(--border); }
.cta-bottom .features { padding: 0 24px; }
.cta-bottom p { margin-bottom: 24px; }

.legal-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 24px;
    width: 100%;
    box-sizing: border-box;
}
.legal-page h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-900);
}
.legal-page .updated {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 32px;
}
.legal-page h2 {
    font-size: 22px;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--gray-900);
    scroll-margin-top: 80px;
}
.legal-page h3 {
    font-size: 17px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--gray-800);
}
.legal-page p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--gray-700);
    margin-bottom: 12px;
}
.legal-page ul,
.legal-page ol {
    margin: 12px 0 12px 24px;
    color: var(--gray-700);
    line-height: 1.7;
}
.legal-page li { margin-bottom: 6px; font-size: 15px; }
.legal-page a { color: var(--brand-teal); text-decoration: none; }
.legal-page a:hover { text-decoration: underline; }
.legal-page code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.legal-toc {
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 32px;
}
.legal-toc h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    margin-bottom: 8px;
    margin-top: 0;
}
.legal-toc ol {
    margin: 0 0 0 20px;
    font-size: 13px;
    color: var(--gray-700);
}
.legal-toc li { margin-bottom: 4px; font-size: 13px; }
.legal-toc a {
    color: var(--gray-700);
    text-decoration: none;
}
.legal-toc a:hover { color: var(--brand-teal); }

/* Utility classes used in landing/legal pages (avoid inline styles) */
.text-center { text-align: center; }
.text-muted { color: var(--gray-600); }
.mb-24 { margin-bottom: 24px; }

/* Larger button variant for landing page CTAs (btn-sm / btn-ghost / btn-outline already defined above) */
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ===== LifeTrial Integration (Phase 12.6) ===== */
.lifetrial-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
}
.lifetrial-status.ok {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}
.lifetrial-status.error {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}
.lifetrial-status.disabled {
    background: var(--gray-100);
    color: var(--gray-500);
    border-color: var(--border);
}
.lifetrial-help {
    padding: 12px;
    background: var(--gray-50);
    border-left: 3px solid var(--brand-teal);
    border-radius: 4px;
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 16px;
}
.lifetrial-help code {
    background: var(--bg-surface);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.lifetrial-help ul {
    margin: 8px 0 0 20px;
    padding: 0;
}
.lifetrial-help li {
    margin-bottom: 4px;
}

/* ===== Signup + Welcome (Phase 12.3) ===== */
.signup-container {
    max-width: 560px;
    margin: 0 auto;
    padding: 48px 24px;
}
.signup-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}
.signup-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-900);
}
.signup-card .subtitle {
    color: var(--gray-500);
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.5;
}
.signup-form .form-group { margin-bottom: 16px; }
.signup-form textarea { resize: vertical; min-height: 80px; }
.signup-terms {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 16px 0;
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
}
.signup-terms input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.signup-terms a { color: var(--brand-teal); text-decoration: none; }
.signup-terms a:hover { text-decoration: underline; }
.signup-submit { width: 100%; margin-top: 8px; }
.signup-success {
    padding: 16px;
    background: #d1fae5;
    border: 1px solid #16a34a;
    border-radius: 8px;
    color: #065f46;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}
.signup-error {
    padding: 12px 16px;
    background: #fee2e2;
    border: 1px solid #dc2626;
    border-radius: 8px;
    color: #7f1d1d;
    font-size: 13px;
    margin: 12px 0;
}
.signup-success-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.welcome-wizard {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 24px;
}
.welcome-progress {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
}
.welcome-progress-step {
    flex: 1;
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    transition: background 0.2s ease;
}
.welcome-progress-step.active { background: var(--brand-teal); }
.welcome-step {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}
.welcome-step h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-900);
}
.welcome-step .subtitle {
    color: var(--gray-600);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}
.welcome-step .form-group { margin-bottom: 16px; }
.welcome-hint { font-size: 12px; color: var(--gray-500); margin-top: 6px; line-height: 1.5; }
.welcome-embed-code {
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 12px 0;
    color: var(--gray-800);
}
.welcome-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.welcome-actions .btn { flex: 0 0 auto; }
.welcome-areas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin: 16px 0;
}
.welcome-area-btn {
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s ease;
}
.welcome-area-btn:hover { border-color: var(--brand-teal); }
.welcome-area-btn.active {
    background: var(--brand-teal);
    color: #ffffff;
    border-color: var(--brand-teal);
}
.hidden { display: none !important; }

.empresas-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.empresas-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: -1px;
}
.empresas-tab:hover { color: var(--brand-teal); }
.empresas-tab.active {
    color: var(--brand-teal);
    border-bottom-color: var(--brand-teal);
}
