/* ═══════════════════════════════════════════════════════════════
   eTrustPortal — Production Design System
   Dark navy theme, Inter + JetBrains Mono
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables — Dark Theme (default) ────────────────── */
:root,
[data-theme="dark"] {
  /* ── Backgrounds ── */
  --bg-base:        #0a0e1a;
  --bg-surface:     #111827;
  --bg-elevated:    #1a2235;
  --bg-hover:       #1e2a40;
  --bg-active:      #243048;
  --surface-2:      #1a2235;

  /* ── Borders ── */
  --border:         #1e2d45;
  --border-light:   #253550;

  /* ── Primary / Accent (tenant-overrideable) ── */
  --primary:        var(--tenant-primary, #0066FF);
  --primary-hover:  var(--tenant-primary-hover, #0052cc);
  --primary-light:  var(--tenant-primary-light, rgba(0,102,255,0.12));
  --primary-glow:   var(--tenant-primary-glow, rgba(0,102,255,0.25));

  /* Keep --accent as alias for backwards compat */
  --accent:         var(--primary);
  --accent-hover:   var(--primary-hover);
  --accent-light:   var(--primary-light);
  --accent-glow:    var(--primary-glow);

  /* ── Secondary Colors ── */
  --cyan:           #00D4FF;
  --cyan-light:     rgba(0,212,255,0.12);
  --success:        #10b981;
  --success-light:  rgba(16,185,129,0.12);
  --warning:        #f59e0b;
  --warning-light:  rgba(245,158,11,0.12);
  --danger:         #ef4444;
  --danger-light:   rgba(239,68,68,0.12);
  --purple:         #8b5cf6;
  --purple-light:   rgba(139,92,246,0.12);

  /* ── Text ── */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-disabled:  #374151;

  /* ── Input / Form ── */
  --input-bg:       #1a2235;
  --input-border:   #1e2d45;

  /* ── Sidebar ── */
  --sidebar-bg:     #0d1117;

  /* ── Card ── */
  --card-bg:        #111827;
  --card-border:    #1e2d45;

  /* ── Fonts ── */
  --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  /* ── Radius ── */
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --radius-full:    9999px;

  /* ── Shadows ── */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.4);
  --shadow:         0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.6);
  --shadow-accent:  0 4px 20px rgba(0,102,255,0.3);

  /* ── Layout ── */
  --sidebar-w:      240px;
  --header-h:       60px;
  --transition:     0.18s ease;

  /* ── Tenant primary placeholder ── */
  --tenant-primary:       #0066FF;
  --tenant-primary-hover: #0052cc;
  --tenant-primary-light: rgba(0,102,255,0.12);
  --tenant-primary-glow:  rgba(0,102,255,0.25);
}

/* ── Light Theme ───────────────────────────────────────────────── */
[data-theme="light"] {
  /* ── Backgrounds ── */
  --bg-base:        #f0f4f8;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f8fafc;
  --bg-hover:       #e8f0fe;
  --bg-active:      #dbeafe;
  --surface-2:      #f8fafc;

  /* ── Borders ── */
  --border:         #e2e8f0;
  --border-light:   #cbd5e1;

  /* ── Primary stays tenant-controlled ── */
  --primary:        var(--tenant-primary, #0066FF);
  --primary-hover:  var(--tenant-primary-hover, #0052cc);
  --primary-light:  var(--tenant-primary-light, rgba(0,102,255,0.10));
  --primary-glow:   var(--tenant-primary-glow, rgba(0,102,255,0.20));
  --accent:         var(--primary);
  --accent-hover:   var(--primary-hover);
  --accent-light:   var(--primary-light);
  --accent-glow:    var(--primary-glow);

  /* ── Secondary Colors ── */
  --cyan:           #0891b2;
  --cyan-light:     rgba(8,145,178,0.10);
  --success:        #059669;
  --success-light:  rgba(5,150,105,0.10);
  --warning:        #d97706;
  --warning-light:  rgba(217,119,6,0.10);
  --danger:         #dc2626;
  --danger-light:   rgba(220,38,38,0.10);
  --purple:         #7c3aed;
  --purple-light:   rgba(124,58,237,0.10);

  /* ── Text ── */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-disabled:  #cbd5e1;

  /* ── Input / Form ── */
  --input-bg:       #ffffff;
  --input-border:   #d1d5db;

  /* ── Sidebar ── */
  --sidebar-bg:     #1e293b;

  /* ── Card ── */
  --card-bg:        #ffffff;
  --card-border:    #e2e8f0;

  /* ── Shadows ── */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.10);
  --shadow:         0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.15);
  --shadow-accent:  0 4px 20px rgba(0,102,255,0.20);
}

