/* ══════════════════════════════════════════════════════════════════════════
   Autopicker — design system
   "Ink & Iris": a near-monochrome graphite chrome with one restrained iris
   accent, a display serif for brand moments, hairline-forward surfaces, and
   tabular figures on every metric.
   ══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;

  --bg:            #f6f7f9;
  --bg-raised:     #ffffff;
  --surface:       #ffffff;
  --bg-sunken:     #eef0f4;
  --bg-hover:      #f1f3f7;
  --bg-active:     #e6eaf0;

  --text:          #14161c;
  --text-soft:     #57606f;
  --text-mute:     #8a93a2;

  --border:        #e7e9ef;
  --border-strong: #d6dae2;

  /* iris accent — links, focus, gauges, selected states */
  --primary:       #5b4be6;
  --primary-hover: #4c3dd6;
  --primary-weak:  #eeecfd;

  /* ink — primary actions & active tabs (the near-black premium tone) */
  --ink:           #17181d;
  --ink-hover:     #000000;
  --ink-contrast:  #ffffff;

  --success:       #0f9d58;
  --success-weak:  #e6f5ec;
  --warning:       #b9720c;
  --warning-weak:  #fbf2e2;
  --danger:        #dc3b45;
  --danger-weak:   #fcecec;

  --ring:          rgba(91, 75, 230, .30);

  --shadow-xs: 0 1px 2px rgba(20, 22, 28, .04);
  --shadow-sm: 0 1px 3px rgba(20, 22, 28, .06), 0 1px 2px rgba(20, 22, 28, .04);
  --shadow-md: 0 12px 30px -10px rgba(20, 22, 28, .16), 0 4px 10px -4px rgba(20, 22, 28, .07);
  --shadow-lg: 0 32px 64px -18px rgba(20, 22, 28, .28), 0 10px 24px -12px rgba(20, 22, 28, .14);

  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-full: 999px;

  --header-h: 66px;
  --maxw: 1400px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0b0c11;
  --bg-raised:     #14151b;
  --surface:       #14151b;
  --bg-sunken:     #101117;
  --bg-hover:      #1b1d26;
  --bg-active:     #232634;

  --text:          #edeef2;
  --text-soft:     #aeb6c4;
  --text-mute:     #767f8f;

  --border:        #23262f;
  --border-strong: #333744;

  --primary:       #8b7dff;
  --primary-hover: #9c90ff;
  --primary-weak:  #201d3a;

  /* in dark the primary action inverts to near-white — reads expensive */
  --ink:           #f3f4f7;
  --ink-hover:     #ffffff;
  --ink-contrast:  #14151b;

  --success:       #35c97a;
  --success-weak:  #10241a;
  --warning:       #efa441;
  --warning-weak:  #2b2010;
  --danger:        #f05a63;
  --danger-weak:   #2d1519;

  --ring:          rgba(139, 125, 255, .38);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .55), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 12px 30px -10px rgba(0, 0, 0, .62), 0 4px 10px -4px rgba(0, 0, 0, .5);
  --shadow-lg: 0 32px 64px -18px rgba(0, 0, 0, .72), 0 10px 24px -12px rgba(0, 0, 0, .55);
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

*, *::before, *::after {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-mute); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

body {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Faint dot-grid canvas that fades out toward the fold — premium tooling texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  color: var(--border);
  opacity: .6;
  background-image: radial-gradient(currentColor .75px, transparent .75px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 120% 78% at 50% 0%, #000 28%, transparent 74%);
          mask-image: radial-gradient(ellipse 120% 78% at 50% 0%, #000 28%, transparent 74%);
}

button { font-family: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: color-mix(in srgb, var(--primary) 26%, transparent); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gauge-mini-num, .stat .v, .bal .v, .slider-top .val, .dial-state,
.meter-row, .mini-title, table.data td, .lead-ago {
  font-variant-numeric: tabular-nums;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--ink);
  color: var(--ink-contrast);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .10);
}
.brand-mark svg { width: 19px; height: 19px; display: block; }
.brand-mark .dot { fill: var(--primary); }

.brand-text { min-width: 0; line-height: 1.15; }
.brand-word {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--text);
}
.brand-sub {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.header-actions { display: flex; align-items: center; gap: .55rem; }

/* Persistent "cookies expired" alert — visible from every view until fixed */
.session-alert {
  flex: none;
  max-width: 46vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: alertPulse 2s ease-in-out infinite;
}
@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 0%, transparent); }
}

.avatar {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--ink-contrast);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
  user-select: none;
  cursor: pointer;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: transform .12s ease, box-shadow .2s ease;
}
.avatar:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ── Account menu ─────────────────────────────────────────────────────────── */
.acct-wrap { position: relative; }
.acct-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 232px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: .4rem;
  z-index: 60;
  animation: menuIn .16s ease;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }
