/* ============================================================
   ContactFinder — design system unifie (light, moderne, responsive)
   ============================================================ */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-end: #7c3aed;
  --gradient: linear-gradient(135deg, #3b82f6 0%, #7c3aed 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .08), 0 4px 10px rgba(15, 23, 42, .04);
  --ring: 0 0 0 3px rgba(59, 130, 246, .15);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; }

/* ===== Login page ===== */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(124, 58, 237, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(59, 130, 246, 0.08), transparent 60%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: var(--surface);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 24px;
  padding: 56px 40px 40px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.02),
    0 10px 40px rgba(15, 23, 42, 0.06);
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--gradient);
  display: inline-grid; place-items: center;
  box-shadow:
    0 8px 20px rgba(59, 130, 246, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.4) inset;
  margin: 0 auto 28px;
}
.login-logo svg { width: 28px; height: 28px; fill: #fff; }
.login-title {
  font-size: 1.55rem; font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 44px;
  color: var(--text);
}
.brand {
  display: flex; align-items: center; gap: 10px;
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--gradient);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(59,130,246,.25);
}
.brand-icon svg { width: 20px; height: 20px; fill: #fff; }
.brand-name { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 14px 20px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500; font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.google-btn:hover {
  border-color: var(--border-strong);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}
.google-btn:active { transform: translateY(0); }
.google-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ===== App shell ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand-name { font-size: 1.1rem; }
.topbar .brand-icon { width: 32px; height: 32px; border-radius: 9px; }
.topbar .brand-icon svg { width: 18px; height: 18px; }
.topbar-nav { display: flex; align-items: center; gap: 4px; margin-left: 16px; flex: 1; }
.nav-link {
  padding: 8px 14px; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
}
.nav-link:hover { background: var(--surface-muted); color: var(--text); }
.nav-link.active {
  background: rgba(59,130,246,.1); color: var(--primary-hover);
  border-color: rgba(59,130,246,.2);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--border);
  cursor: pointer;
}
.avatar-fallback {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gradient); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 0.85rem;
  cursor: pointer;
}
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
}
.menu.open { display: block; }
.menu-item {
  display: block; width: 100%; padding: 10px 14px; text-align: left;
  background: none; border: 0; cursor: pointer; font-size: 0.9rem;
  color: var(--text);
}
.menu-item:hover { background: var(--surface-muted); }
.menu-info {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.menu-info strong { display: block; color: var(--text); }
.menu-info span { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.role-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600;
  background: rgba(59,130,246,.12); color: var(--primary-hover);
  margin-top: 6px;
}
.role-pill.admin { background: linear-gradient(135deg, rgba(59,130,246,.15), rgba(124,58,237,.15)); color: var(--primary-end); }

.burger {
  display: none;
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  place-items: center;
}
.burger svg { width: 22px; height: 22px; }

.drawer {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 23, 42, .45);
  display: none;
}
.drawer.open { display: block; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 80%; max-width: 320px;
  background: var(--surface);
  padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}

/* ===== Page container ===== */
.page {
  flex: 1;
  padding: 28px 24px 60px;
  max-width: 1200px; width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 4px 0 0; }

/* ===== Search page ===== */
.search-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}
.search-bar .input-wrap { position: relative; flex: 1; min-width: 200px; display: flex; }
.search-bar input.text {
  flex: 1; padding: 12px 40px 12px 16px;
  font-size: 1rem;
  border: 0; outline: 0; background: transparent;
  color: var(--text);
}
.search-bar select {
  padding: 12px 14px;
  font-size: 0.95rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); min-width: 120px; cursor: pointer;
}
.btn-primary {
  padding: 12px 24px;
  background: var(--gradient); color: white;
  font-weight: 600; font-size: 0.95rem;
  border: none; border-radius: 8px;
  cursor: pointer; transition: transform .08s, box-shadow .12s;
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(59,130,246,.25); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn {
  padding: 8px 14px; font-size: 0.85rem; font-weight: 500;
  background: var(--surface); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: all .12s;
}
.btn:hover { background: var(--surface-muted); color: var(--text); border-color: var(--border-strong); }
.btn.danger { color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn.danger:hover { background: var(--danger-bg); }

.clear-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); cursor: pointer; font-size: 1.1rem;
  padding: 4px; line-height: 1; background: none; border: 0;
}
.clear-btn:hover { color: var(--text); }

.options-row {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap; margin: 14px 0;
  min-height: 32px;
  color: var(--text-secondary); font-size: 0.85rem;
}

