/* ═══════════════════════════════════════════════════════════════════
   1BT Business Intel — Premium Design System
   ═══════════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────────────────────────── */

:root {
  /* Colors */
  --color-bg: #f4f6fa;
  --color-surface: #ffffff;
  --color-sidebar: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-active: #2563eb;
  --color-header: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-subtle: #eff6ff;
  --color-accent: #f59e0b;
  --color-accent-subtle: #fffbeb;
  --color-success: #059669;
  --color-success-subtle: #ecfdf5;
  --color-danger: #dc2626;
  --color-danger-subtle: #fef2f2;
  --color-warning: #d97706;
  --color-warning-subtle: #fffbeb;
  --color-info: #0284c7;
  --color-info-subtle: #f0f9ff;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-tertiary: #94a3b8;
  --color-text-inverse: #ffffff;
  --color-border: #e2e8f0;
  --color-border-focus: #2563eb;
  --color-overlay: rgba(15, 23, 42, 0.5);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radii */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px rgba(15, 23, 42, 0.10), 0 8px 10px rgba(15, 23, 42, 0.04);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
}

/* ─── Reset & Base ──────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background: var(--color-bg);
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-hover); }

img { max-width: 100%; display: block; }

/* ─── Focus Styles ──────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Login Page ────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: var(--space-4);
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}

@media (max-height: 560px) {
  .login-page {
    align-items: flex-start;
  }
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(245, 158, 11, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.login-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  box-shadow: var(--shadow-xl);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-brand-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  font-size: 1.5rem;
  color: white;
}

.login-brand h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.login-brand p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.login-form { display: flex; flex-direction: column; gap: var(--space-5); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.form-input {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

.form-input::placeholder { color: var(--color-text-tertiary); }

.form-input:hover { border-color: #cbd5e1; }

.form-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.form-input.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  min-height: 1.25em;
}

/* ─── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border-color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-4) var(--space-6); font-size: var(--text-base); }
.btn-full { width: 100%; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ─── Login Button Spinner ──────────────────────────────────── */

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn.loading .btn-spinner { display: inline-block; }
.btn.loading .btn-text { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── App Layout ────────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform var(--transition-slow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--header-height);
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-brand-text {
  color: var(--color-text-inverse);
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3);
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: #94a3b8;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
}

.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active {
  background: rgba(37, 99, 235, 0.15);
  color: #93c5fd;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: #94a3b8;
  font-size: var(--text-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

/* ─── Main Content ──────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-header {
  height: var(--header-height);
  background: var(--color-header);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: 30;
}

.main-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.main-body {
  flex: 1;
  padding: var(--space-8);
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Hamburger ─────────────────────────────────────────────── */

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--color-text-primary);
}

/* ─── Cards ─────────────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
}

.card-body {
  padding: var(--space-6);
}

.card-body-compact {
  padding: var(--space-4) var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: #f8fafc;
}

/* ─── Stat Cards ────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: box-shadow var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--color-primary-subtle); }
.stat-icon.amber { background: var(--color-accent-subtle); }
.stat-icon.green { background: var(--color-success-subtle); }
.stat-icon.red { background: var(--color-danger-subtle); }
.stat-icon.purple { background: #f3e8ff; }
.stat-icon.cyan { background: var(--color-info-subtle); }

.stat-content { flex: 1; min-width: 0; }

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.1;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

/* ─── Tables ────────────────────────────────────────────────── */

.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead th {
  background: #f8fafc;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  cursor: default;
}

.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .cell-truncate {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .cell-url {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}

/* ─── Badges ────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-green { background: var(--color-success-subtle); color: var(--color-success); }
.badge-amber { background: var(--color-warning-subtle); color: var(--color-warning); }
.badge-red { background: var(--color-danger-subtle); color: var(--color-danger); }
.badge-blue { background: var(--color-primary-subtle); color: var(--color-primary); }
.badge-gray { background: #f1f5f9; color: var(--color-text-secondary); }

/* ─── Verdicts ──────────────────────────────────────────────── */

.verdict-contact-now { color: var(--color-success); font-weight: 600; }
.verdict-verify-first { color: var(--color-warning); font-weight: 600; }
.verdict-watch-list { color: var(--color-info); font-weight: 600; }
.verdict-park { color: var(--color-text-tertiary); font-weight: 500; }

/* ─── Score Circle ──────────────────────────────────────────── */

.score-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: var(--text-sm);
  font-weight: 700;
  border: 2px solid;
}

.score-high { color: var(--color-success); border-color: var(--color-success); }
.score-medium { color: var(--color-warning); border-color: var(--color-warning); }
.score-low { color: var(--color-text-tertiary); border-color: var(--color-border); }