.acct-menu-head { padding: .55rem .65rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .35rem; }
.acct-menu-name { font-weight: 700; font-size: .86rem; }
.acct-menu-mail { font-size: .74rem; color: var(--text-mute); word-break: break-all; margin-top: .1rem; }
.acct-menu-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .55rem .65rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-soft);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  transition: background .12s ease, color .12s ease;
}
.acct-menu-item:hover { background: var(--bg-hover); color: var(--text); }
.acct-menu-item.danger { color: var(--danger); }
.acct-menu-item.danger:hover { background: var(--danger-weak); }
.acct-menu-sep { height: 1px; background: var(--border); margin: .35rem 0; }

/* ── Account details modal ───────────────────────────────────────────────── */
.info-group { margin-bottom: 1.1rem; }
.info-group:last-child { margin-bottom: 0; }
.info-group-title {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-mute);
  margin-bottom: .45rem;
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.info-row:last-child { border-bottom: none; }
.info-row span { color: var(--text-mute); }
.info-row b { text-align: right; word-break: break-word; font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .52rem .95rem;
  font-size: .83rem;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease,
              color .15s ease, transform .06s ease;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ink-contrast);
  box-shadow: var(--shadow-xs), 0 8px 18px -10px color-mix(in srgb, var(--ink) 65%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, .10);
}
.btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }

.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(.94); }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-block { width: 100%; }
.btn-lg { padding: .72rem 1.05rem; font-size: .9rem; border-radius: var(--r-md); }
.btn-sm { padding: .34rem .6rem; font-size: .74rem; border-radius: 7px; }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background .15s ease, color .15s ease, transform .5s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
#btnRefreshConn:active, #btnRefreshUsers:active { transform: rotate(-360deg); }

/* ── Auth screen ─────────────────────────────────────────────────────────── */
.auth-wrap {
  position: relative;
  min-height: calc(100vh - var(--header-h));
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(38rem 24rem at 50% 8%, color-mix(in srgb, var(--primary) 8%, transparent), transparent 70%);
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2.25rem;
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -.005em;
  text-align: center;
}
.auth-card .sub { color: var(--text-soft); font-size: .88rem; margin: .5rem 0 1.7rem; text-align: center; }

/* premium sign-in: brand lockup above the form, soft vignette behind the card */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  margin-bottom: 1.5rem;
}
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
.auth-brand .brand-mark svg { width: 26px; height: 26px; }
.auth-brand .brand-word { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; }
.auth-foot {
  margin-top: 1.35rem;
  text-align: center;
  font-size: .77rem;
  color: var(--text-mute);
}
.form-error {
  margin-top: .9rem;
  padding: .65rem .85rem;
  border-radius: var(--r-sm);
  background: var(--danger-weak);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  font-size: .82rem;
  font-weight: 500;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: .95rem; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: .38rem;
}
.input, .select, .textarea {
  width: 100%;
  padding: .64rem .8rem;
  font-size: .88rem;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-mute); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring);
}
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
                    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.textarea { resize: vertical; min-height: 92px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .82rem; }
.check-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* toggle switch */
.switch { display: inline-block; position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-full);
  transition: background .18s ease;
}
.switch span::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s cubic-bezier(.4, 0, .2, 1);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ── App shell: left sidebar + main ─────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  align-items: start;
}
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: 1rem .7rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .58rem .7rem;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: .855rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--ink); color: var(--ink-contrast); }
.nav-item:disabled { opacity: .42; cursor: not-allowed; }
.nav-ico { width: 17px; height: 17px; flex: none; }
.app-main { min-width: 0; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    gap: .3rem;
    padding: .55rem .75rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
}

/* ── Console dashboard layout ────────────────────────────────────────────── */
.workspace {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* generic page (Analysis, Reverts, …) */
.page { max-width: var(--maxw); margin: 0 auto; padding: 1.6rem 1.5rem; }
.page-head { margin-bottom: 1.25rem; }
.page-head h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.page-sub { font-size: .85rem; color: var(--text-mute); margin-top: .3rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

.empty-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .5rem;
  padding: 4rem 1.5rem;
}
.empty-page-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--text-mute) 0 4px, transparent 5px) center / 100% 100% no-repeat,
    var(--bg-sunken);
  border: 1px solid var(--border);
  margin-bottom: .4rem;
}
.empty-page-title { font-weight: 700; font-size: .95rem; }
.empty-page-sub { font-size: .82rem; color: var(--text-mute); max-width: 34ch; }

/* Setup — the two configuration entry points, surfaced as tappable tiles
   instead of buttons buried in an unrelated card header */