/* Toggle switch */
.toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  user-select: none;
  line-height: 1.2;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.toggle-track {
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--border-strong); position: relative;
  transition: background .15s;
  flex-shrink: 0;
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .15s;
}
.toggle.on .toggle-track { background: var(--primary); }
.toggle.on .toggle-track::after { transform: translateX(16px); }

.cost-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--warning-bg); color: var(--warning-text);
  font-size: 0.8rem; font-weight: 500;
  position: relative;
}
.cost-badge.has-tooltip { cursor: help; }
.cost-badge .cost-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 220px; max-width: min(600px, 92vw);
  padding: 10px 14px;
  background: #0f172a; color: #fff;
  border-radius: 10px;
  font-size: 0.78rem; font-weight: 500; line-height: 1.6;
  white-space: pre;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  opacity: 0; visibility: hidden;
  transform: translateY(6px);
  transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s;
  pointer-events: none;
  z-index: 50;
  text-align: left;
}
/* Pont invisible entre le badge et le tooltip pour que le curseur puisse
   circuler de l'un à l'autre sans fermer le tooltip. */
.cost-badge .cost-tooltip::before {
  content: ''; position: absolute;
  left: 0; right: 0; bottom: -10px; height: 10px;
}
/* Flèche vers le badge */
.cost-badge .cost-tooltip::after {
  content: ''; position: absolute;
  top: 100%; right: 16px;
  border: 6px solid transparent;
  border-top-color: #0f172a;
}
.cost-badge:hover .cost-tooltip,
.cost-badge:focus-within .cost-tooltip {
  opacity: 1; visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity .14s ease, transform .14s ease, visibility 0s;
}

.status {
  margin: 16px 0; color: var(--text-secondary); font-size: 0.95rem;
  min-height: 24px;
}

/* Encart d'avertissements affiché en haut des résultats (admin uniquement) */
.warning-box {
  margin-bottom: 14px;
  padding: 12px 16px;
  background: var(--danger-bg);
  border-left: 3px solid var(--danger);
  border-radius: 8px;
  color: #7f1d1d;
  font-size: 0.86rem;
  line-height: 1.55;
  box-shadow: 0 1px 2px rgba(239,68,68,0.05);
}
.warning-title {
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.warning-line { margin: 2px 0; }
.warning-source {
  font-weight: 600;
  color: var(--danger);
  margin-right: 2px;
}

/* Table d'efficacité par provider (dashboard admin) */
/* Section header pour les résultats regroupés par provider (admin view).
   Sticky au scroll pour que tu saches toujours dans quel groupe tu es en
   descendant. Fond opaque (base --surface) + gradient tinted en overlay +
   box-shadow discret pour la séparation quand il est collé. */
.engine-heading {
  position: sticky;
  top: 56px; /* hauteur de la .topbar sticky + un léger espace */
  z-index: 10;
  margin: 28px 0 12px;
  padding: 10px 16px;
  background-color: var(--surface);
  background-image: linear-gradient(90deg, rgba(59,130,246,0.12) 0%, rgba(59,130,246,0.03) 60%, rgba(255,255,255,0) 100%);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  box-shadow: 0 1px 0 var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-hover);
}
.engine-heading:first-child { margin-top: 4px; }

.engines-table th, .engines-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.engines-table th:first-child, .engines-table td:first-child { text-align: left; }
.engines-table tbody tr:last-child td { border-bottom: 0; }
.engines-table tbody tr:hover { background: var(--surface-muted); }
.status .err { color: var(--danger); }

.multi-header {
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid transparent;
  border-image: var(--gradient) 1;
  font-size: 1.1rem; font-weight: 600;
  color: var(--primary-hover);
}

/* Download bar */
.download-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(59,130,246,.08), rgba(124,58,237,.06));
  border: 1px solid rgba(59,130,246,.2);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--primary-hover); font-weight: 500;
}
.download-bar .count { flex: 1; }

