:root {
  --blue: #003087; --navy: #001d5c; --gold: #c9a84c;
  --bg: #f8fafc; --card: #fff; --border: #e5e7eb;
  --text: #1e293b; --muted: #6b7280;
  --red: #ef4444; --orange: #f97316; --amber: #f59e0b; --green: #22c55e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Inter","Segoe UI",Arial,sans-serif; background: var(--bg); color: var(--text); }

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; height: 52px;
  border-bottom: 3px solid var(--gold); position: sticky; top: 0; z-index: 100; }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .logo { background: var(--gold); color: var(--blue); font-weight: 800;
  font-size: 13px; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.topbar-title { font-size: 14px; font-weight: 700; }
.topbar-sub { font-size: 10px; color: #93c5fd; }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-link { color: #93c5fd; text-decoration: none; padding: 6px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 600; transition: all 0.2s; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.15); color: white; }

/* Run Pipeline Button */
.nav-run-btn { display: inline-flex; align-items: center; gap: 6px; color: #fff; padding: 6px 16px;
  border-radius: 6px; font-size: 12px; font-weight: 700; border: 1.5px solid var(--gold);
  background: transparent; cursor: pointer; transition: all 0.25s; font-family: inherit; }
.nav-run-btn:hover { background: var(--gold); color: var(--navy); }
.nav-run-btn.running { background: var(--gold); color: var(--navy); animation: pulse-gold 2s ease-in-out infinite; }

/* ── Animations ─────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-gold { 0%,100% { box-shadow: 0 0 0 0 rgba(201,168,76,0.4); } 50% { box-shadow: 0 0 0 8px rgba(201,168,76,0); } }

.spinner { width: 16px; height: 16px; border: 2.5px solid #e2e8f0; border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
.spinner-inline { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }

/* ── Pipeline Control Panel ─────────────────────────────────────────── */
.pipeline-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 9999; display: flex; align-items: center; justify-content: center; }

.pipeline-panel { background: #fff; border-radius: 16px; width: 640px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,0.3); border: 1px solid #e2e8f0; }

.pipeline-header { display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.pipeline-title { font-size: 18px; font-weight: 800; color: var(--blue); margin: 0; }
.pipeline-subtitle { font-size: 11px; color: var(--muted); font-weight: 500; }
.pipeline-close { background: none; border: none; font-size: 28px; cursor: pointer;
  color: #94a3b8; line-height: 1; padding: 0 4px; transition: color 0.2s; }
.pipeline-close:hover { color: var(--red); }

/* Tabs */
.pipeline-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); padding: 0 24px; }
.pipeline-tab { padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.2s; font-family: inherit; }
.pipeline-tab:hover { color: var(--text); }
.pipeline-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.pipeline-tab-content { padding: 16px 24px 24px; }

/* Sections & Inputs */
.pipeline-section { margin-bottom: 16px; }
.pipeline-label { display: block; font-size: 11px; font-weight: 700; color: #334155;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.pipeline-input { border: 1.5px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-size: 12px; font-family: inherit; outline: none; transition: border-color 0.2s; }
.pipeline-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,48,135,0.08); }
.pipeline-badge { display: inline-flex; align-items: center; justify-content: center;
  background: #eff6ff; color: var(--blue); font-size: 10px; font-weight: 700;
  padding: 1px 8px; border-radius: 10px; min-width: 20px; }

/* Preset buttons */
.pipeline-preset-btn { padding: 5px 12px; border-radius: 8px; border: 1.5px solid var(--border);
  font-size: 11px; cursor: pointer; background: #fff; font-weight: 600;
  color: var(--text); transition: all 0.2s; font-family: inherit; }
.pipeline-preset-btn:hover { border-color: var(--blue); background: #f0f4ff; }
.pipeline-preset-btn.selected { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Add button */
.pipeline-btn-add { padding: 8px 16px; border-radius: 8px; border: none;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit; white-space: nowrap; transition: background 0.2s; }
.pipeline-btn-add:hover { background: var(--navy); }

/* Selected queue */
.pipeline-queue { border: 1px solid var(--border); border-radius: 8px; max-height: 140px;
  overflow-y: auto; background: #fafbfc; }
.pipeline-queue-item { display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.pipeline-queue-item:last-child { border-bottom: none; }

/* Start button */
.pipeline-btn-start { width: 100%; padding: 12px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, var(--blue), var(--navy)); color: #fff;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: all 0.3s; box-shadow: 0 4px 12px rgba(0,48,135,0.3); }
.pipeline-btn-start:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,48,135,0.4); }
.pipeline-btn-start:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Job Cards ──────────────────────────────────────────────────────── */
.pipeline-jobs { display: flex; flex-direction: column; gap: 8px; }

.pipeline-job { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  background: #fff; transition: border-color 0.2s; }
.pipeline-job.job-running { border-left: 4px solid var(--blue); background: #f8faff; }
.pipeline-job.job-done { border-left: 4px solid var(--green); }
.pipeline-job.job-error { border-left: 4px solid var(--red); }
.pipeline-job.job-queued { border-left: 4px solid #94a3b8; }

.job-header { display: flex; justify-content: space-between; align-items: center; }
.job-city { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.job-meta { display: flex; align-items: center; gap: 6px; }
.job-status-icon { font-size: 12px; }
.job-status-label { font-size: 9px; font-weight: 800; letter-spacing: 0.5px; padding: 2px 8px;
  border-radius: 6px; text-transform: uppercase; }
.job-status-label.job-done { background: #dcfce7; color: #166534; }
.job-status-label.job-error { background: #fef2f2; color: #991b1b; }
.job-status-label.job-running { background: #eff6ff; color: var(--blue); }
.job-status-label.job-queued { background: #f1f5f9; color: #64748b; }

.pipeline-job.job-stopped { border-left: 4px solid var(--amber); background: #fffbf0; }
.job-status-label.job-stopped { background: #fef3c7; color: #92400e; }
.job-stage { font-size: 11px; color: var(--blue); margin-top: 4px; font-weight: 500; }
.job-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.job-btn { padding: 5px 14px; border-radius: 6px; border: none; font-size: 11px;
  font-weight: 700; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.job-btn-stop { background: #dc2626; color: white; }
.job-btn-stop:hover { background: #b91c1c; }
.job-btn-resume { background: #16a34a; color: white; }
.job-btn-resume:hover { background: #15803d; }
.job-error-msg { font-size: 11px; color: #dc2626; margin-top: 6px; background: #fef2f2;
  padding: 6px 10px; border-radius: 6px; }

.job-log-details { margin-top: 8px; }
.job-log-details summary { font-size: 10px; font-weight: 600; color: var(--muted); cursor: pointer;
  padding: 4px 0; user-select: none; }
.job-log-details summary:hover { color: var(--blue); }
.job-log { background: #0f172a; color: #a3e635; font-size: 10px; line-height: 1.5;
  padding: 12px; border-radius: 8px; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all; font-family: "JetBrains Mono","Fira Code",monospace; margin-top: 4px; }

/* ── City Search Bar ────────────────────────────────────────────────── */
.city-search-bar { position: relative; margin-bottom: 16px; display: flex; align-items: center;
  background: #fff; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 4px 14px; transition: border-color 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.city-search-bar:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,48,135,0.08); }
.city-search-icon { font-size: 16px; margin-right: 10px; color: #94a3b8; flex-shrink: 0; }
.city-search-input { border: none; outline: none; font-size: 13px; font-family: inherit;
  flex: 1; padding: 8px 0; background: transparent; color: var(--text); }
.city-search-input::placeholder { color: #94a3b8; }
.city-search-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 50; max-height: 280px; overflow-y: auto; margin-top: 4px; }
.city-search-item { display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  font-size: 12px; cursor: pointer; border-bottom: 1px solid #f8fafc; transition: background 0.15s; }
.city-search-item:hover { background: #f0f4ff; }
.city-search-item:last-child { border-bottom: none; }

/* ── Stats ──────────────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { background: var(--card); border-radius: 10px; padding: 16px; border: 1px solid var(--border);
  border-top: 4px solid var(--blue); flex: 1; min-width: 130px; text-align: center; }
.stat-val { font-size: 26px; font-weight: 800; color: var(--blue); }
.stat-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }

/* ── Table ──────────────────────────────────────────────────────────── */
.table-card { background: var(--card); border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.table-toolbar h3 { font-size: 13px; font-weight: 700; }
.search { border: 1px solid var(--border); border-radius: 7px; padding: 6px 12px;
  font-size: 12px; width: 200px; outline: none; }
.filter-row { display: flex; gap: 4px; flex-wrap: wrap; }
.fbtn { padding: 4px 12px; border-radius: 16px; border: 1.5px solid var(--border);
  font-size: 11px; cursor: pointer; background: #fff; font-weight: 500; }
.fbtn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th { background: var(--navy); color: #fff; padding: 8px 10px; text-align: left;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; z-index: 10; }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
tbody tr:hover { background: #eff6ff; }
td { padding: 8px 10px; }
.tier { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 10px; font-weight: 700; }
.tier-top { background: #fef2f2; color: #dc2626; }
.tier-rec { background: #fff7ed; color: #c2410c; }
.tier-watch { background: #fffbeb; color: #b45309; }
.tier-low { background: #f0fdf4; color: #16a34a; }
.tbody-scroll { max-height: 500px; overflow-y: auto; }

/* ── Map page ───────────────────────────────────────────────────────── */
.map-container { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; }
.map-sidebar { position: absolute; top: 0; left: 0; width: 320px; height: 100%; background: white;
  z-index: 1000; overflow-y: auto; box-shadow: 2px 0 10px rgba(0,0,0,0.12); }
.map-sidebar-header { background: var(--blue); color: white; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; }
.sidebar-section { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.sidebar-section-title { font-size: 9px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; margin-bottom: 4px; }
.city-btn { padding: 4px 10px; border-radius: 10px; border: 1.5px solid var(--border);
  font-size: 10px; cursor: pointer; background: white; font-weight: 600; }
.city-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.loc-item { padding: 8px 6px; border-left: 3px solid #ccc; border-bottom: 1px solid #f8fafc;
  cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 10px; }
.loc-item:hover { background: #f8fafc; }
.loc-score { width: 28px; height: 28px; border-radius: 50%; border: 2px solid; display: flex;
  align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex-shrink: 0; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; font-size: 9px; color: #334155; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; vertical-align: middle; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--blue); text-transform: uppercase;
  letter-spacing: 0.8px; margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 3px solid var(--gold); }