.setup-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.setup-tile {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .95rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.setup-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.setup-tile:active { transform: translateY(0); }
.setup-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.setup-tile-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--primary-weak);
  color: var(--primary);
}
.setup-tile-ico svg { width: 19px; height: 19px; }
.setup-tile-body { flex: 1; min-width: 0; }
.setup-tile-title { display: block; font-weight: 700; font-size: .92rem; letter-spacing: -.01em; }
.setup-tile-sub {
  display: block;
  font-size: .78rem;
  color: var(--text-mute);
  margin-top: .18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setup-tile-chev { flex: none; color: var(--text-mute); font-size: 1.2rem; line-height: 1; }
@media (max-width: 640px) { .setup-strip { grid-template-columns: 1fr; } }

/* status + progress: one slim row */
.console-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 1160px) { .console-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .console-strip { grid-template-columns: 1fr; } }

/* feeds: leads + live monitor, equal weight, side by side */
.console-feeds {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}
@media (max-width: 1024px) { .console-feeds { grid-template-columns: 1fr; } }

/* Shared card surface — hairline-forward, near-flat; depth is reserved for
   modals, menus and the engine bar */
.mini-card, .monitor-card, .stat, .panel, .engine-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

/* ── Engine control bar (replaces the hero dial) ─────────────────────────── */
.engine-bar { padding: 0; overflow: hidden; }
.dial {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.15rem 1.4rem;
  border: none;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: background .2s ease;
}
.dial:hover { background: var(--bg-hover); }
.dial:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.dial::after {   /* ambient status wash sweeping in from the left edge */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(32rem 18rem at 0% 50%, color-mix(in srgb, var(--success) 16%, transparent), transparent 70%);
  transition: opacity .35s ease;
}

.dial-led {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-mute);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text-mute) 16%, transparent);
  transition: background .2s ease, box-shadow .2s ease;
}
.dial-inner { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.dial-state { font-size: 1.3rem; font-weight: 800; letter-spacing: .05em; line-height: 1.08; color: var(--text); }
.dial-hint {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.dial-switch {
  flex: none;
  width: 58px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  position: relative;
  transition: background .22s ease;
}
.dial-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}

.dial.is-running .dial-state { color: var(--success); }
.dial.is-running .dial-led { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 24%, transparent); }
.dial.is-running .dial-switch { background: var(--success); }
.dial.is-running .dial-switch::after { transform: translateX(26px); }
.dial.is-running::after { opacity: 1; animation: dialGlow 3s ease-in-out infinite; }
@keyframes dialGlow { 0%, 100% { opacity: .35; } 50% { opacity: .8; } }

/* engine looping but blocked on expired IndiaMART cookies */
.dial.is-stalled .dial-state,
.dial.is-stalled .dial-hint { color: var(--danger); }
.dial.is-stalled .dial-led { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 24%, transparent); }
.dial.is-stalled .dial-switch { background: var(--danger); }
.dial.is-stalled .dial-switch::after { transform: translateX(26px); }
.dial.is-stalled::after {
  opacity: 1;
  animation: none;
  background: radial-gradient(32rem 18rem at 0% 50%, color-mix(in srgb, var(--danger) 16%, transparent), transparent 70%);
}

@media (max-width: 480px) {
  .dial { flex-wrap: wrap; gap: .7rem 1rem; justify-content: space-between; }
  .dial-inner { order: 3; flex-basis: 100%; }
}