/* Result card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.card-actions { display: flex; gap: 6px; }
.card-desc {
  padding: 10px 16px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  display: none;
}
.card-body { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  background: var(--surface-muted);
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600; font-size: 0.7rem;
  padding: 10px 14px;
  text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  max-width: 280px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: var(--surface-muted); }
@keyframes cell-flash { 0% { background: rgba(16,185,129,.3); } 100% { background: transparent; } }
.data-table td.copied { animation: cell-flash .5s ease-out; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: #fff;
  padding: 10px 20px; border-radius: 8px; font-size: 0.85rem;
  opacity: 0; pointer-events: none; z-index: 100;
  transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* History list (vue user) */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .1s;
}
.history-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.history-main { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.history-q { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 500;
  background: rgba(59,130,246,.1); color: var(--primary-hover);
}
.pill.warn { background: var(--warning-bg); color: var(--warning-text); }
.pill.gray { background: var(--surface-muted); color: var(--text-secondary); }
.history-actions { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  background: none; border: 0; border-radius: 6px; color: var(--text-muted);
  cursor: pointer; font-size: 0.9rem;
  vertical-align: middle;
}
td.row-actions { white-space: nowrap; text-align: right; }
.icon-btn:hover { background: var(--surface-muted); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-bg); }
.empty {
  text-align: center; padding: 48px 16px; color: var(--text-muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* History admin table */
.filters-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
  align-items: center;
}
.filters-row .input-date { flex: 0 0 130px; width: 130px; min-width: 0; }
.filters-row .ts-wrapper { flex: 1 1 240px; min-width: 220px; max-width: 320px; }
.filters-row .input-search { flex: 1 1 200px; min-width: 180px; max-width: 300px; }
.input, .select {
  padding: 8px 12px; font-size: 0.9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); min-width: 130px;
}
.input:focus, .select:focus { outline: 0; border-color: var(--primary); box-shadow: var(--ring); }
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th {
  padding: 12px 14px; text-align: left; font-weight: 600;
  color: var(--text-secondary); font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
  white-space: nowrap;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: var(--surface-muted); }

/* Dashboard */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.kpi-label { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi-value { font-size: 1.75rem; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.kpi-sub { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }

.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.chart-title { margin: 0 0 16px; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-svg { width: 100%; height: 220px; display: block; }
.chart-svg .line { stroke: var(--primary); stroke-width: 2; fill: none; }
.chart-svg .area { fill: url(#grad); opacity: 0.2; }
.chart-svg .dot { fill: var(--primary); }
.chart-svg .axis { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis-text { fill: var(--text-muted); font-size: 10px; }
.chart-svg .bar { fill: var(--primary); opacity: 0.8; }
.chart-svg .bar:hover { opacity: 1; }
.chart-empty { text-align: center; color: var(--text-muted); padding: 40px 16px; font-size: 0.9rem; }

.two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

/* Admin sub-tabs */
.sub-tabs {
  display: flex; gap: 2px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.sub-tab {
  padding: 8px 16px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
}
.sub-tab:hover { color: var(--text); background: rgba(255,255,255,.6); }
.sub-tab.active {
  background: var(--surface);
  color: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

/* Columns page */
.columns-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* Role select */
.role-select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.85rem; background: var(--surface); cursor: pointer;
}

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 8px 4px;
}
.pagination .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex: 1; text-align: center;
  min-width: 180px;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
  animation: modalFadeIn .15s ease-out;
}
.modal-backdrop.closing { animation: modalFadeOut .12s ease-in forwards; }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalFadeOut { to { opacity: 0; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  max-width: 520px; width: 100%;
  max-height: min(85vh, 780px);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp .2s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  margin: 0;
  padding: 18px 24px;
  font-size: 1.05rem; font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-body {
  padding: 20px 24px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-body .field-row + .field-row { margin-top: 14px; }
.modal-body .field-row label {
  display: block;
  font-size: 0.82rem; font-weight: 500;
  color: var(--text); margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.modal-body .field-row input.text,
.modal-body .field-row select.text {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
  box-sizing: border-box;
}
.modal-body .field-row input.text:focus,
.modal-body .field-row select.text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.modal-body .field-row select.text {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg viewBox='0 0 12 7' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px;
  padding-right: 34px;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.btn.primary {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.btn.primary:hover { box-shadow: 0 6px 16px rgba(59, 130, 246, 0.25); }
.btn.danger-solid {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.btn.danger-solid:hover { background: #dc2626; box-shadow: 0 6px 16px rgba(239, 68, 68, 0.25); }

/* Scrollbar minimal */
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Helpers */
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.row { display: flex; align-items: center; }
.hide { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar-nav { display: none; }
  .burger { display: grid; }
  .page { padding: 20px 16px 40px; }
  .two-col { grid-template-columns: 1fr; }
  .admin-table { font-size: 0.82rem; }
}

@media (max-width: 500px) {
  .brand-name { display: none; }
  .search-bar { padding: 8px; }
  .kpi-value { font-size: 1.45rem; }
  .page-title { font-size: 1.3rem; }
}
