:root {
  --bg: #0b0d10;
  --panel: #12161c;
  --panel-2: #171d24;
  --line: #26303a;
  --text: #eef3f7;
  --muted: #8f9daa;
  --soft: #c3ccd5;
  --green: #26c281;
  --cyan: #38bdf8;
  --amber: #f5b84b;
  --red: #f87171;
  --blue: #5aa7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  background: rgba(11, 13, 16, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #061014;
  font-weight: 900;
}

h1, h2, p {
  margin: 0;
}

h1 { font-size: 20px; letter-spacing: 0; }
h2 { font-size: 15px; letter-spacing: 0; }
p { color: var(--muted); font-size: 12px; margin-top: 3px; }

.metrics {
  display: flex;
  gap: 10px;
}

.metrics div, .metrics button {
  min-width: 76px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.metrics button {
  cursor: pointer;
}

.metrics button:hover, .metrics button:focus {
  border-color: var(--cyan);
  outline: none;
}

.metrics strong { display: block; font-size: 18px; }
.metrics span { display: block; color: var(--muted); font-size: 11px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 16px;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.run-panel, .status-panel, .data-panel {
  padding: 16px;
}

.data-panel {
  grid-column: 1 / -1;
}

.panel-head, .table-actions, .inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-toggle, .tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #0d1116;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.source-btn, .tab {
  border: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

.source-btn.active, .tab.active {
  color: #071016;
  background: var(--green);
  font-weight: 800;
}

.run-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact { align-items: end; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-grid .wide {
  grid-column: span 2;
}

label span, .checkline span {
  display: block;
  margin-bottom: 6px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1116;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

input:focus, select:focus, .chip-box:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.source-fields { display: none; gap: 12px; }
.source-fields.active { display: grid; }

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.checkline input {
  width: 16px;
  min-height: 16px;
}

.checkline span {
  margin: 0;
}

.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.advanced label {
  display: block;
  margin-top: 10px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-btn, .ghost-btn {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.primary-btn {
  background: var(--green);
  color: #071016;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #0d1116;
  color: var(--soft);
}

.form-status { color: var(--muted); font-size: 12px; }

.pipeline-card {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 12px 14px;
  border: 1px solid rgba(73, 222, 167, 0.3);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(38, 194, 129, 0.12), rgba(48, 183, 214, 0.08));
}

.pipeline-card strong { color: var(--text); font-size: 14px; }
.pipeline-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.pipeline-card select { width: 100%; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.45; }
.pipeline-kicker {
  color: #8ef0ca;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chip-box {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1116;
  padding: 5px 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #345042;
  border-radius: 6px;
  background: rgba(38, 194, 129, 0.12);
  color: #b9f7dc;
  padding: 4px 7px;
  font-size: 12px;
}

.chip button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.chip-box input {
  flex: 1;
  min-width: 120px;
  min-height: 28px;
  border: 0;
  padding: 4px;
  box-shadow: none;
}

.chip-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.chip-menu.open { display: block; }

.chip-option {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--soft);
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.chip-option:hover { background: var(--panel-2); color: var(--text); }

.progress-shell {
  margin-top: 16px;
}

.progress-row, .progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--soft);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  margin: 10px 0;
  overflow: hidden;
  background: #0d1116;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width 0.3s ease;
}

.radar-shell {
  margin-top: 12px;
}

.radar {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 4px auto;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(circle, #0e141b 0%, #0b0f14 72%);
  overflow: hidden;
}

.radar-grid,
.radar-grid::before,
.radar-grid::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  content: '';
}

.radar-grid {
  background:
    linear-gradient(transparent 49.6%, rgba(56, 189, 248, 0.14) 50%, transparent 50.4%),
    linear-gradient(90deg, transparent 49.6%, rgba(56, 189, 248, 0.14) 50%, transparent 50.4%);
}

.radar-grid::before {
  inset: 26px;
  border: 1px solid rgba(56, 189, 248, 0.16);
}

.radar-grid::after {
  inset: 56px;
  border: 1px solid rgba(56, 189, 248, 0.16);
}

.radar-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(38, 194, 129, 0.55), rgba(56, 189, 248, 0.18) 55deg, transparent 78deg);
  opacity: 0;
  animation: radar-sweep-rotate 3.2s linear infinite;
  animation-play-state: paused;
}

@keyframes radar-sweep-rotate {
  to { transform: rotate(360deg); }
}

.radar-shell[data-state='active'] .radar-sweep {
  opacity: 1;
  animation-play-state: running;
}

.radar-shell[data-state='stale'] .radar-sweep {
  opacity: 0.25;
  animation-play-state: paused;
}

.radar-shell[data-state='waiting'] .radar-sweep {
  opacity: 0.35;
  animation-play-state: paused;
  background: conic-gradient(from 0deg, rgba(245, 184, 75, 0.5), transparent 70deg);
}

.radar-shell[data-state='failed'] .radar-sweep {
  opacity: 0.35;
  animation-play-state: paused;
  background: conic-gradient(from 0deg, rgba(248, 113, 113, 0.5), transparent 70deg);
}

.radar-shell[data-state='completed'] .radar-sweep {
  opacity: 0;
  animation-play-state: paused;
}

.radar-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.radar-ring circle {
  fill: none;
  stroke-width: 4;
}

.radar-ring .ring-bg {
  stroke: rgba(38, 48, 58, 0.9);
}

.radar-ring .ring-fill {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 4px rgba(38, 194, 129, 0.6));
}