/* ── Status + progress tiles ─────────────────────────────────────────────── */
.mini-card {
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.mini-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); border-color: var(--border-strong); }
.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-bottom: .8rem;
}
.mini-head .tools { display: flex; align-items: center; gap: .45rem; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-mute);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-mute) 20%, transparent);
}
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent); }
.mini-body { display: flex; align-items: flex-start; gap: .75rem; }
.mini-ico {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: .95rem;
}
.mini-title { font-weight: 700; font-size: .92rem; }
.mini-sub { font-size: .78rem; color: var(--text-mute); margin-top: .12rem; }
.mini-link {
  display: inline-block;
  margin-top: .35rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.mini-link:hover { text-decoration: underline; }
.mini-link.urgent {
  margin-top: .45rem;
  padding: .28rem .6rem;
  border-radius: var(--r-sm);
  background: var(--danger);
  color: #fff;
}
.mini-link.urgent:hover { text-decoration: none; filter: brightness(.94); }

/* ── Re-login banner ─────────────────────────────────────────────────────── */
.relogin-banner {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1.05rem;
  background: var(--danger-weak);
  border: 1px solid color-mix(in srgb, var(--danger) 26%, transparent);
  border-radius: var(--r-md);
  font-size: .85rem;
  color: var(--danger);
}
.relogin-banner .msg { flex: 1; font-weight: 600; }

/* ── Rate-limit banner ──────────────────────────────────────────────────── */
.ratelimit-banner {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1.05rem;
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 30%, transparent);
  border-radius: var(--r-md);
  font-size: .85rem;
  color: #b45309;
  animation: rl-pulse 2s ease-in-out infinite;
}
.ratelimit-banner .msg { flex: 1; font-weight: 600; }
.ratelimit-banner strong { color: #92400e; }
@keyframes rl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}
[data-theme="dark"] .ratelimit-banner {
  background: color-mix(in srgb, #f59e0b 15%, transparent);
  color: #fbbf24;
}
[data-theme="dark"] .ratelimit-banner strong { color: #fcd34d; }

/* mini "cap" chip in a tile header */
.mini-cap {
  padding: .08rem .42rem;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-mute);
  letter-spacing: .06em;
}

/* ── Progress tiles (compact donut + text) ──────────────────────────────── */
.gauge-mini .mini-head { margin-bottom: .2rem; }
.gauge-mini-body { display: flex; align-items: center; gap: .85rem; margin-top: .55rem; }
.donut { width: 56px; height: 56px; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.donut .track { fill: none; stroke: var(--border); stroke-width: 13; }
.donut .fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 13;
  stroke-linecap: round;
  transition: stroke-dashoffset .7s cubic-bezier(.4, 0, .2, 1);
}
.gauge-mini-txt { min-width: 0; }
.gauge-mini-num { font-weight: 800; letter-spacing: -.01em; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge-mini-num b { font-size: 1.25rem; }
.gauge-mini-num span { font-size: .74rem; font-weight: 600; color: var(--text-mute); }
.gauge-mini-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }

/* ── Pills / badges ──────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.4;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-soft);
  white-space: nowrap;
}
.pill.green { background: var(--success-weak); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.pill.red   { background: var(--danger-weak);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.pill.amber { background: var(--warning-weak); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 24%, transparent); }

/* ── Live monitor / leads ────────────────────────────────────────────────── */
.monitor-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.monitor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem .9rem;
  padding: 1.05rem 1.3rem .8rem;
}
.monitor-head h2 { font-size: 1.02rem; font-weight: 800; letter-spacing: -.015em; }
.monitor-counts { display: flex; gap: .4rem; flex-wrap: wrap; }

/* header toolbar: section title + its quick actions (Limits / Filters, etc.) */
.monitor-head-l {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem;
  min-width: 0;
}
.monitor-head-l h2 { margin-right: .35rem; }
.monitor-head-l .btn {
  flex: none;
  padding: .32rem .62rem;
  font-size: .75rem;
  background: var(--bg-sunken);
  border-color: transparent;
  box-shadow: none;
}
.monitor-head-l .btn:hover { background: var(--bg-hover); border-color: transparent; }

/* header toolbar: counts + actions, right-aligned opposite the title */
.monitor-head-r { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.btn-ico { flex: none; width: 14px; height: 14px; }

.scope-tag {
  display: inline-block;
  margin-left: .5rem;
  padding: .1rem .5rem;
  border-radius: var(--r-full);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-weak);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  vertical-align: middle;
}

/* both feeds get an equal internal scroll area */
.console-feeds .monitor-list { max-height: 58vh; min-height: 260px; }
@media (max-width: 1024px) { .console-feeds .monitor-list { max-height: 46vh; } }

.monitor-tabs {
  display: flex;
  gap: .35rem;
  padding: 0 1.3rem .9rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.monitor-tabs::-webkit-scrollbar { display: none; }
.mtab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .36rem .75rem;
  font-size: .77rem;
  font-weight: 600;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.mtab:hover { background: var(--bg-hover); color: var(--text); }
.mtab.active {
  background: var(--ink);
  color: var(--ink-contrast);
  box-shadow: var(--shadow-xs);
}
.mtab .count {
  font-size: .66rem;
  font-weight: 700;
  background: color-mix(in srgb, currentColor 14%, transparent);
  border-radius: var(--r-full);
  padding: 0 .36rem;
  min-width: 1.1rem;
  text-align: center;
}

.monitor-list {
  flex: 1;
  overflow-y: auto;
  padding: .55rem .8rem;
  min-height: 168px;
}
.monitor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .7rem;
  text-align: center;
  color: var(--text-mute);
  font-size: .82rem;
  padding: 3rem 1.5rem;
}
.monitor-empty::before {
  content: "";
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--text-mute) 0 3.5px, transparent 4.5px) center / 100% 100% no-repeat,
    var(--bg-sunken);
  border: 1px solid var(--border);
}

