/* ============================================================
   MotherBeast Dashboard — Claude Code Inspired Design System
   Warm terracotta on dark brown, cream text, monospace data
   ============================================================ */

/* --- CSS Variables ---------------------------------------- */
:root {
  --bg-primary: #1a1815;
  --bg-secondary: #201d18;
  --bg-tertiary: #2a2520;
  --bg-input: #151310;
  --bg-hover: #302b25;

  --text-primary: #e8e6e3;
  --text-secondary: #C4A584;
  --text-muted: #9e9488;
  --text-inverse: #1a1815;

  --accent: #C15F3C;
  --accent-hover: #D97757;
  --accent-muted: rgba(193, 95, 60, 0.15);
  --accent-glow: rgba(193, 95, 60, 0.3);

  --success: #98C379;
  --success-bg: rgba(152, 195, 121, 0.12);
  --warning: #E67D22;
  --warning-bg: rgba(230, 125, 34, 0.12);
  --danger: #ff6b6b;
  --danger-bg: rgba(255, 107, 107, 0.12);
  --info: #61AFEF;
  --info-bg: rgba(97, 175, 239, 0.12);

  --border: #2a2520;
  --border-hover: #3a3530;
  --border-accent: #C15F3C;

  --priority-critical: #ff4444;
  --priority-high: #E67D22;
  --priority-medium: #f0c040;
  --priority-low: #98C379;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 4px 20px rgba(193, 95, 60, 0.12);
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* --- Reset & Base ---------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

/* --- Layout ---------------------------------------------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --- Sidebar Search ---------------------------------------- */
.sidebar-search {
  padding: 8px 14px 4px;
}
.sidebar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-search-icon {
  position: absolute;
  left: 8px;
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar-search-input {
  width: 100%;
  padding: 6px 10px 6px 28px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: var(--font-main);
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-search-input::placeholder {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.sidebar-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.sidebar-nav {
  flex: 1;
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover, .sidebar-nav a:focus-visible {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-muted);
  border-left-color: var(--accent);
}

.sidebar-nav .nav-icon {
  width: 24px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.main {
  flex: 1;
  margin-left: 220px;
  padding: 28px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* --- Cards ----------------------------------------------- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.card-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.2;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* Stat cards grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
}

.stat-card .stat-icon {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --- Progress Bar ---------------------------------------- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar .progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Stacked status bar */
.status-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.status-bar .seg-completed { background: var(--success); }
.status-bar .seg-pending { background: var(--warning); }
.status-bar .seg-error { background: var(--danger); }
.status-bar .seg-skipped { background: var(--text-muted); }

/* --- Priority & Flag Badges ----------------------------- */
.priority-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.priority-dot.critical { background: var(--priority-critical); box-shadow: 0 0 6px var(--priority-critical); }
.priority-dot.high { background: var(--priority-high); }
.priority-dot.medium { background: var(--priority-medium); }
.priority-dot.low { background: var(--priority-low); }

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.priority-badge.critical { background: rgba(255, 68, 68, 0.15); color: var(--priority-critical); }
.priority-badge.high { background: rgba(230, 125, 34, 0.15); color: var(--priority-high); }
.priority-badge.medium { background: rgba(240, 192, 64, 0.15); color: var(--priority-medium); }
.priority-badge.low { background: rgba(152, 195, 121, 0.15); color: var(--priority-low); }

.flag-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.flag-pill.no-id { background: rgba(255, 68, 68, 0.2); color: var(--danger); }
.flag-pill.old-id { background: rgba(230, 125, 34, 0.2); color: var(--warning); }
.flag-pill.foreign { background: rgba(97, 175, 239, 0.2); color: var(--info); }
.flag-pill.company { background: rgba(196, 165, 132, 0.2); color: var(--text-secondary); }
.flag-pill.early { background: rgba(180, 130, 255, 0.2); color: #b482ff; }

/* Lead count badges (for dashboard) */
.lead-counts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.lead-count {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.lead-count .count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
}

.lead-count .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

/* --- Tables ---------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color var(--transition);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr.clickable {
  cursor: pointer;
}

tbody tr.clickable:hover {
  background: var(--bg-hover);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* --- Sortable Table Headers ------------------------------ */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

th.sortable:hover {
  color: var(--text-primary);
}

th.sortable.sort-active {
  color: var(--accent);
}

th.sortable .sort-label {
  margin-right: 2px;
}

th.sortable .sort-arrow {
  font-size: 0.65rem;
  color: var(--accent);
}

.cell-mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.cell-rtl {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.cell-score {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}

/* --- Forms & Inputs -------------------------------------- */
input, select, textarea {
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: border-color var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238a8078' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
}

/* --- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.2);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled, .btn.htmx-request {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

/* Button inline spinner (htmx loading) */
.btn .btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.htmx-request .btn-spinner,
.btn.loading .btn-spinner {
  display: inline-block;
}

.htmx-request .btn-label,
.btn.loading .btn-label {
  opacity: 0.7;
}

/* --- Tabs (Alpine.js) ------------------------------------ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-secondary);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Upload Zone ----------------------------------------- */
.upload-zone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover, .upload-zone-active {
  border-color: var(--accent);
  background: rgba(193, 95, 60, 0.08);
}

/* --- Toast Notifications --------------------------------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 3s forwards;
  box-shadow: var(--shadow-lg);
}

.toast.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(152, 195, 121, 0.3); }
.toast.error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(255, 107, 107, 0.3); }
.toast.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(230, 125, 34, 0.3); }
.toast.info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(97, 175, 239, 0.3); }

@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* --- Health Badge ---------------------------------------- */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.health-dot.valid { background: var(--success); box-shadow: 0 0 6px var(--success); }
.health-dot.expired { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* --- Extract Log ----------------------------------------- */
.extract-log {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  max-height: 400px;
  overflow-y: auto;
}

.extract-log .log-line {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.extract-log .log-line:last-child {
  border-bottom: none;
}

.extract-log .log-success { color: var(--success); }
.extract-log .log-error { color: var(--danger); }
.extract-log .log-warning { color: var(--accent); }
.extract-log .log-info { color: var(--text-muted); }

/* --- Keep/Deny Icon Buttons ------------------------------ */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  line-height: 1;
}

.btn-icon.btn-keep:hover {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(152, 195, 121, 0.4);
}

.btn-icon.btn-deny:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

/* --- Ownership Breakdown --------------------------------- */
.ownership-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ownership-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

.ownership-pill.private { background: rgba(193, 95, 60, 0.15); color: var(--accent); }
.ownership-pill.public { background: rgba(97, 175, 239, 0.15); color: var(--info); }
.ownership-pill.mixed { background: rgba(240, 192, 64, 0.15); color: var(--priority-medium); }
.ownership-pill.other { background: rgba(138, 128, 120, 0.15); color: var(--text-muted); }

/* --- Login Page ------------------------------------------ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 1.4rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 28px;
}

.login-card .error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.login-card input {
  margin-bottom: 16px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
}

/* --- Utility Classes ------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hidden { display: none !important; }

/* --- Loading / htmx indicator ---------------------------- */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Notes History --------------------------------------- */
.notes-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
}

.note-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.note-bullet {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
}

.note-text {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* --- Status Badges (lead detail) ------------------------- */
.status-badge {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-new { background: var(--info-bg); color: var(--info); }
.status-investigating { background: var(--success-bg); color: var(--success); }
.status-closed { background: rgba(180,130,255,0.15); color: #b482ff; }
.status-rejected { background: var(--danger-bg); color: var(--danger); }

/* --- Timeline (lead detail history) ---------------------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0;
  max-height: 350px;
  overflow-y: auto;
}

.timeline-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 12px;
  position: relative;
  font-size: 0.78rem;
  line-height: 1.5;
  border-left: 2px solid var(--border);
  margin-left: 6px;
}

.timeline-entry:last-child {
  border-left-color: transparent;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-top: 4px;
  position: relative;
  left: -17px;
  margin-right: -8px;
}

.timeline-text {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-word;
}

/* Status change entries */
.timeline-status .timeline-text {
  font-weight: 600;
}

.timeline-keep .timeline-dot { background: var(--success); }
.timeline-keep .timeline-text { color: var(--success); }

.timeline-dismiss .timeline-dot { background: var(--danger); }
.timeline-dismiss .timeline-text { color: var(--danger); }

.timeline-close .timeline-dot { background: #b482ff; }
.timeline-close .timeline-text { color: #b482ff; }

.timeline-reopen .timeline-dot { background: var(--info); }
.timeline-reopen .timeline-text { color: var(--info); }

/* Comment entries */
.timeline-comment .timeline-dot { background: var(--accent); }
.timeline-comment .timeline-text { color: var(--text-secondary); font-weight: 400; }

/* --- Company Card Popup ---------------------------------- */
.company-card-popup {
  animation: fadeIn 0.15s ease;
}
.company-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.company-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.company-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
}
.company-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.company-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.company-card-row .label {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.company-card-row .value {
  font-size: 0.8rem;
  text-align: right;
}
.company-pill-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.company-pill-clickable:hover {
  filter: brightness(1.2);
}

/* --- Search Bar ------------------------------------------ */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-bar input {
  flex: 1;
  min-width: 0;
}

/* --- Block Tags ------------------------------------------ */
.block-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  color: var(--accent-hover);
  padding: 3px 8px 3px 10px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

.block-tag-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s;
}

.block-tag-remove:hover {
  color: var(--danger);
}

/* --- Modal Overlay / Popup ------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: modal-fade-in 0.2s ease;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  animation: modal-slide-in 0.25s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.modal-row:last-child { border-bottom: none; }
.modal-row .label { color: var(--text-muted); }
.modal-row .value { color: var(--text-primary); font-weight: 500; }
.modal-row .value.rtl { direction: rtl; text-align: right; }

/* --- Gush Autocomplete Dropdown -------------------------- */
.gush-autocomplete {
  position: relative;
}

.gush-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 2px;
  animation: dropdown-in 0.15s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.gush-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.gush-dropdown-item:last-child { border-bottom: none; }

.gush-dropdown-item:hover {
  background: var(--accent-muted);
}

.gush-dropdown-item .gush-num {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}

.gush-dropdown-item .gush-loc {
  color: var(--text-secondary);
  direction: rtl;
  flex: 1;
  text-align: right;
}

.gush-dropdown-item .gush-pending {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* --- Mobile ---------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: 60px;
    border-right: none;
    border-top: 1px solid var(--border);
    flex-direction: row;
    padding: 0;
    z-index: 100;
  }

  .sidebar-brand { display: none; }
  .sidebar-search { display: none; }
  .sidebar-footer { display: none; }

  .sidebar-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
  }

  .sidebar-nav a {
    flex-direction: column;
    padding: 8px 4px;
    font-size: 0.65rem;
    border-left: none;
    border-top: 3px solid transparent;
    gap: 2px;
  }

  .sidebar-nav a.active {
    border-left-color: transparent;
    border-top-color: var(--accent);
  }

  .sidebar-nav .nav-label { display: block; }

  .main {
    margin-left: 0;
    margin-bottom: 60px;
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .page-header h2 {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Sticky table headers for scrollable tables */
.table-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 2;
}

/* Resizable table columns */
.table-resizable th {
  position: relative;
  overflow: hidden;
}
.table-resizable th .col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
}
.table-resizable th .col-resizer:hover,
.table-resizable th .col-resizer.resizing {
  background: var(--accent);
}

/* Block grid layout */
.block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.block-grid .card {
  margin-bottom: 0;
  height: 100%;
}

/* Multi-select tag input */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 32px;
  align-items: center;
  cursor: text;
}
.tag-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}
.tag-input-wrap input,
.tag-input-wrap select {
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
  flex: 1;
  min-width: 60px;
  padding: 2px 4px;
  font-size: 0.8rem;
  color: var(--text-primary);
  background-image: none;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-muted);
  color: var(--accent-hover);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.tag-pill .tag-remove {
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.7;
}
.tag-pill .tag-remove:hover {
  opacity: 1;
  color: var(--danger);
}

/* Checkbox column for table */
.cell-check {
  width: 28px;
  text-align: center;
  padding: 0 4px !important;
}
.cell-check input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 14px;
  height: 14px;
}

/* Bulk actions bar — floating bottom bar */
.bulk-actions {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.bulk-actions .bulk-count {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-hover);
}

/* Undo action in table */
.undo-link {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.75rem;
  text-decoration: underline;
}
.undo-link:hover {
  color: var(--accent-hover);
}

/* ============================================================
   Block Cards Grid — Leads page block view
   ============================================================ */

.tabs-row {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid var(--border);
}
.tab-item {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-item:hover {
  color: var(--text-primary);
}
.tab-item.tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 10px;
}

.block-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.block-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.block-card:hover {
  border-color: var(--accent-muted);
  box-shadow: 0 2px 12px rgba(193, 95, 60, 0.1);
}
.block-card.expanded {
  border-color: var(--accent);
  grid-column: 1 / -1;
  cursor: default;
}

.block-card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.block-card-gush {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}
.block-card-locality {
  font-size: 0.85rem;
  color: var(--text-secondary);
  direction: rtl;
}

.block-card-stats {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.block-card-priorities {
  display: flex;
  gap: 8px;
  align-items: center;
}
.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
.priority-badge.critical {
  color: var(--priority-critical);
}
.priority-badge.high {
  color: var(--priority-high);
}

/* Block row layout (leads page) */
.block-row {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.block-row:hover {
  border-color: var(--accent-muted);
  box-shadow: 0 1px 8px rgba(193, 95, 60, 0.08);
}
.block-row.expanded {
  border-color: var(--accent);
  cursor: default;
}
.block-row-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.block-card-expanded {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.block-card-expanded select {
  width: auto;
  padding: 3px 28px 3px 8px;
  font-size: 0.72rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.block-leads-container table {
  font-size: 0.78rem;
}

/* Leads table inside block cards — compact style */
.leads-block-table {
  font-size: 0.78rem;
}
.leads-block-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.leads-block-table td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
/* ID Type and ID Number hidden via inline style in template */

/* ============================================================
   UI Polish — Accessibility, Skeletons, Scrollbars, States
   ============================================================ */

/* --- Custom Scrollbars ----------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

/* --- Skeleton Loading ------------------------------------ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-line:last-child {
  width: 60%;
}

.skeleton-card {
  height: 100px;
  border-radius: var(--radius);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Empty States ---------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 0.85rem;
  max-width: 320px;
  line-height: 1.5;
}

/* --- Focus-visible for all interactive elements ---------- */
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.tab-btn:focus-visible,
.tab-item:focus-visible,
.block-card:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Improved btn-icon hover (Keep/Deny) ----------------- */
.btn-icon {
  position: relative;
}

.btn-icon::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.btn-icon:hover::after {
  opacity: 1;
}

/* Don't show tooltip if no title */
.btn-icon:not([title])::after {
  display: none;
}

/* --- Lead count badges hover ----------------------------- */
.lead-count {
  transition: border-color var(--transition), box-shadow var(--transition);
}

.lead-count:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

/* --- Progress bar smooth fill transition ----------------- */
.status-bar > div {
  transition: width 0.5s ease;
}

/* --- Block card expanded animation ----------------------- */
.block-card-expanded {
  animation: expand-in 0.2s ease;
}

@keyframes expand-in {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 2000px; }
}

/* --- Reduced motion preference --------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Toast container improvements ------------------------ */
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
  max-width: 420px;
}

.toast-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
}

.toast-dismiss:hover {
  opacity: 1;
}

/* --- Breadcrumbs ----------------------------------------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--text-muted);
  transition: color var(--transition);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs .separator {
  color: var(--border-hover);
  font-size: 0.7rem;
}

.breadcrumbs .current {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================
   Theme Variants — switchable via data-theme on <html>
   Override only the CSS variables, everything else inherits.
   ============================================================ */

/* --- Theme: Premium Gold ----------------------------------- */
[data-theme="gold"] {
  --bg-primary: #0f0e0c;
  --bg-secondary: #1a1816;
  --bg-tertiary: #242120;
  --bg-input: #0a0908;
  --bg-hover: #2a2725;

  --text-primary: #f0ece8;
  --text-secondary: #c9b99a;
  --text-muted: #8a8178;

  --accent: #CA8A04;
  --accent-hover: #EAB308;
  --accent-muted: rgba(202, 138, 4, 0.15);
  --accent-glow: rgba(202, 138, 4, 0.25);

  --border: #242120;
  --border-hover: #3a3530;
  --border-accent: #CA8A04;

  --shadow-glow: 0 4px 20px rgba(202, 138, 4, 0.12);
}

/* --- Theme: Midnight Indigo -------------------------------- */
[data-theme="indigo"] {
  --bg-primary: #0c0c1a;
  --bg-secondary: #141428;
  --bg-tertiary: #1e1e38;
  --bg-input: #080812;
  --bg-hover: #262648;

  --text-primary: #e8e8f0;
  --text-secondary: #a0a0cc;
  --text-muted: #7878a0;

  --accent: #7C3AED;
  --accent-hover: #9B5AFF;
  --accent-muted: rgba(124, 58, 237, 0.15);
  --accent-glow: rgba(124, 58, 237, 0.25);

  --border: #1e1e38;
  --border-hover: #2e2e50;
  --border-accent: #7C3AED;

  --info: #818CF8;
  --info-bg: rgba(129, 140, 248, 0.12);

  --shadow-glow: 0 4px 20px rgba(124, 58, 237, 0.12);
}

/* --- Theme: Ocean Slate ------------------------------------ */
[data-theme="ocean"] {
  --bg-primary: #0B1120;
  --bg-secondary: #0F172A;
  --bg-tertiary: #1E293B;
  --bg-input: #070D18;
  --bg-hover: #283548;

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --accent: #3B82F6;
  --accent-hover: #60A5FA;
  --accent-muted: rgba(59, 130, 246, 0.15);
  --accent-glow: rgba(59, 130, 246, 0.25);

  --success: #22C55E;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #38BDF8;
  --info-bg: rgba(56, 189, 248, 0.12);

  --border: #1E293B;
  --border-hover: #334155;
  --border-accent: #3B82F6;

  --priority-critical: #EF4444;
  --priority-high: #F59E0B;
  --priority-medium: #FBBF24;
  --priority-low: #22C55E;

  --shadow-glow: 0 4px 20px rgba(59, 130, 246, 0.12);
}

/* --- Theme: Ember (warm orange on charcoal) ---------------- */
[data-theme="ember"] {
  --bg-primary: #151210;
  --bg-secondary: #1c1816;
  --bg-tertiary: #282320;
  --bg-input: #100e0c;
  --bg-hover: #322b26;

  --text-primary: #f0ebe5;
  --text-secondary: #d4a574;
  --text-muted: #9c8a78;

  --accent: #F97316;
  --accent-hover: #FB923C;
  --accent-muted: rgba(249, 115, 22, 0.15);
  --accent-glow: rgba(249, 115, 22, 0.3);

  --border: #282320;
  --border-hover: #3a3430;
  --border-accent: #F97316;

  --shadow-glow: 0 4px 20px rgba(249, 115, 22, 0.12);
}

/* --- Theme: Sand (warm light) ------------------------------ */
[data-theme="sand"] {
  --bg-primary: #FAF7F2;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F0EBE3;
  --bg-input: #FFFFFF;
  --bg-hover: #EDE7DD;

  --text-primary: #2C2418;
  --text-secondary: #6B5B4A;
  --text-muted: #9A8B7A;
  --text-inverse: #FFFFFF;

  --accent: #B85C38;
  --accent-hover: #D4724E;
  --accent-muted: rgba(184, 92, 56, 0.1);
  --accent-glow: rgba(184, 92, 56, 0.15);

  --success: #3D8B37;
  --success-bg: rgba(61, 139, 55, 0.1);
  --warning: #C47F17;
  --warning-bg: rgba(196, 127, 23, 0.1);
  --danger: #C53030;
  --danger-bg: rgba(197, 48, 48, 0.08);
  --info: #2B6CB0;
  --info-bg: rgba(43, 108, 176, 0.08);

  --border: #E2DDD5;
  --border-hover: #D4CEC4;
  --border-accent: #B85C38;

  --priority-critical: #C53030;
  --priority-high: #C47F17;
  --priority-medium: #B7940A;
  --priority-low: #3D8B37;

  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 4px 16px rgba(184, 92, 56, 0.08);
}

/* --- Theme: Paper (clean light blue-gray) ------------------ */
[data-theme="paper"] {
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F1F5F9;
  --bg-input: #FFFFFF;
  --bg-hover: #E2E8F0;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #FFFFFF;

  --accent: #2563EB;
  --accent-hover: #3B82F6;
  --accent-muted: rgba(37, 99, 235, 0.08);
  --accent-glow: rgba(37, 99, 235, 0.12);

  --success: #16A34A;
  --success-bg: rgba(22, 163, 74, 0.08);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.06);
  --info: #0284C7;
  --info-bg: rgba(2, 132, 199, 0.06);

  --border: #E2E8F0;
  --border-hover: #CBD5E1;
  --border-accent: #2563EB;

  --priority-critical: #DC2626;
  --priority-high: #D97706;
  --priority-medium: #CA8A04;
  --priority-low: #16A34A;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 4px 16px rgba(37, 99, 235, 0.06);
}

/* --- Light theme fixes ------------------------------------- */
/* Select arrow needs darker stroke on light backgrounds */
[data-theme="sand"] select,
[data-theme="paper"] select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Input borders more visible on light */
[data-theme="sand"] input,
[data-theme="sand"] select,
[data-theme="sand"] textarea,
[data-theme="paper"] input,
[data-theme="paper"] select,
[data-theme="paper"] textarea {
  border-color: var(--border-hover);
}

/* Sticky table headers match light surface */
[data-theme="sand"] .table-wrap thead th,
[data-theme="paper"] .table-wrap thead th {
  background: var(--bg-tertiary);
}

/* Sidebar slightly tinted on light */
[data-theme="sand"] .sidebar {
  background: #F0EBE3;
  border-right-color: #E2DDD5;
}

[data-theme="paper"] .sidebar {
  background: #F1F5F9;
  border-right-color: #E2E8F0;
}

/* Health dot glow toned down */
[data-theme="sand"] .health-dot.valid,
[data-theme="paper"] .health-dot.valid {
  box-shadow: 0 0 4px var(--success);
}

[data-theme="sand"] .health-dot.expired,
[data-theme="paper"] .health-dot.expired {
  box-shadow: 0 0 4px var(--danger);
}

/* Priority dot glow toned down */
[data-theme="sand"] .priority-dot.critical,
[data-theme="paper"] .priority-dot.critical {
  box-shadow: 0 0 4px var(--priority-critical);
}

/* Modal overlay lighter */
[data-theme="sand"] .modal-overlay,
[data-theme="paper"] .modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}

/* Scrollbar lighter */
[data-theme="sand"],
[data-theme="paper"] {
  scrollbar-color: var(--border-hover) transparent;
}

[data-theme="sand"] ::-webkit-scrollbar-thumb,
[data-theme="paper"] ::-webkit-scrollbar-thumb {
  background: var(--border-hover);
}

/* --- Theme Picker Component -------------------------------- */
.theme-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  min-width: 90px;
}

.theme-swatch:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
}

.theme-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.theme-swatch-colors {
  display: flex;
  gap: 3px;
  height: 24px;
}

.theme-swatch-colors span {
  width: 20px;
  height: 24px;
  border-radius: 3px;
}

.theme-swatch-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ================================================================
   Hot Leads — Star Button
   ================================================================ */
.btn-star {
  font-size: 1rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: all var(--transition);
  border-radius: var(--radius-sm);
}

.btn-star.starred {
  color: #f0c040;
  text-shadow: 0 0 6px rgba(240, 192, 64, 0.4);
}

.btn-star:hover {
  color: #f0c040;
  background: rgba(240, 192, 64, 0.1);
}

/* ================================================================
   Notification Bell
   ================================================================ */
.notif-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
  display: inline-flex;
  align-items: center;
}

.notif-bell:hover {
  color: var(--text-primary);
}

.notif-count {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-family: var(--font-mono);
  line-height: 1;
}

/* ================================================================
   Notification Dropdown
   ================================================================ */
.notif-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
  margin-bottom: 8px;
}

.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.notif-list {
  max-height: 340px;
  overflow-y: auto;
}

.notif-item {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition);
}

.notif-item:hover {
  background: rgba(255, 255, 255, 0.03);
  text-decoration: none;
  color: var(--text-secondary);
}

.notif-item.unread {
  border-left: 3px solid var(--accent);
  background: rgba(193, 95, 60, 0.05);
}

.notif-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
}

.notif-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.notif-message {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  direction: rtl;
}