.radar-shell[data-state='failed'] .ring-fill { stroke: var(--red); }
.radar-shell[data-state='waiting'] .ring-fill,
.radar-shell[data-state='stale'] .ring-fill { stroke: var(--amber); }

.radar-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
}

.radar-center strong {
  font-size: 20px;
  letter-spacing: 0;
}

.radar-center span {
  color: var(--muted);
  font-size: 10px;
}

.radar-blips {
  position: absolute;
  inset: 0;
}

.radar-blip {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(38, 194, 129, 0.9);
  animation: radar-blip-ping 3.6s ease-out forwards;
}

@keyframes radar-blip-ping {
  0% { opacity: 0; transform: scale(0.4); }
  12% { opacity: 1; transform: scale(1.35); }
  100% { opacity: 0; transform: scale(0.7); }
}

.orbit {
  position: absolute;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #0d1116;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  transition: box-shadow 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.orbit-docker { top: 10px; left: 50%; margin-left: -12px; }
.orbit-google { bottom: 18px; left: 20px; }
.orbit-apify { bottom: 18px; right: 20px; }

.orbit.live.orbit-docker {
  color: #a5f3fc;
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.75);
  animation: orbit-pulse 1.8s ease-in-out infinite;
}

.orbit.live.orbit-google {
  color: #b9f7dc;
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(38, 194, 129, 0.75);
  animation: orbit-pulse 1.8s ease-in-out infinite;
}

.orbit.live.orbit-apify {
  color: #f5d0fe;
  border-color: #e879f9;
  box-shadow: 0 0 10px rgba(232, 121, 249, 0.75);
  animation: orbit-pulse 1.8s ease-in-out infinite;
}

.orbit.standby {
  opacity: 0.55;
  border-style: dashed;
}

@keyframes orbit-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.radar-shell[data-state='completed'] .orbit.live,
.radar-shell[data-state='waiting'] .orbit.live,
.radar-shell[data-state='stale'] .orbit.live,
.radar-shell[data-state='failed'] .orbit.live {
  animation: none;
}

.radar-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.heartbeat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.heartbeat::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.radar-shell[data-state='active'] .heartbeat { color: #b9f7dc; }
.radar-shell[data-state='active'] .heartbeat::before {
  background: var(--green);
  animation: heartbeat-pulse 1.2s ease-in-out infinite;
}

.radar-shell[data-state='stale'] .heartbeat,
.radar-shell[data-state='waiting'] .heartbeat { color: var(--amber); }
.radar-shell[data-state='stale'] .heartbeat::before,
.radar-shell[data-state='waiting'] .heartbeat::before { background: var(--amber); }

.radar-shell[data-state='failed'] .heartbeat { color: var(--red); }
.radar-shell[data-state='failed'] .heartbeat::before { background: var(--red); }

.radar-shell[data-state='completed'] .heartbeat { color: #b9f7dc; }
.radar-shell[data-state='completed'] .heartbeat::before { background: var(--green); }

@keyframes heartbeat-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.75); }
}

