/* Funnel Links dashboard — BioSpoofer-parity analytics + edit (no generation wizard) */

:root {
  --bg: #0b0f19;
  --panel: #121826;
  --panel2: #1a2234;
  --border: #2a3548;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #6366f1;
  --good: #34d399;
  --warn: #f59e0b;
  --bad: #f87171;
  --cyan: #22d3ee;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1e1b4b55, transparent),
    radial-gradient(900px 500px at 100% 0%, #0e749055, transparent), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 0.4rem; }
.panel h2, .panel-title { margin: 0 0 12px; font-size: 0.95rem; display: flex; align-items: center; gap: 0.35rem; }
.kpi .label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: 6px; }

/* Hover info tips (same pattern as Social Ops) */
.ops-info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  outline: none;
}
.ops-info-tip-icon {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(156, 163, 175, 0.95);
  font-size: 0.58rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}
.ops-info-tip:hover .ops-info-tip-icon,
.ops-info-tip:focus .ops-info-tip-icon {
  border-color: rgba(99, 102, 241, 0.55);
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.12);
}
.ops-info-tip-pop {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 20rem;
  padding: 0.42rem 0.58rem;
  border-radius: 8px;
  background: rgba(17, 17, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.4;
  color: rgba(229, 231, 235, 0.95);
  text-align: left;
  white-space: normal;
  text-transform: none;
  letter-spacing: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 60;
}
.ops-info-tip:hover .ops-info-tip-pop,
.ops-info-tip:focus .ops-info-tip-pop,
.ops-info-tip:focus-within .ops-info-tip-pop {
  opacity: 1;
  visibility: visible;
}
.ops-label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select, button, input, textarea {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 12px;
}
button {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}
.tab.active { background: #312e81; color: #fff; border-color: #4338ca; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.kpi-grid-days {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 10px;
}
.kpi-grid-days .kpi {
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0.55));
}
.kpi-grid-days .kpi .value {
  font-size: 1.45rem;
}
.kpi-grid-outcomes {
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  .kpi-grid, .kpi-grid-days, .kpi-grid-outcomes { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .kpi-grid, .kpi-grid-days, .kpi-grid-outcomes { grid-template-columns: 1fr; }
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}
.kpi .label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: 6px; }
.kpi .pct {
  margin-top: 2px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.kpi .pct.good { color: var(--good); }
.kpi .pct.warn { color: var(--warn); }
.kpi .pct.bad { color: var(--bad); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 6px 10px; font-size: 0.78rem; }

.panels,
.panels-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .panels, .panels-2x2 { grid-template-columns: 1fr; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 0;
}
.panel h2 { margin: 0 0 12px; font-size: 0.95rem; }
.bot-learnings-panel summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}
.bot-learnings-panel summary::-webkit-details-marker { display: none; }
.bot-learnings-panel summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.8rem;
}
.bot-learnings-panel[open] summary::before { content: "▾"; }
.bot-learnings-log {
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: #cbd5e1;
  margin: 0;
}
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.funnel-row .funnel-label {
  width: 128px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--text);
}
.funnel-row .funnel-count {
  width: 48px;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
}
.funnel-bar {
  flex: 1;
  height: 10px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
}
.funnel-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-item {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) 1fr 44px;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
}
.bar-item .bar-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-item .bar-flag {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}
.bar-item .bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-item .bar-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.bar-item .track { height: 8px; background: #0f172a; border-radius: 999px; overflow: hidden; }
.bar-item .track > i { display: block; height: 100%; background: var(--good); }
.bar-item.proxy .track > i { background: var(--warn); }
.bar-item.datacenter .track > i { background: var(--cyan); }
.bar-item.google .track > i, .bar-item.bot_ua .track > i { background: var(--bad); }
.bar-item.header_incomplete .track > i { background: #a78bfa; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(99, 102, 241, 0.08); }
code { font-size: 0.8rem; color: #c7d2fe; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.pill-on { background: #064e3b; color: #6ee7b7; }
.pill-off { background: #7f1d1d; color: #fecaca; }
.pill-learn { background: #1e3a8a; color: #bfdbfe; }
.pill-protect { background: #4c1d95; color: #ddd6fe; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; width: min(440px, 100%); height: 100%;
  background: var(--panel); border-left: 1px solid var(--border);
  z-index: 50; padding: 20px; overflow: auto;
}
.drawer h2 { margin: 0 0 4px; }
.form-grid { display: grid; gap: 12px; margin-top: 16px; }
.form-grid label { display: grid; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.form-grid input, .form-grid textarea, .form-grid select { width: 100%; }
.create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  align-items: center;
}
.create-row input {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #334155);
  background: var(--bg, #0f172a);
  color: inherit;
}
.create-row button { white-space: nowrap; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.toast {
  position: fixed; bottom: 20px; right: 20px; background: #312e81; color: #fff;
  padding: 12px 16px; border-radius: 12px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Custom login — never use browser Basic-Auth sheet */
#loginScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% 0%, #312e8155, transparent),
    radial-gradient(700px 400px at 100% 100%, #0e749044, transparent),
    var(--bg);
}
#loginScreen[hidden] { display: none !important; }
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.login-card .sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 20px;
  line-height: 1.45;
}
.login-card label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
}
.login-card input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px #6366f133;
}
.login-card .btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.login-card .btn-row button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
}
.login-card .btn-row button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.login-err {
  color: var(--bad);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0 0 8px;
}
.row-actions{display:flex;gap:6px;flex-wrap:wrap}.row-actions button{padding:6px 10px;font-size:0.78rem}

/* Redesign editor */
.design-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 23, 0.92);
  padding: 16px;
  overflow: auto;
}
.design-shell {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 20px;
  min-height: calc(100vh - 32px);
}
@media (max-width: 900px) {
  .design-shell { grid-template-columns: 1fr; }
}
.design-side {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.design-side-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.design-side-top h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.design-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.design-tab {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  font-weight: 600;
}
.design-tab.active {
  background: #10b981;
  border-color: #10b981;
  color: #042f2e;
}
.design-pane { display: grid; gap: 10px; }
.design-pane label { display: grid; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.design-pane input, .design-pane textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.design-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 6px;
}
.theme-grid, .loader-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.theme-card, .loader-card {
  border: 2px solid transparent;
  border-radius: 12px;
  min-height: 56px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  padding: 8px;
}
.theme-card.active, .loader-card.active {
  border-color: #34d399;
  box-shadow: 0 0 0 2px #34d39955;
}
.loader-card {
  background: var(--panel2);
  color: var(--text);
  text-shadow: none;
  text-transform: capitalize;
}
.gif-upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-check { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; }
.design-save-row {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.design-save {
  background: #10b981;
  color: #042f2e;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}
.design-save:disabled {
  opacity: 0.65;
  cursor: wait;
}
.design-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.phone-frame {
  width: min(320px, 100%);
  aspect-ratio: 9 / 19;
  border-radius: 36px;
  border: 3px solid #334155;
  background: #020617;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  overflow: hidden;
}
.phone-screen {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 22px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.phone-screen .tap-hint {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}
.phone-screen .tap-hint-emoji {
  font-size: 1.85rem;
  line-height: 1;
  animation: tap-bounce 1.35s ease-in-out infinite;
}
.phone-screen .tap-hint-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.2;
}
@keyframes tap-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.bridge-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 22px;
  padding: 22px 16px 18px;
  color: #fff;
  text-align: center;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
}
.bridge-card h3 {
  margin: 0 0 10px;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-align: center;
}
.bridge-card > p {
  margin: 0 0 16px;
  font-size: 0.84rem;
  line-height: 1.5;
  opacity: 0.92;
  text-align: center;
}
.pv-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  border-radius: 14px;
  padding: 12px 12px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
.pv-step span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.pv-gif {
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  background: transparent;
  min-height: 0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}
.pv-gif img { width: 100%; display: block; border-radius: 16px; }
.pv-gif-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px dashed rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
}
.safe-preview { text-align: center; padding-top: 28%; color: inherit; }
.safe-spin {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #10b981;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.safe-badge {
  margin-top: 40px;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.72rem;
  opacity: 0.8;
}
.small { font-size: 0.78rem; }

.geo-block-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.geo-block-field > .label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.geo-block-field input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}
.geo-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
}
.geo-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  flex-direction: row;
}
.geo-chip:hover { background: rgba(99, 102, 241, 0.12); }
.geo-chip input { margin: 0; }
.geo-chip span {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #a5b4fc;
  min-width: 1.6rem;
}
.geo-selected { font-size: 0.75rem; }