/* ─── Modal ─────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--space-4);
  animation: fadeIn 150ms ease-out;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 200ms ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-tertiary);
  transition: all var(--transition-fast);
  font-size: 1.2rem;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--color-text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Empty State ───────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 400px;
  margin: 0 auto var(--space-6);
}

/* ─── Loading ───────────────────────────────────────────────── */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  gap: var(--space-4);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-state p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* ─── Toast / Alert ─────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 200ms ease-out;
}

.toast-success { background: var(--color-success-subtle); color: var(--color-success); border: 1px solid #a7f3d0; }
.toast-error { background: var(--color-danger-subtle); color: var(--color-danger); border: 1px solid #fecaca; }
.toast-info { background: var(--color-info-subtle); color: var(--color-info); border: 1px solid #bae6fd; }

@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Detail View ───────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.detail-field.full-width {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  line-height: var(--leading-relaxed);
  word-break: break-word;
}

.detail-value.excerpt {
  background: #f8fafc;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  max-height: 120px;
  overflow-y: auto;
}

/* ─── Source Status ─────────────────────────────────────────── */

.source-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.source-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: box-shadow var(--transition-fast);
}

.source-item:hover {
  box-shadow: var(--shadow-sm);
}

.source-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-status-dot.online { background: var(--color-success); }
.source-status-dot.offline { background: var(--color-danger); }
.source-status-dot.unknown { background: var(--color-text-tertiary); }

.source-info { flex: 1; min-width: 0; }

.source-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.source-url {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* ─── Agent Interaction ─────────────────────────────────────── */

.agent-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.agent-input-area {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.agent-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 44px;
  max-height: 120px;
  transition: border-color var(--transition-fast);
}

.agent-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.agent-result {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* ─── Responsive ────────────────────────────────────────────── */

@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .main-body { padding: var(--space-6); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-overlay);
    z-index: 35;
    animation: fadeIn 200ms ease-out;
  }

  .main-content {
    margin-left: 0;
  }

  .main-header {
    padding: 0 var(--space-4);
  }

  .main-body {
    padding: var(--space-4);
  }

  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }

  .stat-card {
    padding: var(--space-4);
  }

  .stat-value {
    font-size: var(--text-xl);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .header-user-badge .user-name {
    display: none;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .main-body {
    padding: var(--space-3);
  }

  .card-body {
    padding: var(--space-4);
  }

  .login-card {
    padding: var(--space-6);
  }

  .data-table thead th,
  .data-table tbody td {
    padding: var(--space-2) var(--space-3);
  }

  .modal {
    border-radius: var(--radius-lg);
    max-height: 90vh;
  }
}

@media (max-width: 360px) {
  .login-card {
    padding: var(--space-5);
  }

  .stat-card {
    padding: var(--space-3);
  }
}

/* ─── Utility ───────────────────────────────────────────────── */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.font-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ─── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Tab Bar ───────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
  gap: 0;
  overflow-x: auto;
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--color-text-primary);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Hardened local UI additions ───────────────────────────── */

[hidden] { display: none !important; }

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.app-layout,
.main-content,
.main-body,
.card,
.card-body,
.card-body-compact,
.table-card-body {
  min-width: 0;
}

.main-content { width: calc(100% - var(--sidebar-width)); }

.main-header h1,
.card-header h2,
.modal-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.sidebar-section-spaced { margin-top: var(--space-4); }

.sidebar-user-name {
  color: #e2e8f0;
  font-weight: 500;
}

.sidebar-signout {
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: #94a3b8;
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.sidebar-signout:hover { color: #e2e8f0; }

.sidebar-overlay {
  border: 0;
  cursor: pointer;
}

.dashboard-card { margin-top: var(--space-6); }

.table-card-body {
  width: 100%;
  overflow: hidden;
}

.table-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.data-table { min-width: 920px; }

.table-link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-primary);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.table-link-button:hover { color: var(--color-primary-hover); }

.safe-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.invalid-link { color: var(--color-danger); }

.notes-input { width: 100%; }

.notes-actions,
.agent-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.agent-input-area { display: block; }

.agent-result {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.result-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.fit-preview-warning {
  padding: var(--space-4);
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  background: var(--color-warning-subtle);
  color: #92400e;
}

.text-danger { color: var(--color-danger); }

.about-list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-left: var(--space-5);
}

.modal-open { overflow: hidden; }

@media (max-width: 768px) {
  .main-content { width: 100%; }

  .card-header-responsive {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-4);
  }

  .card-header-responsive .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