/* Light theme: override body + main areas */
[data-theme="light"] body {
  background: var(--bg-base);
  color: var(--text-primary);
}
[data-theme="light"] .sidebar {
  background: var(--sidebar-bg);
  border-color: #334155;
}
[data-theme="light"] .sidebar .nav-item { color: #94a3b8; }
[data-theme="light"] .sidebar-brand,
[data-theme="light"] .sidebar-tenant-name { color: #f1f5f9; }
[data-theme="light"] .sidebar-tenant-label,
[data-theme="light"] .nav-section-label { color: #64748b; }
[data-theme="light"] .header { background: var(--bg-surface); border-color: var(--border); }
[data-theme="light"] .login-card { background: var(--bg-surface); border-color: var(--border); }
[data-theme="light"] .stat-card,
[data-theme="light"] .card { background: var(--card-bg); border-color: var(--card-border); }
[data-theme="light"] .form-control,
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}
[data-theme="light"] .modal-content {
  background: var(--bg-surface);
  border-color: var(--border);
}
[data-theme="light"] .table thead th { background: var(--bg-elevated); color: var(--text-secondary); border-color: var(--border); }
[data-theme="light"] .table tbody td { border-color: var(--border); }
[data-theme="light"] .table tbody tr:hover { background: var(--bg-hover); }
[data-theme="light"] .toast { background: var(--bg-surface); border-color: var(--border); color: var(--text-primary); }
[data-theme="light"] .dropdown-menu { background: var(--bg-surface); border-color: var(--border); }
[data-theme="light"] .settings-nav-item { color: var(--text-secondary); }
[data-theme="light"] .settings-nav-item:hover { background: var(--bg-hover); }
[data-theme="light"] .settings-nav-item.active { background: var(--primary-light); color: var(--primary); }

/* ── Custom Theme (uses CSS vars injected by applyBranding JS) ─────── */
[data-theme="custom"] {
  --bg-base:        var(--custom-bg-base, #0a0e1a);
  --bg-surface:     var(--custom-bg-surface, #111827);
  --bg-elevated:    var(--custom-bg-elevated, #1a2235);
  --bg-hover:       var(--custom-bg-hover, #1e2a40);
  --bg-active:      var(--custom-bg-active, #243048);
  --surface-2:      var(--custom-bg-elevated, #1a2235);
  --border:         var(--custom-border, #1e2d45);
  --border-light:   var(--custom-border-light, #253550);
  --text-primary:   var(--custom-text-primary, #f1f5f9);
  --text-secondary: var(--custom-text-secondary, #94a3b8);
  --text-muted:     var(--custom-text-muted, #64748b);
  --sidebar-bg:     var(--custom-sidebar-bg, #0d1117);
  --input-bg:       var(--custom-bg-elevated, #1a2235);
  --card-bg:        var(--custom-bg-surface, #111827);
  --card-border:    var(--custom-border, #1e2d45);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--cyan); }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }
ul, ol { list-style: none; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,102,255,0.08) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,212,255,0.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.login-logo-text { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.login-logo-text span { color: var(--accent); }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }
.login-demo-btns {
  display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap;
}
.demo-btn {
  flex: 1; min-width: 80px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  transition: all var(--transition);
  text-align: center;
}
.demo-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.demo-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ── Form Elements ─────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  outline: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-accent); }
.btn-secondary {
  background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-light); }
.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost {
  background: transparent; color: var(--text-secondary); border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── Loading spinner ───────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.sidebar-brand { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-brand span { color: var(--accent); }

.sidebar-tenant {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-tenant-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.sidebar-tenant-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg-hover); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Header ────────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.header-title { font-size: 18px; font-weight: 700; flex: 1; }
.header-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  width: 260px;
  transition: border-color var(--transition);
}
.header-search:focus-within { border-color: var(--accent); }
.header-search input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; width: 100%;
}
.header-search input::placeholder { color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
  position: relative;
}
.header-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.header-icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 9px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
}

/* ── Page Content ──────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header-left h1 { font-size: 22px; font-weight: 700; }
.page-header-left p { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════
   CARDS & STATS
══════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--accent-light); }
.stat-icon.cyan   { background: var(--cyan-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.red    { background: var(--danger-light); }
.stat-icon.purple { background: var(--purple-light); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════════ */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.table-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  flex: 1; min-width: 200px; max-width: 320px;
}
.table-search input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; width: 100%;
}
.table-search input::placeholder { color: var(--text-muted); }
.table-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select {
  padding: 7px 28px 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2364748b' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}
.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.table-empty .empty-icon { font-size: 40px; margin-bottom: 12px; }
.table-empty p { font-size: 14px; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary);
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════
   BADGES & TAGS
══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-blue    { background: var(--accent-light);   color: var(--accent); }
.badge-cyan    { background: var(--cyan-light);     color: var(--cyan); }
.badge-green   { background: var(--success-light);  color: var(--success); }
.badge-yellow  { background: var(--warning-light);  color: var(--warning); }
.badge-red     { background: var(--danger-light);   color: var(--danger); }
.badge-purple  { background: var(--purple-light);   color: var(--purple); }
.badge-gray    { background: rgba(100,116,139,0.15); color: var(--text-secondary); }

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Tag Editor */
.tag-editor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 42px; padding: 6px 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: text;
  transition: border-color 0.2s;
}
.tag-editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.tag-editor #editClientTagPills { display: contents; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 10px;
  background: var(--primary); color: #fff;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-pill .tag-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(255,255,255,0.25); cursor: pointer;
  font-size: 11px; line-height: 1; border: none; color: #fff;
  padding: 0; transition: background 0.15s;
}
.tag-pill .tag-remove:hover { background: rgba(255,255,255,0.45); }
.tag-editor input[type="text"] {
  flex: 1; min-width: 120px; border: none; outline: none;
  background: transparent; color: var(--text-primary);
  font-size: 13px; padding: 2px 0;
}
.tag-editor input[type="text"]::placeholder { color: var(--text-muted); }
kbd {
  display: inline-block; padding: 1px 5px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 4px; font-size: 11px; font-family: monospace;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px; max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.3s ease;
}
.toast.removing { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-msg { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast.info    { border-color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.dashboard-grid .span-2 { grid-column: span 2; }
.dashboard-grid .span-3 { grid-column: span 3; }

.chart-container { position: relative; }
canvas { max-width: 100%; }

.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}
.activity-text { font-size: 13px; line-height: 1.4; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════
   CLIENTS
══════════════════════════════════════════════════════════════ */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.client-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
}
.client-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.client-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.client-avatar {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.client-name { font-size: 15px; font-weight: 600; }
.client-type { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.client-stats { display: flex; gap: 16px; margin-top: 12px; }
.client-stat { text-align: center; }
.client-stat-value { font-size: 18px; font-weight: 700; }
.client-stat-label { font-size: 10px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   DOCUMENTS
══════════════════════════════════════════════════════════════ */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.doc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all var(--transition);
  cursor: pointer;
}
.doc-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.doc-icon { font-size: 32px; margin-bottom: 10px; }
.doc-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; word-break: break-word; }
.doc-meta { font-size: 11px; color: var(--text-muted); }
.doc-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ── Upload Zone ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  background: var(--bg-elevated);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone-icon { font-size: 40px; margin-bottom: 12px; }
.upload-zone-text { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.upload-zone-hint { font-size: 12px; color: var(--text-muted); }

.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.upload-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.upload-item-icon { font-size: 20px; flex-shrink: 0; }
.upload-item-info { flex: 1; min-width: 0; }
.upload-item-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item-size { font-size: 11px; color: var(--text-muted); }
.upload-progress { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.upload-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }
.upload-status { font-size: 11px; font-weight: 600; flex-shrink: 0; }
.upload-status.done    { color: var(--success); }
.upload-status.error   { color: var(--danger); }
.upload-status.pending { color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   KANBAN / TASKS
══════════════════════════════════════════════════════════════ */
.kanban-board {
  display: flex; gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-col {
  min-width: 260px; width: 260px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 200px);
}
.kanban-col-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.kanban-col-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kanban-col-count {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-size: 11px; color: var(--text-muted);
}
.kanban-cards { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.kanban-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
.kanban-card-title { font-size: 13px; font-weight: 500; margin-bottom: 8px; line-height: 1.4; }
.kanban-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.priority-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.priority-dot.high   { background: var(--danger); }
.priority-dot.normal { background: var(--warning); }
.priority-dot.low    { background: var(--success); }

/* ══════════════════════════════════════════════════════════════
   SECURE MESSAGES
══════════════════════════════════════════════════════════════ */
.messages-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: calc(100vh - 160px);
}
.threads-panel {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.threads-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.threads-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.threads-list { flex: 1; overflow-y: auto; }
.thread-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.thread-item:hover { background: var(--bg-hover); }
.thread-item.active { background: var(--accent-light); }
.thread-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.thread-client { font-size: 13px; font-weight: 600; }
.thread-time { font-size: 11px; color: var(--text-muted); }
.thread-subject { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

.chat-panel { display: flex; flex-direction: column; }
.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-subject { font-size: 15px; font-weight: 600; }
.chat-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 12px;
}
.chat-empty-icon { font-size: 48px; }

.message-bubble {
  display: flex; gap: 10px; max-width: 75%;
}
.message-bubble.outgoing { flex-direction: row-reverse; align-self: flex-end; }
.message-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.message-content { display: flex; flex-direction: column; gap: 4px; }
.message-sender { font-size: 11px; color: var(--text-muted); }
.message-bubble.outgoing .message-sender { text-align: right; }
.message-text {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  font-size: 13px; line-height: 1.5;
}
.message-bubble.outgoing .message-text {
  background: var(--accent-light);
  border-color: var(--accent);
}
.message-time { font-size: 10px; color: var(--text-muted); }
.message-bubble.outgoing .message-time { text-align: right; }
.message-encrypted-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--success);
  margin-top: 2px;
}

.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  resize: none;
  outline: none;
  max-height: 120px;
  transition: border-color var(--transition);
  font-family: inherit;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   E-SIGNATURES
══════════════════════════════════════════════════════════════ */
.signature-canvas-wrapper {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  cursor: crosshair;
}
canvas.sig-canvas { display: block; width: 100%; height: 200px; }
.sig-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.sig-tab {
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  background: none; border-top: none; border-left: none; border-right: none;
}
.sig-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sig-type-input {
  font-family: 'Dancing Script', cursive, var(--font-sans);
  font-size: 32px;
  text-align: center;
  background: #fff;
  color: #1a1a2e;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  outline: none;
}

/* ══════════════════════════════════════════════════════════════
   AUDIT LOG
══════════════════════════════════════════════════════════════ */
.audit-action {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.audit-action.create  { background: var(--success-light); color: var(--success); }
.audit-action.update  { background: var(--warning-light); color: var(--warning); }
.audit-action.delete  { background: var(--danger-light);  color: var(--danger); }
.audit-action.login   { background: var(--accent-light);  color: var(--accent); }
.audit-action.logout  { background: rgba(100,116,139,0.15); color: var(--text-secondary); }
.audit-action.download { background: var(--cyan-light);   color: var(--cyan); }
.audit-action.upload  { background: var(--purple-light);  color: var(--purple); }

/* ══════════════════════════════════════════════════════════════
   SETTINGS
══════════════════════════════════════════════════════════════ */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
}
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item {
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  background: none; border: none; text-align: left; width: 100%;
}
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.settings-nav-item.active { background: var(--accent-light); color: var(--accent); }
.settings-section { display: none; }
.settings-section.active { display: block; }

/* ══════════════════════════════════════════════════════════════
   REPORTS
══════════════════════════════════════════════════════════════ */
.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ══════════════════════════════════════════════════════════════
   CLIENT PORTAL SPECIFIC
══════════════════════════════════════════════════════════════ */
.portal-welcome {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.portal-welcome::before {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
  pointer-events: none;
}
.portal-welcome h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.portal-welcome p { color: var(--text-secondary); font-size: 14px; }

.doc-request-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color var(--transition);
}
.doc-request-card:hover { border-color: var(--border-light); }
.doc-request-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--warning-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.doc-request-info { flex: 1; }
.doc-request-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.doc-request-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.doc-request-due { font-size: 11px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   UTILITY CLASSES
══════════════════════════════════════════════════════════════ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Loading State ─────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg-base);
  z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
}
.loading-logo { font-size: 48px; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.loading-text { font-size: 14px; color: var(--text-muted); }

/* ── Skeleton ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid .span-3 { grid-column: span 2; }
  .messages-layout { grid-template-columns: 260px 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .span-2, .dashboard-grid .span-3 { grid-column: span 1; }
  .messages-layout { grid-template-columns: 1fr; height: auto; }
  .threads-panel { display: none; }
  .threads-panel.show { display: flex; }
  .reports-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
/* ── Toggle Switch ─────────────────────────────────────────── */
/* Usage: <label class="toggle-switch"><input type="checkbox"><span class="toggle-slider"></span></label> */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── E-Signature Provider Cards ─────────────────────────────────────────────── */
.sig-provider-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  transition: all var(--transition);
  background: var(--bg-surface);
  user-select: none;
}
.sig-provider-card:hover { border-color: var(--primary); background: rgba(0,102,255,0.04); }
.sig-provider-card.active { border-color: var(--primary); background: rgba(0,102,255,0.08); color: var(--primary); }

/* ═══ New Feature Styles ══════════════════════════════════════════════════ */

/* Notification items */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s;
  cursor: pointer;
}
.notif-item:hover { background: var(--bg-secondary); }
.notif-item.unread { background: #eff6ff; border-left: 3px solid #3b82f6; }
.notif-item:last-child { border-bottom: none; }
.notif-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 14px; color: var(--text-primary); margin-bottom: 2px; }
.notif-body  { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.notif-time  { font-size: 12px; color: var(--text-muted, #9ca3af); }
.notif-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #3b82f6; flex-shrink: 0; margin-top: 6px; }

/* Onboarding workflow cards */
.onboarding-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  background: var(--bg-white, #fff);
  transition: box-shadow 0.2s;
}
.onboarding-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.onboarding-steps { margin-top: 16px; }
.onboarding-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}
.onboarding-step:last-child { border-bottom: none; }
.step-indicator {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.step-pending   { background: #f3f4f6; color: #6b7280; border: 2px solid #d1d5db; }
.step-completed { background: #d1fae5; color: #065f46; border: 2px solid #6ee7b7; }
.step-current   { background: #dbeafe; color: #1e40af; border: 2px solid #93c5fd; }
.step-skipped   { background: #fef3c7; color: #92400e; }
.ob-progress-bar { height: 6px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.ob-progress-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #10b981); border-radius: 4px; transition: width 0.3s; }

/* Document preview */
.preview-container { position: relative; }
.preview-img { max-width: 100%; height: auto; display: block; }
.preview-unavailable { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.preview-unavailable .preview-icon { font-size: 64px; margin-bottom: 16px; }

/* MFA styles */
.mfa-type-card {
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}
.mfa-type-card:hover { border-color: #3b82f6; background: #eff6ff; }
.mfa-type-card.selected { border-color: #3b82f6; background: #eff6ff; }
.backup-code-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 15px;
  text-align: center;
  letter-spacing: 2px;
}
.backup-code-item.used { text-decoration: line-through; color: #9ca3af; }

/* Accounting cards */
.accounting-provider-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  background: white;
  transition: box-shadow 0.2s;
}
.accounting-provider-card.connected { border-color: #10b981; }
.accounting-provider-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* Role badges */
.role-badge-partner  { background: #7c3aed; color: #fff; }
.role-badge-manager  { background: #2563eb; color: #fff; }
.role-badge-senior   { background: #0891b2; color: #fff; }
.role-badge-junior   { background: #10b981; color: #fff; }
.role-badge-auditor  { background: #d97706; color: #fff; }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }

/* Email config section */
.email-provider-option {
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 10px;
}
.email-provider-option:hover { border-color: #3b82f6; }
.email-provider-option.selected { border-color: #3b82f6; background: #eff6ff; }

/* Bulk upload zone */
.bulk-upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f9fafb;
}
.bulk-upload-zone:hover, .bulk-upload-zone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}
.bulk-upload-zone .upload-icon { font-size: 48px; margin-bottom: 12px; }

/* Badge connected */
.badge-connected { background: #d1fae5; color: #065f46; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-not-connected { background: #f3f4f6; color: #6b7280; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* p-4 utility */
.p-4 { padding: 16px; }

/* ══════════════════════════════════════════════════════════════════════════
   BRANDING & THEME SETTINGS
══════════════════════════════════════════════════════════════════════════ */

/* Color swatches */
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.color-swatch:hover {
  transform: scale(1.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.color-swatch.active {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

/* Theme cards */
.theme-card {
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.theme-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.theme-card.active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Branding logo preview */
#brandingLogoPreview {
  transition: border-color 0.18s;
}
#brandingLogoPreview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* ── AI Feature Styles ──────────────────────────────────────────────────────── */
.ai-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.ai-menu-item:hover {
  background: var(--surface-2);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.ai-badge-active {
  background: rgba(99,102,241,0.12);
  color: #6366f1;
  border: 1px solid rgba(99,102,241,0.3);
}
.ai-badge-inactive {
  background: rgba(245,158,11,0.12);
  color: #d97706;
  border: 1px solid rgba(245,158,11,0.3);
}

/* AI result panels */
.ai-result-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.6;
}
.ai-result-card h4 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.ai-result-card p {
  margin: 0 0 6px;
  color: var(--text-secondary);
}

/* AI severity badges */
.ai-severity-high   { color: #ef4444; font-weight: 700; }
.ai-severity-medium { color: #f59e0b; font-weight: 700; }
.ai-severity-low    { color: #10b981; font-weight: 700; }

/* AI priority labels */
.ai-priority-high   { background: rgba(239,68,68,0.1);   color: #ef4444; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.ai-priority-medium { background: rgba(245,158,11,0.1);  color: #d97706; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.ai-priority-low    { background: rgba(16,185,129,0.1);  color: #059669; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }

/* AI loading pulse */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.ai-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* AI task card */
.ai-task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #6366f1;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.ai-task-card .task-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.ai-task-card .task-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* AI query result table */
.ai-query-results {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}
.ai-query-summary {
  padding: 10px 14px;
  background: rgba(99,102,241,0.08);
  border-bottom: 1px solid var(--border);
  color: #6366f1;
  font-weight: 600;
  font-size: 13px;
}