.lead-row {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: .75rem;
  padding: .7rem .6rem .7rem .7rem;
  border-radius: var(--r-sm);
  transition: background .14s ease;
}
.lead-row::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: transparent;
  transition: background .14s ease;
}
.lead-row:hover { background: var(--bg-hover); }
.lead-row:hover::before { background: var(--primary); }
.lead-row.dim { opacity: .55; }
.lead-row.dim:hover { opacity: 1; }
.lead-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 2px 6px -2px rgba(17, 24, 39, .25);
}
.lead-main { min-width: 0; }
.lead-title {
  font-weight: 700;
  font-size: .86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-meta {
  font-size: .74rem;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .08rem;
}
.lead-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.lead-side { text-align: right; white-space: nowrap; }
.lead-status { font-size: .74rem; font-weight: 700; }
.lead-status.purchased { color: var(--success); }
.lead-status.lost { color: var(--danger); }
.lead-status.lead_skipped { color: var(--warning); }
.lead-status.skipped { color: var(--warning); }
.lead-status.scanned { color: var(--text-mute); }
.lead-ago { font-size: .7rem; color: var(--text-mute); margin-top: .18rem; }

/* Purchased-lead receipt — explicit purchase time, keyword and contact signals */
.purchased-row::before { background: var(--success); }
.lead-detail {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1rem;
  margin-top: .3rem;
  font-size: .74rem;
  color: var(--text-soft);
}
.ld-item { white-space: nowrap; }
.ld-k {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-right: .15rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  padding: .16rem .5rem;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-soft);
}
.chip.ok { background: var(--success-weak); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.chip.no { background: var(--bg-sunken); color: var(--text-mute); border-color: var(--border); }
.chip.sm { padding: .06rem .42rem; font-size: .64rem; font-weight: 700; vertical-align: middle; margin-left: .1rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-editable {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .4rem .22rem .6rem;
  border-radius: var(--r-full);
  font-size: .78rem; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-sunken); color: var(--text-soft);
}
.chip-editable button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: none; background: transparent; color: var(--text-mute);
  font-size: .8rem; line-height: 1; cursor: pointer;
}
.chip-editable button:hover { background: var(--danger-weak); color: var(--danger); }

