/* ============================================
   STRINGER - Modern Mobile-First CSS
   ============================================ */

:root {
  /* Colors */
  --fg: #0f172a;
  --muted: #64748b;
  --text-muted: #64748b;
  --line: #e2e8f0;
  --link: #2563eb;
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --primary: #3b82f6;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;

  /* Shadows */
  --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 -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Border radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

/* Dark mode variables - applied via data-theme attribute */
:root[data-theme="dark"] {
  --fg: #f1f5f9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --text-muted: #94a3b8;
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --border: #334155;
  --line: #334155;
  --link: #60a5fa;
  --primary: #60a5fa;
  --primary-light: #1e3a5f;
  --primary-dark: #93c5fd;
  --success: #34d399;
  --success-light: #064e3b;
  --danger: #f87171;
  --danger-light: #450a0a;
  --warning: #fbbf24;
  --warning-light: #451a03;
  --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 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
}

/* Fallback for system preference when no explicit theme set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --fg: #f1f5f9;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --text-muted: #94a3b8;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --border: #334155;
    --line: #334155;
    --link: #60a5fa;
    --primary: #60a5fa;
    --primary-light: #1e3a5f;
    --primary-dark: #93c5fd;
    --success: #34d399;
    --success-light: #064e3b;
    --danger: #f87171;
    --danger-light: #450a0a;
    --warning: #fbbf24;
    --warning-light: #451a03;
    --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 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
  }
}

/* Dark mode component overrides */
[data-theme="dark"] .form-control {
  background-color: var(--bg-secondary);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
}

/* Dark mode alerts */
[data-theme="dark"] .alert-success { background: var(--success-light); color: #6ee7b7; border-color: #065f46; }
[data-theme="dark"] .alert-error { background: var(--danger-light); color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .alert-warning { background: var(--warning-light); color: #fcd34d; border-color: #78350f; }
[data-theme="dark"] .alert-info { background: var(--primary-light); color: #93c5fd; border-color: #1e3a5f; }

/* Dark mode badges */
[data-theme="dark"] .badge-success { background: var(--success-light); color: #6ee7b7; }
[data-theme="dark"] .badge-danger { background: var(--danger-light); color: #fca5a5; }
[data-theme="dark"] .badge-warning { background: var(--warning-light); color: #fcd34d; }
[data-theme="dark"] .badge-info { background: var(--primary-light); color: #93c5fd; }

/* Dark mode empty state */
[data-theme="dark"] .empty-state { background: var(--bg-secondary); border-color: var(--border); }

/* Dark mode dropdown */
[data-theme="dark"] .user-dropdown-trigger { background: var(--bg-secondary); border-color: var(--border); }
[data-theme="dark"] .user-dropdown-menu { background: var(--bg-secondary); border-color: var(--border); }
[data-theme="dark"] .dropdown-header { background: var(--bg-tertiary); }
[data-theme="dark"] .dropdown-item:hover { background: var(--bg-tertiary); }

/* Dark mode persona cards */
[data-theme="dark"] .persona-card { background: var(--bg-secondary); border-color: var(--border); }
[data-theme="dark"] .persona-card:hover { background: var(--bg-tertiary); border-color: var(--primary); }
[data-theme="dark"] .persona-card.selected { background: var(--primary-light); border-color: var(--primary); }

/* Dark mode buttons */
[data-theme="dark"] .btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border);
  color: var(--fg);
}
[data-theme="dark"] .btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--muted);
}
[data-theme="dark"] .btn-danger-outline {
  background: transparent;
  border-color: #7f1d1d;
  color: var(--danger);
}
[data-theme="dark"] .btn-danger-outline:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* Dark mode cards and tables */
[data-theme="dark"] .stat-card,
[data-theme="dark"] .card,
[data-theme="dark"] .intel-card {
  background: var(--bg-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .card-header {
  background: var(--bg-tertiary);
}
[data-theme="dark"] .table-responsive {
  background: var(--bg-secondary);
}
[data-theme="dark"] th {
  background: var(--bg-tertiary);
}
[data-theme="dark"] tbody tr:hover {
  background: var(--bg-tertiary);
}
[data-theme="dark"] header {
  background: var(--bg-secondary);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .modal,
[data-theme="dark"] .modal-content {
  background: var(--bg-secondary);
}
[data-theme="dark"] .message-body {
  background: var(--bg-secondary);
  border-color: var(--border);
}
[data-theme="dark"] pre,
[data-theme="dark"] code {
  background: var(--bg-tertiary);
}
[data-theme="dark"] .nav-admin:hover {
  background: rgba(234, 88, 12, 0.15) !important;
}
[data-theme="dark"] .provider-btn-gmail:hover { background: rgba(66, 133, 244, 0.15); }
[data-theme="dark"] .provider-btn-outlook:hover { background: rgba(0, 120, 212, 0.15); }
[data-theme="dark"] .provider-btn-icloud:hover { background: rgba(21, 126, 251, 0.15); }
[data-theme="dark"] .provider-btn-yahoo:hover { background: rgba(96, 1, 210, 0.15); }

/* Dark mode bot score badges */
[data-theme="dark"] .badge-bot-high { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-bot-medium { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-bot-low { background: #064e3b; color: #6ee7b7; }

/* Dark mode skeleton loader */
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, #475569 50%, var(--bg-tertiary) 75%);
}

/* ============================================
   BASE STYLES
   ============================================ */

* { box-sizing: border-box; }

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  z-index: 1001;
  transition: top 0.2s;
  text-decoration: none;
  font-weight: 500;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  top: 0;
  text-decoration: none;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: clamp(14px, 2vw + 4px, 15px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

/* ============================================
   FOCUS STYLES (Accessibility)
   ============================================ */

/* Remove default focus outline, use focus-visible */
:focus {
  outline: none;
}

/* Visible focus ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Enhanced focus for buttons */
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Enhanced focus for form controls */
.form-control:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Focus for dropdown items */
.dropdown-item:focus-visible {
  background: var(--bg-secondary);
  outline: none;
  box-shadow: inset 2px 0 0 var(--primary);
}

/* Focus for cards */
.persona-card:focus-visible,
.reply-style-option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Modal close button focus */
.modal-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

/* Checkbox focus */
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */

header {
  background: linear-gradient(to bottom, #ffffff, #fafafa);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--fg);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand:hover {
  text-decoration: none;
  color: var(--primary);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-sm);
  cursor: pointer;
  color: var(--fg);
  border-radius: var(--radius);
  transition: background var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-secondary);
}

.menu-toggle svg {
  display: block;
  width: 24px;
  height: 24px;
}

/* Desktop nav */
nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

nav a:hover {
  color: var(--fg);
  background: var(--bg-secondary);
  text-decoration: none;
}

nav a.active {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-admin {
  color: #ea580c !important;
}

.nav-admin:hover {
  background: #fff7ed !important;
}

/* Header user section */
.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.user-dropdown-trigger:hover {
  background: var(--bg-secondary);
  border-color: var(--muted);
  box-shadow: var(--shadow);
}

.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-arrow {
  transition: transform var(--transition-fast);
  opacity: 0.6;
}

.user-dropdown:has(.user-dropdown-menu.show) .dropdown-arrow {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-sm));
  right: 0;
  min-width: 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  overflow: hidden;
  animation: dropdown-fade-in 0.15s ease-out;
}

.user-dropdown-menu.show {
  display: block;
}

@keyframes dropdown-fade-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.dropdown-user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}

.dropdown-user-email {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-xs) 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover {
  background: var(--bg-secondary);
  text-decoration: none;
}

.dropdown-item svg {
  color: var(--muted);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.dropdown-item-admin {
  color: #ea580c;
}

.dropdown-item-admin svg {
  color: #ea580c;
}

.dropdown-item-logout {
  color: var(--danger);
}

.dropdown-item-logout svg {
  color: var(--danger);
}

.dropdown-logout-form {
  margin: 0;
}

/* ============================================
   LAYOUT
   ============================================ */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
  min-height: calc(100vh - 200px);
}

footer {
  max-width: 1200px;
  margin: var(--space-lg) auto;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3 {
  margin: 0 0 var(--space-md);
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg);
}

h1 { font-size: clamp(20px, 4vw + 10px, 26px); letter-spacing: -0.5px; }
h2 { font-size: clamp(16px, 3vw + 8px, 20px); }
h3 { font-size: clamp(14px, 2vw + 6px, 16px); }

pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
}

/* ============================================
   BREADCRUMBS
   ============================================ */

.breadcrumb {
  margin-bottom: var(--space-md);
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.breadcrumb a {
  color: var(--link);
}

.breadcrumb-sep {
  color: var(--muted);
  opacity: 0.5;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
  min-height: 40px;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 32px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 12px;
  min-height: 26px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--muted);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: var(--shadow-md);
}

.btn-danger-outline {
  background: var(--bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger-outline:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: var(--shadow-md);
}

.btn-purple {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-purple:hover {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  box-shadow: var(--shadow-md);
}

/* ============================================
   BUTTON LOADING STATE
   ============================================ */

.btn--loading {
  pointer-events: none;
  color: transparent !important;
  position: relative;
}

.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

.btn-primary.btn--loading::after,
.btn-danger.btn--loading::after,
.btn-success.btn--loading::after,
.btn-purple.btn--loading::after {
  border-color: white;
  border-right-color: transparent;
}

@keyframes btn-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ============================================
   SKELETON LOADERS
   ============================================ */

.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 75%;
}

.skeleton-heading {
  height: 1.5em;
  width: 60%;
  margin-bottom: 1em;
}

.skeleton-card {
  height: 100px;
  margin-bottom: var(--space-md);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-btn {
  height: 40px;
  width: 100px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.card-body {
  padding: var(--space-md);
}

/* ============================================
   TABLES
   ============================================ */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

td {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--bg-secondary);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Mobile table: Card-based layout */
@media (max-width: 768px) {
  .table-responsive--cards table,
  .table-responsive--cards thead,
  .table-responsive--cards tbody,
  .table-responsive--cards th,
  .table-responsive--cards td,
  .table-responsive--cards tr {
    display: block;
  }

  .table-responsive--cards thead {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  .table-responsive--cards tbody tr {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm);
  }

  .table-responsive--cards tbody tr:hover {
    background: var(--bg);
  }

  .table-responsive--cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border: none;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }

  .table-responsive--cards td:last-child {
    border-bottom: none;
  }

  .table-responsive--cards td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    flex-shrink: 0;
    margin-right: var(--space-md);
    text-align: left;
  }

  /* Hide low-priority columns on mobile */
  .table-responsive--cards .col-hide-mobile {
    display: none;
  }

  /* Full-width action buttons */
  .table-responsive--cards td.td-actions {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
    padding-top: var(--space-md);
  }

  .table-responsive--cards td.td-actions::before {
    display: none;
  }

  .table-responsive--cards td.td-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .table-responsive--cards td.td-actions form {
    width: 100%;
  }

  .table-responsive--cards td.td-actions form .btn {
    width: 100%;
  }
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success {
  background: var(--success-light);
  color: #065f46;
}

.badge-danger {
  background: var(--danger-light);
  color: #991b1b;
}

.badge-warning {
  background: var(--warning-light);
  color: #92400e;
}

.badge-info {
  background: var(--primary-light);
  color: #1e40af;
}

.badge-status {
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
}

.badge-stung {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  box-shadow: var(--shadow-sm);
}

/* Solid badge variants */
.badge-success-solid { background: var(--success); color: white; }
.badge-danger-solid { background: var(--danger); color: white; }
.badge-primary-solid { background: var(--primary); color: white; }
.badge-muted { background: var(--bg-tertiary); color: var(--muted); }

/* Bot score badges */
.badge-bot-high,
.badge-bot-medium,
.badge-bot-low {
  margin-left: 4px;
  font-size: 10px;
  border: none;
}
.badge-bot-high { background: #fee2e2; color: #991b1b; }
.badge-bot-medium { background: #fef3c7; color: #92400e; }
.badge-bot-low { background: #d1fae5; color: #065f46; }

/* ============================================
   COLOR UTILITIES
   ============================================ */

.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--muted); }

.bg-danger-light { background: var(--danger-light); }
.bg-warning-light { background: var(--warning-light); }
.bg-success-light { background: var(--success-light); }
.bg-primary-light { background: var(--primary-light); }

/* ============================================
   BUTTON VARIANTS
   ============================================ */

.btn-warning-solid { background: var(--warning); color: #78350f; }
.btn-warning-solid:hover { background: #d97706; }
.btn-purple-solid { background: #8b5cf6; color: white; }
.btn-purple-solid:hover { background: #7c3aed; }
.btn-limit-danger { background: #fff; color: #991b1b; }
.btn-limit-danger:hover { background: #fef2f2; }
.btn-limit-warning { background: #fff; color: #92400e; }
.btn-limit-warning:hover { background: #fffbeb; }

/* ============================================
   SPACING & DISPLAY UTILITIES
   ============================================ */

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.m-0 { margin: 0; }
.ml-sm { margin-left: var(--space-sm); }
.ml-md { margin-left: var(--space-md); }
.mr-sm { margin-right: var(--space-sm); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: 'SF Mono', Monaco, monospace; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-bold { font-weight: 600; }
.italic { font-style: italic; }
.break-all { word-break: break-all; }
.text-white { color: white; }
.bg-light { background: var(--bg-secondary); }
.border-top { border-top: 1px solid var(--border); }

/* ============================================
   FORMS
   ============================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-control {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: all var(--transition-fast);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Form validation error state */
.form-control--error,
.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control--error:focus,
.form-control.is-invalid:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Form success state */
.form-control--success,
.form-control.is-valid {
  border-color: var(--success);
}

.form-control--success:focus,
.form-control.is-valid:focus {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Form error message */
.form-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: var(--space-xs);
  display: none;
  align-items: center;
  gap: var(--space-xs);
}

.form-error::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  flex-shrink: 0;
}

.form-error.show,
.form-group.has-error .form-error {
  display: flex;
}

/* Form group error state */
.form-group.has-error .form-control {
  border-color: var(--danger);
}

.form-group.has-error label {
  color: var(--danger);
}

.form-control::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.form-inline {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--space-xs);
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: var(--space-sm);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-hint {
  font-size: 12px;
  color: var(--muted);
  margin-left: 26px;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
}

.alert-success {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background: var(--primary-light);
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ============================================
   STAT CARDS
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: clamp(20px, 5vw + 8px, 28px);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  margin-bottom: var(--space-lg);
}

.page-header h1 {
  margin: 0 0 var(--space-md);
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.page-header-row h1 {
  margin: 0;
}

.header-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* Refresh button */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.refresh-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.3s ease;
}

.refresh-btn:hover .refresh-icon {
  transform: rotate(180deg);
}

@media (max-width: 480px) {
  .page-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions .btn {
    flex: 1;
  }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  color: var(--muted);
}

.empty-state h3 {
  color: var(--text);
  margin-bottom: var(--space-sm);
}

/* ============================================
   UTILITIES
   ============================================ */

.meta { color: var(--muted); font-size: 14px; }
.actions a { margin-right: var(--space-sm); }
.hint { color: var(--muted); font-size: 12px; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ============================================
   CONVERSATION DETAIL
   ============================================ */

.convo-header {
  margin-bottom: var(--space-lg);
}

.convo-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.convo-header-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.convo-title {
  margin: 0;
  font-size: 22px;
}

.convo-badges {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

/* Conversation Meta Grid */
.convo-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  background: var(--bg-secondary);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.meta-item-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.meta-item-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.meta-item-value.large {
  font-size: 24px;
  font-weight: 700;
}

/* ============================================
   MESSAGE THREAD
   ============================================ */

.thread-container {
  max-width: 100%;
  margin: var(--space-lg) 0;
}

.message-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.message-card:hover {
  box-shadow: var(--shadow);
}

.message-card.inbound {
  border-left: 4px solid var(--success);
  margin-right: 0;
}

.message-card.outbound {
  border-left: 4px solid var(--primary);
  margin-left: 0;
  background: var(--bg-secondary);
}

@media (min-width: 768px) {
  .message-card.inbound { margin-right: 48px; }
  .message-card.outbound { margin-left: 48px; }
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.message-meta {
  font-size: 13px;
  color: var(--muted);
}

.message-direction {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.message-direction.inbound {
  background: var(--success);
  color: white;
}

.message-direction.outbound {
  background: var(--primary);
  color: white;
}

.message-from-to {
  margin: var(--space-xs) 0;
  font-size: 13px;
  color: var(--muted);
}

.message-body {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.message-card.outbound .message-body {
  background: var(--bg);
}

.message-body-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  max-height: 500px;
  overflow-y: auto;
}

.message-body-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.message-actions {
  margin-top: var(--space-md);
  font-size: 13px;
}

.message-actions a {
  margin-right: var(--space-md);
}

.message-id {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

/* ============================================
   SETTINGS PAGES
   ============================================ */

.settings-container {
  max-width: 800px;
  margin: 0 auto;
}

.settings-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  background: var(--bg);
}

.settings-fieldset legend {
  font-weight: 600;
  padding: 0 var(--space-sm);
  font-size: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
}

.settings-hint {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-secondary);
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-top: var(--space-md);
}

.settings-page-container {
  max-width: 800px;
  margin: 0 auto;
}

.settings-page-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 2px solid var(--line);
}

.settings-page-header h1 {
  margin: 0 0 var(--space-sm);
}

.settings-info {
  color: var(--muted);
  font-size: 14px;
}

/* Form Sections */
.form-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.form-section h2 {
  margin: 0 0 var(--space-md);
  font-size: 18px;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
}

.form-section .form-group:last-child {
  margin-bottom: 0;
}

.form-section input[type="text"],
.form-section input[type="number"],
.form-section input[type="password"],
.form-section input[type="email"],
.form-section select,
.form-section textarea {
  width: 100%;
}

/* ============================================
   PERSONA SELECTOR
   ============================================ */

.persona-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.persona-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.persona-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.persona-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow);
}

.persona-card input[type="radio"] {
  margin-right: var(--space-sm);
}

.persona-name {
  font-weight: 600;
  color: var(--fg);
  margin-bottom: var(--space-xs);
}

.persona-description {
  font-size: 12px;
  color: var(--muted);
}

.custom-prompt-section {
  display: none;
}

.custom-prompt-section.visible {
  display: block;
}

/* ============================================
   BUTTON GROUPS
   ============================================ */

.button-group {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

/* ============================================
   PROVIDER BUTTONS
   ============================================ */

.provider-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--bg);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  text-decoration: none;
  font-weight: 600;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.provider-btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.provider-btn-gmail {
  border: 2px solid #4285f4;
  color: #4285f4;
}

.provider-btn-gmail:hover {
  background: #e8f0fe;
}

.provider-btn-outlook {
  border: 2px solid #0078d4;
  color: #0078d4;
}

.provider-btn-outlook:hover {
  background: #e5f1fb;
}

.provider-btn-icloud {
  border: 2px solid #157efb;
  color: #157efb;
}

.provider-btn-icloud:hover {
  background: #e8f4ff;
}

.provider-btn-yahoo {
  border: 2px solid #6001d2;
  color: #6001d2;
}

.provider-btn-yahoo:hover {
  background: #f3e8ff;
}

.provider-btn-imap {
  border: 2px solid var(--border);
  color: var(--text);
}

.provider-btn-imap:hover {
  border-color: var(--muted);
  background: var(--bg-secondary);
}

/* ============================================
   BULK ACTIONS
   ============================================ */

.bulk-actions {
  display: none;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.bulk-actions.visible {
  display: flex;
}

/* ============================================
   PAGINATION
   ============================================ */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-lg);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--line);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.pagination-info {
  color: var(--muted);
  font-size: 14px;
}

.pagination-controls {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

.pagination-controls .btn {
  min-width: 40px;
}

.pagination-controls .btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 14px;
  color: var(--muted);
}

.pagination-size select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  cursor: pointer;
}

/* ============================================
   CONVERSATIONS TABLE
   ============================================ */

.convo-table {
  width: 100%;
}

.convo-table tbody tr.convo-row:hover {
  background: var(--bg-secondary);
}

/* ============================================
   PROVIDER INFO
   ============================================ */

.provider-info {
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.server-config {
  font-size: 13px;
}

.folder-config {
  font-size: 12px;
  color: var(--muted);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: toast-slide-in 0.3s ease-out;
  max-width: 380px;
  border: 1px solid var(--border);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}

.toast-message {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--fg);
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  /* Show mobile menu toggle */
  .menu-toggle {
    display: block;
    order: -1;
  }

  /* Hide desktop nav by default */
  nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    flex-direction: column;
    align-items: stretch;
    padding: 80px var(--space-lg) var(--space-lg);
    z-index: 99;
    overflow-y: auto;
    gap: var(--space-xs);
  }

  nav.open {
    display: flex;
  }

  nav a {
    padding: var(--space-md);
    font-size: 16px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    text-align: center;
  }

  .header-inner {
    padding: var(--space-md);
  }

  .brand {
    flex: 1;
    justify-content: center;
  }

  .user-dropdown {
    order: 1;
  }

  .user-dropdown-trigger {
    padding: var(--space-sm);
  }

  .user-name {
    display: none;
  }

  /* Layout */
  main {
    padding: var(--space-md);
  }

  footer {
    padding: var(--space-md);
  }

  /* Typography */
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  /* Stats Grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .stat-card {
    padding: var(--space-md);
  }

  .stat-value {
    font-size: 22px;
  }

  /* Conversation Detail */
  .convo-header-top {
    flex-direction: column;
    align-items: stretch;
  }

  .convo-header-actions {
    flex-wrap: wrap;
  }

  .convo-header-actions .btn {
    flex: 1;
    min-width: 45%;
  }

  .convo-meta {
    grid-template-columns: repeat(2, 1fr);
    padding: var(--space-md);
  }

  .meta-item-value.large {
    font-size: 20px;
  }

  /* Message Thread */
  .message-card {
    padding: var(--space-md);
  }

  .message-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Buttons */
  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
  }

  /* Tables */
  .table-responsive table {
    min-width: 500px;
  }

  th, td {
    padding: var(--space-sm) var(--space-md);
    font-size: 13px;
  }

  /* Forms */
  .form-section {
    padding: var(--space-md);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  /* Provider buttons */
  .provider-buttons {
    grid-template-columns: 1fr;
  }

  /* Bulk actions */
  .bulk-actions.visible {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-actions .btn {
    width: 100%;
  }

  /* Toast - center on mobile */
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }

  .toast {
    max-width: 100%;
  }

  /* Dropdown on mobile - slides up from bottom */
  .user-dropdown-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1001;
    animation: dropdown-slide-up 0.25s ease-out;
  }

  .user-dropdown-menu.show::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
  }

  .dropdown-item {
    padding: var(--space-lg) var(--space-md);
    font-size: 16px;
    min-height: 56px;
    display: flex;
    align-items: center;
  }

  .dropdown-header {
    padding: var(--space-lg) var(--space-md);
  }
}

@keyframes dropdown-slide-up {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  /* Even smaller adjustments */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .stat-label {
    margin-bottom: 0;
  }

  .convo-meta {
    grid-template-columns: 1fr;
  }

  .persona-selector {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .pagination-controls {
    justify-content: center;
  }
}

/* ============================================
   RICKROLL & SPECIAL MESSAGES
   ============================================ */

.rickroll-victory,
.rickroll-armed,
.rickroll-trigger {
  margin-top: var(--space-md);
}

/* ============================================
   MODAL (for inline modals in templates)
   ============================================ */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease-out;
}

.modal-overlay.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal {
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-slide-up 0.3s ease-out;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  padding: var(--space-sm);
  margin: calc(var(--space-sm) * -1);
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--fg);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .modal-overlay.show {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }
}