@media (prefers-reduced-motion: reduce) {
  .radar-sweep,
  .orbit.live,
  .heartbeat::before,
  .radar-blip {
    animation: none !important;
  }
}

.progress-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.progress-metrics span {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.mini-log {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.mini-log div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  background: #0d1116;
}

.tabs {
  margin-bottom: 14px;
}

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

.table-actions {
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #0d1116;
  font-size: 11px;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
}

.badge.completed { color: #b9f7dc; background: rgba(38, 194, 129, 0.12); }
.badge.running, .badge.queued { color: #d7ecff; background: rgba(90, 167, 255, 0.16); }
.badge.failed { color: #ffd0d0; background: rgba(248, 113, 113, 0.16); }
.source { color: var(--cyan); font-weight: 800; }
.muted { color: var(--muted); }

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.settings-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.settings-card h3 {
  margin: 0;
  font-size: 13px;
}

.settings-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.settings-actions {
  margin-top: 14px;
}

.proxy-list {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.proxy-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1116;
  color: var(--soft);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.proxy-row.ok { border-color: rgba(38, 194, 129, 0.5); }
.proxy-row.ok .proxy-result { color: var(--green); }
.proxy-row.fail { border-color: rgba(248, 113, 113, 0.5); }
.proxy-row.fail .proxy-result { color: var(--red); }

.settings-hint.test-ok { color: var(--green); }
.settings-hint.test-fail { color: var(--red); }

.run-config {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

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

@media (max-width: 920px) {
  .layout, .form-grid.two, .form-grid.three, .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid .wide {
    grid-column: auto;
  }

  .topbar, .panel-head, .table-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    width: 100%;
  }

  .metrics div {
    flex: 1;
  }
}

/* ---- Output Mode pipeline selector (Leads-GenX console) ---- */

.mode-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.mode-field-label,
.settings-hint span {
  color: var(--soft);
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.settings-hint p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.settings-hint strong {
  color: var(--soft);
}

.mode-select {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  padding: 2px;
  position: relative;
}

.mode-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 13px 14px 12px;
  position: relative;
  text-align: left;
  transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
  z-index: 1;
}

.mode-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.mode-card:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.7);
  outline-offset: 2px;
}

.mode-card.active {
  background: linear-gradient(165deg, rgba(56, 189, 248, 0.08), rgba(38, 194, 129, 0.05) 60%, transparent), var(--panel-2);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 6px 20px rgba(3, 8, 12, 0.5);
}

/* Slow console sheen sweeping the engaged card */
.mode-scan {
  background: linear-gradient(105deg, transparent 42%, rgba(56, 189, 248, 0.07) 50%, transparent 58%);
  height: 100%;
  left: -120%;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 120%;
}

.mode-card.active .mode-scan {
  animation: mode-scan-sweep 5.5s ease-in-out infinite;
}

@keyframes mode-scan-sweep {
  0%, 55% { left: -120%; }
  85%, 100% { left: 120%; }
}

.mode-head {
  align-items: center;
  display: flex;
  gap: 8px;
}

.mode-led {
  background: #33404d;
  border-radius: 50%;
  flex: 0 0 auto;
  height: 8px;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  width: 8px;
}

.mode-card.active .mode-led {
  animation: mode-led-breathe 2.4s ease-in-out infinite;
  background: var(--green);
  box-shadow: 0 0 8px rgba(38, 194, 129, 0.9);
}

@keyframes mode-led-breathe {
  0%, 100% { box-shadow: 0 0 4px rgba(38, 194, 129, 0.5); }
  50% { box-shadow: 0 0 10px rgba(38, 194, 129, 1); }
}

.mode-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.mode-tag {
  background: rgba(38, 194, 129, 0.14);
  border: 1px solid rgba(38, 194, 129, 0.35);
  border-radius: 4px;
  color: #b9f7dc;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-left: auto;
  opacity: 0;
  padding: 2px 6px;
  transform: translateX(-6px);
  transition: opacity 0.3s ease 0.12s, transform 0.3s ease 0.12s;
}

.mode-card.active .mode-tag {
  opacity: 1;
  transform: translateX(0);
}

.mode-desc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.mode-card.active .mode-desc {
  color: var(--soft);
}

.mode-meta {
  align-items: center;
  border-top: 1px dashed var(--line);
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
}

.mode-engines {
  display: flex;
  gap: 4px;
}

.mode-engine {
  background: #2a3540;
  border-radius: 2px;
  display: block;
  height: 4px;
  transition: background 0.3s ease;
  width: 14px;
}

.mode-card.active .mode-engine {
  animation: engine-ignite 0.45s ease both;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.mode-card.active .mode-engine:nth-child(2) { animation-delay: 0.15s; }
.mode-card.active .mode-engine:nth-child(3) { animation-delay: 0.3s; }

@keyframes engine-ignite {
  0% { opacity: 0.2; transform: scaleX(0.4); }
  60% { opacity: 1; transform: scaleX(1.15); }
  100% { opacity: 1; transform: scaleX(1); }
}

.mode-meta-text {
  color: var(--muted);
  font-size: 11px;
}

/* Targeting frame that glides onto the engaged card */
.mode-glider {
  bottom: -4px;
  left: 2px;
  pointer-events: none;
  position: absolute;
  top: -4px;
  transition: left 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  width: calc(50% - 7px);
  z-index: 2;
}

.mode-select[data-selected='hybrid_max'] .mode-glider {
  left: calc(50% + 5px);
}

.mode-glider .corner {
  height: 12px;
  position: absolute;
  width: 12px;
}

.mode-glider .tl { border-left: 2px solid var(--cyan); border-top: 2px solid var(--cyan); left: 0; top: 0; }
.mode-glider .tr { border-right: 2px solid var(--cyan); border-top: 2px solid var(--cyan); right: 0; top: 0; }
.mode-glider .bl { border-bottom: 2px solid var(--green); border-left: 2px solid var(--green); bottom: 0; left: 0; }
.mode-glider .br { border-bottom: 2px solid var(--green); border-right: 2px solid var(--green); bottom: 0; right: 0; }

/* Leads flowing through the pipeline under the selector */
.mode-conduit {
  background: rgba(42, 53, 64, 0.6);
  border-radius: 2px;
  bottom: -9px;
  height: 2px;
  left: 10%;
  overflow: hidden;
  position: absolute;
  right: 10%;
}

.mode-conduit-flow {
  animation: conduit-flow 1.4s linear infinite;
  background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(56, 189, 248, 0.65) 7px 11px, rgba(38, 194, 129, 0.65) 11px 14px, transparent 14px 21px);
  display: block;
  height: 100%;
  width: 200%;
}

@keyframes conduit-flow {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

/* Click confirmation ripple */
.mode-ripple {
  animation: mode-ripple 0.55s ease-out forwards;
  background: rgba(56, 189, 248, 0.22);
  border-radius: 50%;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, -50%) scale(0);
}

@keyframes mode-ripple {
  to { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ---- AI Analyst panel ---- */

.analyst-panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  transition: border-color 0.3s ease;
}

.analyst-panel[data-verdict='perfect'] { border-color: rgba(38, 194, 129, 0.55); }
.analyst-panel[data-verdict='good'] { border-color: rgba(56, 189, 248, 0.45); }
.analyst-panel[data-verdict='bad'] { border-color: rgba(245, 184, 75, 0.55); }
.analyst-panel[data-verdict='needs_attention'] { border-color: rgba(248, 113, 113, 0.6); }

.analyst-head {
  align-items: center;
  display: flex;
  gap: 10px;
}

.analyst-orb {
  background: radial-gradient(circle, #0e141b 0%, #0b0f14 75%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 50%;
  height: 34px;
  overflow: hidden;
  position: relative;
  width: 34px;
}

.analyst-orb-sweep {
  animation: radar-sweep-rotate 2.8s linear infinite;
  animation-play-state: paused;
  background: conic-gradient(from 0deg, rgba(38, 194, 129, 0.55), rgba(56, 189, 248, 0.18) 55deg, transparent 78deg);
  border-radius: 50%;
  inset: 0;
  opacity: 0;
  position: absolute;
}

.analyst-panel[data-verdict='good'] .analyst-orb-sweep,
.analyst-panel[data-verdict='perfect'] .analyst-orb-sweep {
  opacity: 1;
  animation-play-state: running;
}

.analyst-panel[data-verdict='bad'] .analyst-orb-sweep {
  animation-play-state: running;
  background: conic-gradient(from 0deg, rgba(245, 184, 75, 0.55), transparent 70deg);
  opacity: 1;
}

.analyst-panel[data-verdict='needs_attention'] .analyst-orb-sweep {
  animation-play-state: running;
  background: conic-gradient(from 0deg, rgba(248, 113, 113, 0.6), transparent 70deg);
  opacity: 1;
}

.analyst-orb-core {
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.9);
  height: 6px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
}

.analyst-title {
  align-items: center;
  display: flex;
  gap: 10px;
}

.analyst-title h3 {
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

.analyst-verdict {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  text-transform: uppercase;
}

.analyst-verdict[data-verdict='idle'] { background: rgba(143, 157, 170, 0.15); color: var(--muted); }
.analyst-verdict[data-verdict='perfect'] { background: rgba(38, 194, 129, 0.16); color: #b9f7dc; }
.analyst-verdict[data-verdict='good'] { background: rgba(56, 189, 248, 0.14); color: #bde6fd; }
.analyst-verdict[data-verdict='bad'] { background: rgba(245, 184, 75, 0.16); color: var(--amber); }
.analyst-verdict[data-verdict='needs_attention'] { background: rgba(248, 113, 113, 0.16); color: var(--red); }

.analyst-headline {
  color: var(--soft);
  font-size: 13px;
  line-height: 1.5;
  margin: 10px 0 6px;
}

.analyst-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.analyst-lines li {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  padding-left: 16px;
  position: relative;
}

.analyst-lines li::before {
  border-radius: 50%;
  content: '';
  height: 6px;
  left: 2px;
  position: absolute;
  top: 5px;
  width: 6px;
}

.analyst-lines li[data-tone='ok']::before { background: var(--green); }
.analyst-lines li[data-tone='info']::before { background: var(--cyan); }
.analyst-lines li[data-tone='warn']::before { background: var(--amber); }
.analyst-lines li[data-tone='error']::before { background: var(--red); }

.analyst-lines li[data-tone='engineer'] {
  color: var(--soft);
}

.analyst-lines li[data-tone='engineer']::before {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  border-radius: 1px;
  transform: rotate(45deg) translateY(-1px);
}

.analyst-lines li[data-tone='warn'],
.analyst-lines li[data-tone='error'] {
  color: var(--soft);
}

@media (prefers-reduced-motion: reduce) {
  .mode-scan,
  .mode-led,
  .mode-engine,
  .mode-conduit-flow,
  .mode-glider,
  .mode-ripple,
  .analyst-orb-sweep {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- Engineer quarantine banner ---- */

.quarantine-banner {
  background: rgba(245, 184, 75, 0.08);
  border: 1px solid rgba(245, 184, 75, 0.4);
  border-radius: 10px;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 10px 14px;
}

.quarantine-banner strong {
  color: var(--amber);
}

.nova-request-head {
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.quarantine-item {
  display: block;
  margin-top: 4px;
}

/* ---- Analyst liveness ---- */

.analyst-live {
  align-items: center;
  background: rgba(143, 157, 170, 0.1);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
  padding: 3px 9px;
}

.analyst-live span:last-child,
.analyst-live #analystLiveText {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.analyst-live-dot {
  background: #5a6a78;
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

.analyst-live[data-active='true'] {
  background: rgba(38, 194, 129, 0.1);
  border-color: rgba(38, 194, 129, 0.4);
}

.analyst-live[data-active='true'] .analyst-live-dot {
  animation: analyst-live-pulse 1.6s ease-in-out infinite;
  background: var(--green);
}

.analyst-live[data-active='true'] #analystLiveText {
  color: #b9f7dc;
}

@keyframes analyst-live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(38, 194, 129, 0.55); }
  50% { box-shadow: 0 0 0 5px rgba(38, 194, 129, 0); }
}

.analyst-lines li {
  animation: analyst-line-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes analyst-line-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.analyst-headline-in {
  animation: analyst-headline-in 0.45s ease both;
}

@keyframes analyst-headline-in {
  from { opacity: 0.2; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.analyst-ticker {
  align-items: center;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 8px;
  margin-top: 10px;
  overflow: hidden;
  padding-top: 8px;
  position: relative;
}

.analyst-ticker::after {
  animation: analyst-ticker-scan 2.6s linear infinite;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.5), transparent);
  bottom: -1px;
  content: '';
  height: 1px;
  left: -30%;
  position: absolute;
  width: 30%;
}

@keyframes analyst-ticker-scan {
  to { left: 110%; }
}

.ghost-btn.danger {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--red);
}

.ghost-btn.danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .analyst-live-dot,
  .analyst-lines li,
  .analyst-headline-in,
  .analyst-ticker::after {
    animation: none !important;
  }
}

/* ---------------- Auth gate ---------------- */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(94, 234, 212, 0.07), transparent 60%),
    var(--bg, #0c1116);
  padding: 24px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel, #12181f);
  border: 1px solid var(--line, rgba(148, 163, 184, 0.14));
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.auth-brand {
  margin-bottom: 24px;
}

.auth-form h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.auth-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted, #8b98a5);
  line-height: 1.5;
}

.auth-form label {
  display: block;
  margin-bottom: 14px;
}

.auth-form label span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #8b98a5);
  margin-bottom: 6px;
}

.auth-form input {
  width: 100%;
  box-sizing: border-box;
}

.auth-form .primary-btn {
  width: 100%;
  margin-top: 4px;
}

.auth-error {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--red, #f87171);
}

.auth-loading {
  margin: 0;
  text-align: center;
  color: var(--muted, #8b98a5);
  font-size: 14px;
}

/* ---------------- User chip & plan badges ---------------- */

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  margin-left: 6px;
  border-left: 1px solid var(--line, rgba(148, 163, 184, 0.14));
}

.user-chip[hidden] {
  display: none;
}

.user-chip-name {
  font-size: 13px;
  font-weight: 600;
}

.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--muted, #8b98a5);
}

.plan-badge[data-tier="HYBRID"] {
  border-color: rgba(94, 234, 212, 0.5);
  color: var(--teal, #5eead4);
  background: rgba(94, 234, 212, 0.08);
}

.plan-badge[data-tier="ADMIN"] {
  border-color: rgba(251, 191, 36, 0.5);
  color: var(--amber, #fbbf24);
  background: rgba(251, 191, 36, 0.08);
}

.plan-badge.large {
  font-size: 13px;
  padding: 4px 14px;
}

.account-plan {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.account-plan p {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #8b98a5);
  line-height: 1.5;
}

/* ---------------- Admin panel ---------------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line, rgba(148, 163, 184, 0.1));
}

.admin-table th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted, #8b98a5);
}

.admin-actions {
  white-space: nowrap;
}

.admin-actions .ghost-btn {
  padding: 4px 10px;
  font-size: 12px;
  margin-right: 4px;
}

.admin-users-card {
  margin-top: 20px;
}

.upgrade-request {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line, rgba(148, 163, 184, 0.1));
}

.upgrade-request:last-child {
  border-bottom: none;
}

.upgrade-request .settings-hint {
  margin-left: 6px;
}

/* ---------------- Tier lock ---------------- */

.hybrid-lock-hint {
  color: var(--amber, #fbbf24);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal, #5eead4);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mode-select[data-tier-locked="true"] .mode-card[data-mode="hybrid_max"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.mode-select[data-tier-locked="true"] .mode-card[data-mode="hybrid_max"] .mode-tag {
  display: none;
}

.mode-select[data-tier-locked="true"] .mode-card[data-mode="hybrid_max"] .mode-name::after {
  content: " · HYBRID PLAN";
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--amber, #fbbf24);
}

/* ---------------- Server deployment wizard ---------------- */

.deploy-card {
  margin-bottom: 20px;
}

.deploy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.deploy-head h3 {
  margin: 0;
}

.deploy-phase {
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--muted, #8b98a5);
}

.deploy-phase[data-phase="connecting"],
.deploy-phase[data-phase="installing"],
.deploy-phase[data-phase="securing"],
.deploy-phase[data-phase="setting_up_https"],
.deploy-phase[data-phase="verifying"] {
  border-color: rgba(94, 234, 212, 0.5);
  color: var(--teal, #5eead4);
  background: rgba(94, 234, 212, 0.08);
  animation: deploy-phase-pulse 1.6s ease-in-out infinite;
}

.deploy-phase[data-phase="awaiting_dns"] {
  border-color: rgba(251, 191, 36, 0.5);
  color: var(--amber, #fbbf24);
  background: rgba(251, 191, 36, 0.08);
  animation: deploy-phase-pulse 1.6s ease-in-out infinite;
}

.deploy-phase[data-phase="done"] {
  border-color: rgba(74, 222, 128, 0.5);
  color: var(--green, #4ade80);
  background: rgba(74, 222, 128, 0.1);
}

.deploy-phase[data-phase="error"] {
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--red, #f87171);
  background: rgba(248, 113, 113, 0.1);
}

@keyframes deploy-phase-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.deploy-form {
  margin-top: 12px;
  transition: opacity 0.2s ease;
}

.deploy-update {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
  transition: opacity 0.2s ease;
}

.deploy-update h4 {
  font-size: 14px;
  margin-bottom: 6px;
}

.dns-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.06);
}

.dns-panel h4 {
  margin: 0 0 8px;
  color: var(--amber, #fbbf24);
}

.dns-panel p {
  margin: 0 0 10px;
  font-size: 13px;
}

.dns-record {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 13px;
}

.dns-record strong {
  color: var(--teal, #5eead4);
  margin-left: 4px;
}

.deploy-done {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(74, 222, 128, 0.4);
  border-radius: 12px;
  background: rgba(74, 222, 128, 0.07);
}

.deploy-done h4 {
  margin: 0 0 8px;
  color: var(--green, #4ade80);
}

.deploy-done p {
  margin: 0 0 10px;
  font-size: 13px;
}

.deploy-site-url {
  display: inline-block;
  font-size: 20px;
  font-weight: 700;
  color: var(--teal, #5eead4);
  margin-bottom: 12px;
  text-decoration: none;
}

.deploy-site-url:hover {
  text-decoration: underline;
}

.deploy-error {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.07);
}

.deploy-error h4 {
  margin: 0 0 8px;
  color: var(--red, #f87171);
}

.deploy-error p {
  margin: 0 0 8px;
  font-size: 13px;
}

.deploy-console {
  margin-top: 16px;
  max-height: 320px;
  overflow-y: auto;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(148, 163, 184, 0.14));
  background: #05080b;
  color: #9ef0d3;
  font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (prefers-reduced-motion: reduce) {
  .deploy-phase[data-phase] {
    animation: none !important;
  }
}

/* ---------------- BYOD ---------------- */

.byod-badge {
  display: inline-block;
  padding: 1px 8px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1px solid rgba(94, 234, 212, 0.45);
  color: var(--teal, #5eead4);
  background: rgba(94, 234, 212, 0.08);
  vertical-align: middle;
}