.log-line {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: .75rem;
  line-height: 1.6;
  padding: .32rem .55rem;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  transition: background .12s ease;
}
.log-line:hover { background: var(--bg-hover); }
.log-line .t { color: var(--text-mute); }
.log-line.ERROR { color: var(--danger); }
.log-line.WARN { color: var(--warning); }
.log-line.SUCCESS { color: var(--success); }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, #0b0d14 58%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  overflow-y: auto;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.98);
  opacity: .6;
  transition: transform .22s cubic-bezier(.4, 0, .2, 1), opacity .22s ease;
}
.overlay.open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal.wide { max-width: 684px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.4rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; letter-spacing: -.005em; line-height: 1.2; }
.modal-head .sub { font-size: .8rem; line-height: 1.45; color: var(--text-mute); margin-top: .25rem; }
.modal-x {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.modal-x:hover { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.modal-body { padding: 1.3rem 1.4rem; }
.modal-body.scroll { max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: .55rem;
  padding: .95rem 1.4rem;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-foot .btn { min-width: 5rem; }

/* segmented tabs (re-login) */
.seg {
  display: flex;
  gap: .3rem;
  padding: .3rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 1.3rem;
}
.seg button {
  flex: 1;
  padding: .55rem;
  font-size: .84rem;
  font-weight: 700;
  color: var(--text-soft);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.active { color: var(--primary); background: var(--surface); box-shadow: var(--shadow-xs); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

/* collapsible sections (Filters modal) */
.acc {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: .7rem;
  overflow: hidden;
  transition: border-color .15s ease;
}
.acc:last-child { margin-bottom: 0; }
.acc.open { border-color: var(--border-strong); }
.acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.05rem;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: .875rem;
  letter-spacing: -.005em;
  transition: background .14s ease, color .14s ease;
}
.acc-head:hover { background: var(--bg-hover); }
.acc.open .acc-head { color: var(--primary); }
.acc-head-l { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.acc-ico { flex: none; width: 16px; height: 16px; color: var(--text-mute); }
.acc.open .acc-ico { color: var(--primary); }
.acc-head-r { display: flex; align-items: center; gap: .6rem; flex: none; }
.acc-count {
  min-width: 1.4rem;
  padding: .1rem .4rem;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  color: var(--text-mute);
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
}
.acc.open .acc-count { background: var(--primary-weak); color: var(--primary); }
.acc-head .chev { flex: none; color: var(--text-mute); font-size: 1.05rem; line-height: 1; transition: transform .2s ease; }
.acc.open .acc-head .chev { transform: rotate(90deg); color: var(--primary); }
.acc-body { display: none; padding: 1.05rem; border-top: 1px solid var(--border); background: var(--bg-sunken); }
.acc.open .acc-body { display: block; }
.acc-body > :last-child { margin-bottom: 0; }
.acc-note { font-size: .78rem; line-height: 1.5; color: var(--text-mute); margin-bottom: .8rem; }
.acc-note.sm { margin: .4rem 0 0; }
/* an empty rule list renders just a note — don't double up the gap before the add box */
#kwList > .acc-note:only-child,
#exList > .acc-note:only-child,
#locList > .acc-note:only-child { margin-bottom: 0; }

/* rule list rows */
.rule-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .8rem .9rem;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.rule-box:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.rule-box + .rule-box { margin-top: .5rem; }
.rule-row { display: flex; align-items: center; gap: .8rem; }
.rule-row .rule-info { flex: 1; min-width: 0; }
.rule-name { font-weight: 700; font-size: .875rem; overflow-wrap: anywhere; }
.rule-iso { color: var(--text-mute); font-weight: 600; font-size: .78rem; }
.rule-sub { font-size: .74rem; color: var(--text-mute); margin-top: .15rem; }
.rule-sub b { color: var(--text-soft); font-weight: 700; }
.rule-actions { display: flex; gap: .35rem; flex: none; }
.mini-x, .mini-edit {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: .85rem;
  transition: background .14s ease, color .14s ease;
}
.mini-x:hover { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.mini-edit:hover { background: var(--bg-hover); color: var(--text); }

.add-box {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: .95rem 1rem;
  margin-top: .6rem;
}
.add-box .lbl { font-size: .8rem; font-weight: 600; color: var(--text-soft); margin-bottom: .55rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stack > * + * { margin-top: .5rem; }
.ke-actions { display: flex; gap: .5rem; justify-content: flex-end; }

/* balance cards (limits) */
.bal-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1rem; }
.bal {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .9rem 1rem;
  background: var(--bg-sunken);
}
.bal.green { background: var(--success-weak); border-color: color-mix(in srgb, var(--success) 24%, transparent); }
.bal.blue  { background: var(--primary-weak); border-color: color-mix(in srgb, var(--primary) 24%, transparent); }
.bal .k { font-size: .62rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.bal .v { font-size: 1.55rem; font-weight: 800; margin: .12rem 0; letter-spacing: -.02em; }
.bal .d { font-size: .72rem; color: var(--text-mute); }

.meter-row { display: flex; justify-content: space-between; font-size: .82rem; padding: .32rem 0; }
.meter-row.strong { font-weight: 700; }
.meter-bar {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--border);
  overflow: hidden;
  margin: .35rem 0 1.1rem;
}
.meter-bar > span {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #8b5cff));
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}

.slider-block { margin-top: 1.15rem; }
.slider-top { display: flex; align-items: baseline; justify-content: space-between; }
.slider-top .lab { font-weight: 700; font-size: .9rem; }
.slider-top .val { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.slider-top .val small { font-size: .7rem; color: var(--text-mute); font-weight: 600; }
.slider-sub { font-size: .74rem; color: var(--text-mute); margin-top: .12rem; }
.slider-ends { display: flex; justify-content: space-between; font-size: .68rem; color: var(--text-mute); }

/* Daily / weekly limit inputs */
.limit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 520px) { .limit-grid { grid-template-columns: 1fr; } }
.limit-field label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: .4rem;
}
.limit-input { display: flex; align-items: center; gap: .5rem; }
.limit-input .input {
  flex: 1;
  width: auto;
  min-width: 0;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: .55rem .7rem;
}
.limit-unit { flex: none; font-size: .78rem; font-weight: 600; color: var(--text-mute); }
.limit-hint { margin-top: .45rem; font-size: .74rem; color: var(--text-mute); }
.limit-note {
  margin-top: 1rem;
  padding: .65rem .85rem;
  border-radius: var(--r-sm);
  background: var(--warning-weak);
  border: 1px solid color-mix(in srgb, var(--warning) 26%, transparent);
  color: var(--warning);
  font-size: .8rem;
  font-weight: 500;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: .7rem 0 .3rem;
  border-radius: var(--r-full);
  background: var(--border);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, box-shadow .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { box-shadow: 0 0 0 6px var(--ring); }
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: var(--r-full); background: var(--border); }
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Admin console ───────────────────────────────────────────────────────── */
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.5rem; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.stat {
  border-radius: var(--r-md);
  padding: 1.15rem 1.25rem;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.stat .k { font-size: .64rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); }
.stat .v { font-size: 1.75rem; font-weight: 800; margin-top: .35rem; letter-spacing: -.02em; }
.stat .d { font-size: .75rem; color: var(--text-mute); margin-top: .1rem; }

.panel { border-radius: var(--r-lg); overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.15rem 1.3rem;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 1.02rem; font-weight: 800; letter-spacing: -.015em; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data th {
  text-align: left;
  font-size: .66rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg-hover); }

/* ── Lead History modal ────────────────────────────────────────────────── */
.modal.xl { max-width: min(960px, 94vw); }

.hist-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.hist-filter { padding: 0; border-bottom: none; flex: 1; }
.hist-count {
  flex: none;
  font-size: .74rem;
  font-weight: 600;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hist-body { padding: 0; }
/* single scroll container (both axes) so the sticky <thead> actually sticks */
.hist-body .table-scroll { max-height: 64vh; overflow: auto; }

.hist-table { font-size: .84rem; }
.hist-table thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
}
.hist-table td { padding: .7rem 1rem; vertical-align: top; }
.hist-table tbody tr:hover td { background: var(--bg-hover); }
.hist-table tbody tr.hist-day:hover td,
.hist-table tbody tr.hist-blank:hover td { background: transparent; }

.hist-time { white-space: nowrap; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.hist-title {
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.hist-sub { margin-top: .15rem; font-size: .74rem; color: var(--text-mute); }
.hist-kw {
  display: inline-block;
  max-width: 100%;
  padding: .1rem .5rem;
  border-radius: var(--r-full);
  background: var(--primary-weak);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-dash { color: var(--text-mute); }
.hist-contact { white-space: nowrap; color: var(--text-soft); font-size: .8rem; }
.hist-reason { margin-top: .3rem; font-size: .72rem; color: var(--text-mute); max-width: 22ch; margin-left: auto; }
.ta-r { text-align: right; }

/* Date separators — quiet, full-width, not sticky (avoids header overlap glitches) */
tr.hist-day td {
  padding: .8rem 1rem .45rem;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-mute);
}
tr.hist-day:first-child td { padding-top: .45rem; }

/* Empty / error state */
.hist-blank td { padding: 0; }
.hist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  text-align: center;
  padding: 3.5rem 1.5rem;
}
.hist-empty-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--text-mute) 0 3.5px, transparent 4.5px) center / 100% 100% no-repeat,
    var(--bg-sunken);
  border: 1px solid var(--border);
  margin-bottom: .3rem;
}
.hist-empty-title { font-weight: 700; font-size: .9rem; }
.hist-empty-sub { font-size: .8rem; color: var(--text-mute); }

/* Responsive: below 720px each row becomes a labelled card */
@media (max-width: 720px) {
  .hist-table thead { display: none; }
  .hist-table, .hist-table tbody, .hist-table tr, .hist-table td { display: block; width: auto; }
  .hist-table tbody tr:not(.hist-day):not(.hist-blank) {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin: .6rem .9rem;
    background: var(--surface);
    overflow: hidden;
  }
  .hist-table tbody tr:hover td { background: transparent; }
  .hist-table td { padding: .5rem .9rem; border: none; text-align: left; white-space: normal; }
  .hist-table td + td { border-top: 1px solid var(--border); }
  .hist-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .15rem;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-mute);
  }
  .hist-table td.ta-r { text-align: left; }
  .hist-reason { margin: .3rem 0 0; max-width: none; text-align: left; }
  tr.hist-day { margin: 1.1rem .9rem 0; }
  tr.hist-day td { padding: 0 0 .4rem; border-bottom: 1px solid var(--border); }
  tr.hist-day td::before { content: none; }
}

/* ── Lead Analysis page ────────────────────────────────────────────────── */
.an-card { overflow: hidden; }
.an-toolbar {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: .9rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.an-range { padding: 0; border-bottom: none; }
.an-custom { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.an-custom .input { width: auto; flex: 0 1 158px; }
.an-custom span { color: var(--text-mute); font-size: .8rem; }

.an-body { padding: 1.4rem; }
.an-range-label { font-size: .8rem; font-weight: 600; color: var(--text-soft); margin-bottom: 1.1rem; }

.an-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: .75rem;
}
.an-kpis .stat { padding: .85rem .95rem; border-radius: var(--r-md); }
.an-kpis .stat .k { font-size: .62rem; }
.an-kpis .stat .v { font-size: 1.4rem; margin-top: .2rem; }
.an-kpis .stat-good .v { color: var(--success); }
.an-kpis .stat-warn .v { color: var(--warning); }
.an-kpis .stat-bad  .v { color: var(--danger); }

/* sub-tabs (Overview / Time Patterns / Countries / …) */
.an-subnav { padding: 0; border-bottom: 1px solid var(--border); margin: 1.5rem 0 1.5rem; }

.an-block { margin-top: 1.6rem; }
.an-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.an-block-head h4 {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.an-block-head span { font-size: .72rem; color: var(--text-mute); white-space: nowrap; }

.an-dim { color: var(--text-mute); }

/* chart panes */
.an-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.an-span2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .an-grid2 { grid-template-columns: 1fr; } }

.an-chartbox {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.1rem 1.2rem 1.3rem;
}
.an-chartbox-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .9rem;
}
.an-chartbox-head h4 {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.an-chartbox-head span { font-size: .72rem; color: var(--text-mute); white-space: nowrap; }
.an-chart-wrap { position: relative; height: 230px; }
.an-chart-wrap.tall { height: 320px; }

/* match funnel */
.an-funnel { display: flex; flex-direction: column; gap: .6rem; }
.an-funnel-row { display: grid; grid-template-columns: 110px 1fr auto; gap: .9rem; align-items: center; font-size: .84rem; }
.an-funnel-label { font-weight: 600; }
.an-funnel-track { height: 22px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.an-funnel-fill { height: 100%; border-radius: var(--r-md) 0 0 var(--r-md); min-width: 2px; }
.an-funnel-fill.matched   { background: var(--primary); }
.an-funnel-fill.bought    { background: var(--success); }
.an-funnel-fill.skipped   { background: var(--warning); }
.an-funnel-fill.lost      { background: var(--danger); }
.an-funnel-val { font-variant-numeric: tabular-nums; color: var(--text-soft); white-space: nowrap; }

.an-table { font-size: .84rem; }
.an-table th { background: var(--surface); border-bottom: 1px solid var(--border-strong); }
.an-table td { padding: .6rem 1rem; }
.an-table .hist-kw { font-size: .72rem; }

.an-empty {
  text-align: center;
  color: var(--text-mute);
  font-size: .85rem;
  padding: 2.5rem 1rem;
}

/* ── Engine start / stop flourish ──────────────────────────────────────── */
.engine-fx {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #0b0d14 38%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .3s ease;
}
.engine-fx.show { opacity: 1; }

.engine-fx-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 2.6rem;
  transform: translateY(10px) scale(.96);
  opacity: 0;
  transition: transform .34s cubic-bezier(.2, .8, .2, 1), opacity .3s ease;
}
.engine-fx.show .engine-fx-card { transform: none; opacity: 1; }

.engine-fx-orb {
  position: relative;
  width: 100px;
  height: 100px;
  display: grid;
  place-items: center;
  margin-bottom: 1.15rem;
}
.engine-fx-orb .core {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 26px 5px color-mix(in srgb, var(--success) 55%, transparent);
  transition: background .3s ease, box-shadow .3s ease;
}
.engine-fx-orb .ring {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--success);
  opacity: 0;
}
/* ON — a sonar sweep radiating outward: "we're watching your leads" */
.engine-fx.on .ring { animation: fxSonar 2s ease-out infinite; }
.engine-fx.on .ring:nth-child(2) { animation-delay: .66s; }
.engine-fx.on .ring:nth-child(3) { animation-delay: 1.32s; }
@keyframes fxSonar {
  0%   { transform: scale(1);   opacity: .9; }
  70%  { opacity: .12; }
  100% { transform: scale(3.6); opacity: 0; }
}
/* OFF — the pulses collapse inward and settle */
.engine-fx.off .core { background: var(--text-mute); box-shadow: 0 0 16px 2px color-mix(in srgb, var(--text-mute) 35%, transparent); }
.engine-fx.off .ring { border-color: var(--text-mute); animation: fxSettle .85s ease-in forwards; }
.engine-fx.off .ring:nth-child(2) { animation-delay: .09s; }
.engine-fx.off .ring:nth-child(3) { animation-delay: .18s; }
@keyframes fxSettle {
  0%   { transform: scale(3.4); opacity: .7; }
  100% { transform: scale(1);   opacity: 0; }
}

.engine-fx-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: #fff;
}
.engine-fx-sub {
  font-size: .9rem;
  color: rgba(255, 255, 255, .72);
  margin-top: .4rem;
}

@media (max-width: 480px) {
  .engine-fx-title { font-size: 1.4rem; }
  .engine-fx-card { padding: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .engine-fx.on .ring:first-child { opacity: .5; animation: none; }
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: 372px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .8rem .95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: .84rem;
  font-weight: 500;
  animation: toastIn .24s cubic-bezier(.4, 0, .2, 1);
  transition: opacity .2s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
.toast .tico {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  margin-top: .05rem;
}
.toast.ok .tico { background: var(--success); }
.toast.err .tico { background: var(--danger); }
.toast.warn .tico { background: var(--warning); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }

/* ── Utilities ───────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
