/* ============================================================
   Searchfish — styles
   Palette tokens sourced from the validated data-viz reference.
   ============================================================ */

/* Brand logo typeface (Roundex), self-hosted like searchfish.ai */
@font-face {
  font-family: 'Roundex';
  src: url('/fonts/Roundex.woff2') format('woff2'),
       url('/fonts/Roundex.ttf') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f2f1ec;
  --text:        #0b0b0b;
  --text-2:      #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --border:      rgba(11,11,11,0.10);

  --series-1:    #2a78d6;   /* primary ranking line (blue) */
  --series-1-fill: rgba(42,120,214,0.12);
  --good:        #0ca30c;
  --good-text:   #006300;
  --critical:    #d03b3b;
  --warning:     #fab219;

  /* Searchfish brand palette (from searchfish.ai) */
  --brand:        #006EFE;
  --brand-deep:   #0052CC;
  --brand-cyan:   #34C2FF;
  --brand-navy:   #0a2a5e;
  --brand-gold:   #EFA90B;
  --brand-water:  #EAF2FE;
  --brand-grad:      linear-gradient(135deg, #0d1f4e 0%, #1266f1 60%, #34C2FF 130%);
  --brand-grad-btn:  linear-gradient(135deg, #006EFE 0%, #0052CC 100%);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11,11,11,0.05), 0 8px 24px rgba(11,11,11,0.06);
  --font: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: 'Quicksand', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --font-logo: 'Roundex', 'Quicksand', ui-rounded, system-ui, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-2:   #232320;
  --text:        #ffffff;
  --text-2:      #c3c2b7;
  --muted:       #898781;
  --grid:        #2c2c2a;
  --baseline:    #383835;
  --border:      rgba(255,255,255,0.10);

  --series-1:    #3987e5;
  --series-1-fill: rgba(57,135,229,0.16);
  --good:        #0ca30c;
  --good-text:   #0ca30c;
  --critical:    #e66767;
  --warning:     #fab219;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
.hidden { display: none !important; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Brand */
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-btn { border: none; background: none; padding: 0; cursor: pointer; text-decoration: none; }
.brand-mark { font-size: 1.5rem; }
.brand-logo { height: 33.88px; width: auto; display: block; }
.brand-name { font-family: var(--font-logo); font-weight: 700; font-size: 1.45rem; letter-spacing: -0.01em; color: var(--brand); }

/* Large brand lockup for the login hero */
.hero-brand { display: flex; align-items: center; gap: 0.7rem; }
.hero-logo { width: 52px; height: auto; display: block; }
.hero-brand .brand-name { color: #fff; font-size: 2rem; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.55rem 0.95rem; background: var(--surface); color: var(--text);
  transition: filter 0.12s ease, background 0.12s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--brand-grad-btn); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -8px rgba(0,110,254,0.6); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: 0.7rem; }
.btn-danger { color: var(--critical); }

/* ============ AUTH ============ */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(1100px 520px at 15% -10%, rgba(0,110,254,0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(52,194,255,0.10), transparent 60%),
    var(--page);
}
.auth-shell {
  width: 100%; max-width: min(1240px, 94vw); display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 30px 70px -30px rgba(20,40,90,0.45);
}

/* Left: branded gradient hero */
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  background: var(--brand-grad);
  padding: 3rem 3.2rem; min-height: min(720px, 82vh);
  display: flex; flex-direction: column;
}
.auth-hero .brand-name { color: #fff; }
.auth-hero-copy { position: relative; z-index: 2; margin-top: 1.6rem; margin-bottom: auto; }
.hero-headline {
  font-family: var(--font-display); font-weight: 700;
  font-size: 2.6rem; line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 0.8rem;
}
.hero-sub { color: rgba(255,255,255,0.86); font-size: 1.08rem; line-height: 1.55; max-width: 42ch; margin: 0; }
.hero-points { list-style: none; padding: 0; margin: 1.4rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; }
.hero-points li { display: flex; align-items: center; gap: 0.55rem; color: rgba(255,255,255,0.92); font-size: 0.92rem; font-weight: 500; }
.hero-points .tick {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 999px;
  background: rgba(255,255,255,0.18); color: #fff; font-size: 0.72rem; flex: none;
}
.hero-art { position: absolute; right: 0; top: 0; width: 100%; height: 100%; z-index: 1; opacity: 0.95; pointer-events: none; }
.hero-mascot {
  position: absolute; z-index: 1; right: -5%; top: 46%; width: 62%; max-width: 380px; height: auto;
  pointer-events: none; filter: drop-shadow(0 16px 26px rgba(0,24,70,0.45));
  animation: mascot-float 6s ease-in-out infinite;
}
@keyframes mascot-float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-16px) rotate(-1deg); }
}
@keyframes bubble-rise {
  0%   { transform: translateY(20px); opacity: 0; }
  12%  { opacity: 0.65; }
  85%  { opacity: 0.45; }
  100% { transform: translateY(-520px); opacity: 0; }
}
.hero-art .bub { animation: bubble-rise 9s linear infinite; animation-delay: var(--d, 0s); }
/* Fish swim forward (leftward) across the scene and wrap off-left to off-right. */
.hero-art .fish-cross { animation: fish-cross var(--dur, 20s) linear infinite; animation-delay: var(--dl, 0s); }
@keyframes fish-cross {
  from { transform: translateX(520px); }
  to   { transform: translateX(-100px); }
}
.hero-art .fish-bob { animation: fish-bob var(--bt, 3.5s) ease-in-out infinite; }
@keyframes fish-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(var(--amp, 5px)) rotate(var(--r, -2deg)); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-mascot { animation: none; transform: rotate(-4deg); }
  .hero-art .bub, .hero-art .fish-cross, .hero-art .fish-bob { animation: none; }
}
@media (prefers-reduced-motion: reduce) { .hero-art .fish-cross { transform: translateX(180px); } }

/* Right: form panel */
.auth-card {
  background: var(--surface); padding: 2.6rem 2.4rem;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.auth-card > * { width: 100%; max-width: 420px; }
.auth-card-head { margin-bottom: 1.1rem; }
.auth-card-head h2 { font-family: var(--font-display); font-size: 1.5rem; }
.auth-card-head p { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0 0; }
.tabs { display: flex; gap: 0.25rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.25rem; margin-bottom: 1.1rem; }
.tab {
  flex: 1; border: none; background: transparent; padding: 0.5rem; border-radius: 6px;
  font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 0.85rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  font: inherit; padding: 0.6rem 0.7rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.tab.is-active { color: var(--brand); }
.form-error { color: var(--critical); font-size: 0.85rem; min-height: 1.1rem; margin: 0.6rem 0 0; }

/* Generic inline loading state (spinner + message), e.g. a long-running fetch */
.loading-row {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--muted); font-size: 0.9rem; margin: 0.75rem 0;
}
.spinner {
  width: 1rem; height: 1rem; flex: none; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--brand);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth responsive: stack the hero above the form on small screens */
@media (max-width: 780px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 440px; }
  .auth-hero { min-height: 0; padding: 1.8rem; }
  .hero-headline { font-size: 1.6rem; }
  .hero-art { display: none; }
  .hero-mascot { display: none; }
  .hero-points { display: none; }
  .auth-card { padding: 1.8rem; }
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.who { font-size: 0.9rem; color: var(--text-2); font-weight: 600; }

/* Profile menu — consolidates Admin, theme toggle, and Log out. */
.profile { position: relative; }
.profile > summary { list-style: none; }
.profile > summary::-webkit-details-marker { display: none; }
.profile-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 0.28rem 0.6rem 0.28rem 0.35rem; font: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.profile-btn:hover { background: var(--surface-2); }
.profile[open] .profile-btn { border-color: var(--brand); background: var(--surface-2); }
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; background: var(--brand-grad-btn);
}
.profile-name { font-weight: 600; font-size: 0.9rem; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-caret { font-size: 0.65rem; color: var(--muted); transition: transform 0.15s ease; }
.profile[open] .profile-caret { transform: rotate(180deg); }
.profile-dropdown {
  position: absolute; right: 0; top: calc(100% + 0.45rem); z-index: 50;
  min-width: 200px; display: flex; flex-direction: column; gap: 0.1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 16px 40px -16px rgba(10,42,94,0.4), var(--shadow);
  padding: 0.4rem;
}
.profile-item {
  display: flex; align-items: center; gap: 0.6rem; text-align: left; width: 100%;
  border: none; background: transparent; font: inherit; font-weight: 600; font-size: 0.9rem;
  color: var(--text); padding: 0.6rem 0.65rem; border-radius: 7px; cursor: pointer; text-decoration: none;
}
.profile-item:hover { background: var(--surface-2); }
.profile-item-danger { color: var(--critical); }
.profile-divider { height: 1px; background: var(--border); margin: 0.25rem 0.1rem; }
.admin-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.12rem 0.45rem; border-radius: 6px; background: var(--series-1); color: #fff; margin-left: 0.1rem;
}
.admin-pill {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.05rem 0.4rem; border-radius: 999px; background: var(--series-1); color: #fff; vertical-align: middle;
}
.role-pill {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: middle;
}
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.access-actions { display: inline-flex; gap: 0.4rem; justify-content: flex-end; }
.access-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.access-form input[type="text"], .access-form input[type="email"], .access-form input[type="password"] { flex: 1 1 190px; }
.access-admin-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.access-admin-check input { width: auto; }

/* App-access picker (which Aquarium cards a user can open) */
.app-access { flex: 1 1 100%; border: 1px solid var(--grid); border-radius: 12px; padding: 0.85rem 1rem 1rem; margin: 0.2rem 0 0; min-width: 0; }
.app-access > legend { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); padding: 0 0.4rem; }
.app-access-hint { margin: 0 0 0.65rem; font-size: 0.85rem; }
.app-access-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.4rem 0.9rem; }
.app-access-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 500; color: var(--text); cursor: pointer; padding: 0.15rem 0; }
.app-access-item input { width: auto; margin: 0; accent-color: var(--brand); }

/* Analytics: distribution bar + movers */
.dist-bar { display: flex; height: 24px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.dist-seg { height: 100%; }
.dist-seg + .dist-seg { box-shadow: -2px 0 0 var(--surface); }
.dist-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.85rem; }
.dist-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-2); }
.dist-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.dist-legend-n { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.movers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 720px) { .movers-grid { grid-template-columns: 1fr; } }
.movers-grid .panel { margin-bottom: 0; }
.mover { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--grid); }
.mover:last-child { border-bottom: none; }
.mover-term { font-weight: 600; font-size: 0.92rem; }
.mover-change { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mover-change.up { color: var(--good-text); }
.mover-change.down { color: var(--critical); }

/* ============ DASHBOARD ============ */
.dash { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
/* The ranking page carries extra columns (organic + AI Overview/AI Mode
   Text & References), so it gets a wider canvas than the other dashboards. */
.dash.dash-wide { max-width: 1440px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }

/* margin-bottom lifts the group up from the flex-end baseline so the
   switcher lines up with the subtitle rather than the title's bottom edge. */
.dash-head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; margin-bottom: 0.55rem; }
.user-switcher { display: flex; justify-content: flex-end; align-items: center; gap: 0.6rem; }
.user-switcher label {
  font-size: 0.72rem; font-weight: 700; color: var(--brand-deep);
  text-transform: uppercase; letter-spacing: 0.04em;
}
/* Branded pill-style account switcher. */
.user-switcher select {
  min-width: 230px;
  -webkit-appearance: none; appearance: none;
  padding: 0.5rem 2.3rem 0.5rem 1rem;
  font-weight: 600; color: var(--brand-navy);
  background-color: var(--brand-water);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23006EFE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.85rem center; background-size: 0.85rem;
  border: 1.5px solid rgba(0,110,254,0.35); border-radius: 999px;
  box-shadow: 0 4px 12px -6px rgba(0,110,254,0.45);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.user-switcher select:hover {
  border-color: var(--brand);
  box-shadow: 0 6px 16px -6px rgba(0,110,254,0.6);
}
.user-switcher select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,110,254,0.20);
}
:root[data-theme="dark"] .user-switcher label { color: var(--brand-cyan); }
:root[data-theme="dark"] .user-switcher select {
  color: #e6f0ff; background-color: rgba(0,110,254,0.18);
  border-color: rgba(52,194,255,0.45);
}
.user-switcher-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.85rem; margin: 0 0 1.25rem; }
/* Lighter-blue variant of the primary button for this action row. */
.user-switcher-actions .btn-primary {
  background: linear-gradient(135deg, #4FA4FF 0%, #2D86F5 100%);
  box-shadow: 0 6px 16px -8px rgba(45,134,245,0.55);
}
.user-switcher-actions .btn-primary:hover { filter: brightness(1.05); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
/* Ranking dashboard: fixed 4 per row, so the 5th tile wraps to a new row. */
.dash-wide .stats { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .dash-wide .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  position: relative; overflow: hidden;
  background: var(--brand-grad); border: 1px solid transparent; border-radius: var(--radius);
  padding: 1.15rem 1.25rem; color: #fff;
  box-shadow: 0 12px 24px -12px rgba(0,110,254,0.55), 0 2px 6px -2px rgba(10,42,94,0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
/* Soft radial glow in the corner for depth and a watery sheen. */
.stat::before {
  content: ""; position: absolute; top: -40%; right: -20%;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
}
.stat:hover { transform: translateY(-3px); box-shadow: 0 18px 32px -14px rgba(0,110,254,0.65), 0 3px 8px -2px rgba(10,42,94,0.4); }
.stat-label { position: relative; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: rgba(255,255,255,0.82); font-weight: 700; }
.stat-value { position: relative; font-size: 2.05rem; font-weight: 700; margin-top: 0.25rem; letter-spacing: -0.02em; color: #fff; text-shadow: 0 1px 2px rgba(10,42,94,0.35); }
.stat-sub { position: relative; font-size: 0.8rem; color: rgba(255,255,255,0.78); margin-top: 0.15rem; }

/* App launcher hero */
.launcher-hero {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: var(--brand-grad); color: #fff;
  padding: 0.85rem 2.2rem; margin-bottom: 1.5rem; box-shadow: 0 18px 40px -22px rgba(10,42,94,0.65);
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
}
.launcher-hero-copy { position: relative; z-index: 1; max-width: 62ch; }
.launcher-hero-eyebrow {
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.16em;
  font-size: 0.72rem; font-weight: 700; color: rgba(255,255,255,0.82); margin: 0 0 0.4rem;
}
.launcher-hero h1 { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; margin: 0 0 0.5rem; color: #fff; }
.launcher-hero p { color: rgba(255,255,255,0.9); font-size: 1.02rem; line-height: 1.55; margin: 0; }
.launcher-hero-art { position: relative; z-index: 1; flex: none; height: 84px; width: auto; max-width: 42%; }
@media (max-width: 760px) { .launcher-hero-art { display: none; } .launcher-hero { padding: 1.2rem 1.5rem; } }

/* Movement: rising bubbles, radar pulse, marching trend line, bobbing pennant */
.launcher-hero-bubbles { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.launcher-hero-bubbles .lb { animation: lh-bubble var(--t, 11s) linear infinite; animation-delay: var(--d, 0s); }
@keyframes lh-bubble {
  0%   { transform: translateY(10px); opacity: 0; }
  12%  { opacity: 0.6; }
  85%  { opacity: 0.4; }
  100% { transform: translateY(-150px); opacity: 0; }
}
.launcher-hero-art .ring {
  transform-box: fill-box; transform-origin: center;
  animation: lh-sonar 3.4s ease-out infinite; animation-delay: var(--sd, 0s);
}
@keyframes lh-sonar {
  0%   { transform: scale(0.55); opacity: 0.55; }
  70%  { opacity: 0.12; }
  100% { transform: scale(1.2); opacity: 0; }
}
.launcher-hero-art .trend { animation: lh-dash 1.6s linear infinite; }
@keyframes lh-dash { to { stroke-dashoffset: -10; } }
.launcher-hero-art .pennant { transform-box: fill-box; transform-origin: center; animation: lh-bob 3s ease-in-out infinite; }
@keyframes lh-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  .launcher-hero-bubbles .lb, .launcher-hero-art .ring, .launcher-hero-art .trend, .launcher-hero-art .pennant { animation: none; }
}

/* App launcher cards */
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
@media (max-width: 820px) { .app-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .app-grid { grid-template-columns: 1fr; } }
.app-card {
  --accent: var(--brand);
  --accent-2: var(--brand-cyan);
  position: relative; overflow: hidden; text-align: left; font: inherit; color: var(--text);
  display: flex; flex-direction: column; gap: 0.6rem; text-decoration: none;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.5rem; box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
/* Per-card accent (top bar, sheen, icon glow, CTA, hover shadow) */
.app-card:has(.rank)      { --accent: #006EFE; --accent-2: #34C2FF; }
.app-card:has(.analytics) { --accent: #6A72E6; --accent-2: #8F96F5; }
.app-card:has(.leads)     { --accent: #0F8A63; --accent-2: #1DB981; }
.app-card:has(.access)    { --accent: #D9822B; --accent-2: #F0A93A; }
.app-card:has(.knowledge) { --accent: #DA4E85; --accent-2: #F27DA6; }
.app-card:has(.agents)    { --accent: #7C3AED; --accent-2: #A855F7; }
.app-card:has(.media)     { --accent: #0E9BB8; --accent-2: #3AD6EA; }
/* Accent top bar (always visible, brighter on hover) */
.app-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.6; transition: opacity 0.22s ease;
}
.app-card:not(.is-disabled):hover {
  transform: translateY(-5px);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 22px 44px -20px color-mix(in srgb, var(--accent) 60%, transparent);
}
.app-card:not(.is-disabled):hover::before { opacity: 1; }
.app-card:not(.is-disabled):hover .app-card-icon { transform: translateY(-2px) scale(1.05); }
.app-card.is-disabled { cursor: default; }
.app-card-icon {
  position: relative; width: 64px; height: 64px; display: grid; place-items: center;
  transition: transform 0.18s ease;
}
.app-card-icon img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(2, 20, 45, 0.22));
}
.app-card.is-disabled .app-card-icon img { opacity: 0.72; filter: grayscale(0.15); }
.app-card-body { position: relative; flex: 1; }
.app-card-body h2 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 0.25rem; }
.app-card-body p { color: var(--text-2); font-size: 0.9rem; margin: 0; line-height: 1.45; }
.app-card-cta {
  position: relative; display: inline-flex; align-items: center; gap: 0.35rem;
  font-weight: 700; font-size: 0.9rem; color: var(--accent); margin-top: 0.1rem;
}
.app-card-cta::after {
  content: "→"; transition: transform 0.18s ease; font-size: 1rem; line-height: 1;
}
.app-card:not(.is-disabled):hover .app-card-cta::after { transform: translateX(4px); }
.app-card-cta.muted { color: var(--muted); }
.app-card-cta.muted::after { content: none; }
.app-card-badge {
  position: absolute; top: 1rem; right: 1rem; z-index: 1; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0.2rem 0.5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
@media (prefers-reduced-motion: reduce) {
  .app-card, .app-card::before, .app-card::after, .app-card-icon, .app-card-cta::after { transition: none; }
}

/* Knowledge Base */
.kb-hero {
  display: flex; align-items: center; gap: 1.4rem;
  background: none; border: 0; box-shadow: none; padding: 0.25rem 0.25rem 0;
  margin-bottom: 1.6rem;
}
.kb-hero-art { flex: none; width: 300px; display: grid; place-items: center; }
.kb-hero-art img { width: 100%; height: auto; object-fit: contain; filter: drop-shadow(0 10px 16px rgba(0,82,204,0.22)); }
@media (max-width: 620px) { .kb-hero-art { width: 220px; } }
.kb-hero-copy { display: flex; flex-direction: column; gap: 0.45rem; }
.kb-hero-quote { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; line-height: 1.5; color: var(--text); margin: 0; }
.kb-hero-by { color: var(--text-2); font-size: 0.98rem; margin: 0; }
@media (max-width: 620px) { .kb-hero { flex-direction: column; text-align: center; } }

.kb-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.kb-chip {
  --accent: var(--brand);
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.42rem 0.85rem; border-radius: 999px;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.kb-chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.kb-chip.is-active { color: #fff; background: var(--accent); border-color: transparent; }

.kb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
@media (max-width: 900px) { .kb-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kb-grid { grid-template-columns: 1fr; } }

.kb-card {
  --accent: var(--brand);
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 0.85rem;
  text-decoration: none; color: var(--text);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.kb-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #ffffff));
  opacity: 0.7; transition: opacity 0.18s ease;
}
.kb-card:hover {
  transform: translateY(-4px);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 22px 44px -20px color-mix(in srgb, var(--accent) 55%, transparent);
}
.kb-card:hover::before { opacity: 1; }
.kb-card:hover .kb-read::after { transform: translateX(3px); }

.kb-icon {
  width: 46px; height: 46px; flex: none; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.4rem; line-height: 1;
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.kb-icon-sm { width: 34px; height: 34px; font-size: 1.05rem; border-radius: 9px; }

.kb-card-main { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.kb-card h2 { font-family: var(--font-display); font-size: 1.12rem; margin: 0; line-height: 1.3; }
.kb-card p { color: var(--text-2); font-size: 0.9rem; line-height: 1.5; margin: 0; }
.kb-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.55rem; }
.kb-read { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 700; font-size: 0.9rem; color: var(--accent); }
.kb-read::after { content: "→"; transition: transform 0.18s ease; }

.kb-tag {
  align-self: flex-start; font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.22rem 0.55rem; border-radius: 999px;
  color: var(--accent, var(--brand)); background: color-mix(in srgb, var(--accent, var(--brand)) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent, var(--brand)) 30%, var(--border));
}

.kb-back { color: var(--text-2); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.kb-back:hover { color: var(--accent, var(--brand)); }
@media (prefers-reduced-motion: reduce) { .kb-card, .kb-card::before, .kb-read::after { transition: none; } }

/* Article */
.article { position: relative; overflow: hidden; max-width: 800px; }
.article::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--accent, var(--brand)), color-mix(in srgb, var(--accent, var(--brand)) 38%, #ffffff));
}
.article-meta { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.article-title { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.2; margin: 0 0 1rem; }
.article-lead { font-size: 1.08rem; color: var(--text); line-height: 1.7; }
.article h2 { font-family: var(--font-display); font-size: 1.35rem; margin: 1.8rem 0 0.6rem; }
.article h3 { font-size: 1.08rem; margin: 1.3rem 0 0.4rem; }
.article p { color: var(--text); font-size: 1rem; line-height: 1.7; margin: 0 0 0.9rem; }
.article ul { margin: 0 0 1.1rem; padding-left: 1.25rem; }
.article li { color: var(--text); font-size: 1rem; line-height: 1.6; margin-bottom: 0.5rem; }
.article code {
  font-size: 0.88em; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 0.08em 0.38em;
}
.article a { color: var(--brand); }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.75rem; }
.panel h2 { margin-bottom: 0.9rem; }
.panel-head h2 { margin-bottom: 0; }

.keyword-form { display: grid; grid-template-columns: 2fr 1.4fr auto auto; gap: 0.6rem; }
@media (max-width: 720px) { .keyword-form { grid-template-columns: 1fr; } }

/* Lead Tracker (Leads + Get Started + Agency Partner tabs) — highlight each row by its Status ("Action").
   The per-status colours are CSS variables so admins can customize them;
   leads.js/get-started.js/agency-partner.js set --lead-<Status> on their table from the saved settings. */
#leads-table, #get-started-table, #agency-partner-table {
  --lead-New: #006EFE; --lead-Contacted: #E0912B; --lead-Qualified: #0EA5A0;
  --lead-Converted: #0CA30C; --lead-Lost: #D03B3B;
}
#leads-table tbody tr[data-status],
#get-started-table tbody tr[data-status],
#agency-partner-table tbody tr[data-status] { transition: background-color 0.2s ease; }
#leads-table tbody tr[data-status] > td:first-child,
#get-started-table tbody tr[data-status] > td:first-child,
#agency-partner-table tbody tr[data-status] > td:first-child { border-left: 3px solid transparent; }
#leads-table tbody tr[data-status="New"],
#get-started-table tbody tr[data-status="New"],
#agency-partner-table tbody tr[data-status="New"]       { background: color-mix(in srgb, var(--lead-New) 15%, var(--surface)); }
#leads-table tbody tr[data-status="New"] > td:first-child,
#get-started-table tbody tr[data-status="New"] > td:first-child,
#agency-partner-table tbody tr[data-status="New"]       > td:first-child { border-left-color: var(--lead-New); }
#leads-table tbody tr[data-status="Contacted"],
#get-started-table tbody tr[data-status="Contacted"],
#agency-partner-table tbody tr[data-status="Contacted"] { background: color-mix(in srgb, var(--lead-Contacted) 15%, var(--surface)); }
#leads-table tbody tr[data-status="Contacted"] > td:first-child,
#get-started-table tbody tr[data-status="Contacted"] > td:first-child,
#agency-partner-table tbody tr[data-status="Contacted"] > td:first-child { border-left-color: var(--lead-Contacted); }
#leads-table tbody tr[data-status="Qualified"],
#get-started-table tbody tr[data-status="Qualified"],
#agency-partner-table tbody tr[data-status="Qualified"] { background: color-mix(in srgb, var(--lead-Qualified) 15%, var(--surface)); }
#leads-table tbody tr[data-status="Qualified"] > td:first-child,
#get-started-table tbody tr[data-status="Qualified"] > td:first-child,
#agency-partner-table tbody tr[data-status="Qualified"] > td:first-child { border-left-color: var(--lead-Qualified); }
#leads-table tbody tr[data-status="Converted"],
#get-started-table tbody tr[data-status="Converted"],
#agency-partner-table tbody tr[data-status="Converted"] { background: color-mix(in srgb, var(--lead-Converted) 15%, var(--surface)); }
#leads-table tbody tr[data-status="Converted"] > td:first-child,
#get-started-table tbody tr[data-status="Converted"] > td:first-child,
#agency-partner-table tbody tr[data-status="Converted"] > td:first-child { border-left-color: var(--lead-Converted); }
#leads-table tbody tr[data-status="Lost"],
#get-started-table tbody tr[data-status="Lost"],
#agency-partner-table tbody tr[data-status="Lost"]      { background: color-mix(in srgb, var(--lead-Lost) 15%, var(--surface)); }
#leads-table tbody tr[data-status="Lost"] > td:first-child,
#get-started-table tbody tr[data-status="Lost"] > td:first-child,
#agency-partner-table tbody tr[data-status="Lost"]      > td:first-child { border-left-color: var(--lead-Lost); }

/* Colour customizer */
.lead-colors-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.2rem 0 1rem; }
.lead-color-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.lead-color-row .lead-color-name { font-weight: 600; font-size: 0.9rem; }
.lead-color-row input[type="color"] { width: 46px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.lead-colors-actions { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; }
/* Manage Actions editor rows */
.lead-action-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.55rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.lead-action-row input[type="text"] { flex: 1; min-width: 0; }
.lead-action-row input[type="color"] { width: 42px; height: 32px; flex: none; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.lead-action-row .lead-action-del { flex: none; border: none; background: transparent; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0.3rem 0.4rem; border-radius: 6px; color: var(--muted); }
.lead-action-row .lead-action-del:hover { color: var(--critical); background: var(--surface); }

/* Media Gallery */
.media-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.2rem 0 1.1rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.1rem; }
.media-card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.media-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); box-shadow: 0 18px 34px -18px rgba(20,40,90,0.4); }
.media-thumb {
  display: grid; place-items: center; height: 150px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); overflow: hidden; text-decoration: none;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-fileicon {
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.04em;
  color: #fff; background: var(--brand-grad-btn); padding: 0.5rem 0.9rem; border-radius: 10px;
  box-shadow: 0 8px 18px -8px rgba(0,110,254,0.6);
}
.media-meta { padding: 0.7rem 0.8rem 0.2rem; flex: 1; min-width: 0; }
.media-name { font-weight: 600; font-size: 0.9rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-sub { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; }
.media-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.3rem; padding: 0.3rem 0.6rem 0.6rem; }
.media-actions .row-icon { text-decoration: none; font-size: 1.05rem; }

/* Table */
.table-wrap { overflow-x: auto; }
.kw-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.kw-table th {
  text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--brand-deep); font-weight: 700; padding: 0.6rem 0.6rem;
  background: rgba(0,110,254,0.08); border-bottom: 2px solid rgba(0,110,254,0.22);
}
.kw-table thead th:first-child { border-top-left-radius: var(--radius-sm); }
.kw-table thead th:last-child  { border-top-right-radius: var(--radius-sm); }
.kw-table th.num { text-align: right; }
/* Keep the second line of the two-line AI headers the same size as the rest. */
.kw-table th small { font-size: inherit; font-weight: inherit; color: inherit; }
.kw-table td { padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--grid); vertical-align: middle; }
/* Subtle blue zebra striping + a stronger tint on hover. */
.kw-table tbody tr:nth-child(even) { background: rgba(0,110,254,0.035); }
.kw-table tbody tr:hover { background: rgba(0,110,254,0.09); }
.kw-term { font-weight: 600; color: var(--brand-navy); }
.engine-pill {
  font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
}
/* Rank badges, colour-coded by quality. */
.pos {
  display: inline-block; min-width: 2.3rem; text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.55rem; border-radius: 999px;
}
.pos-top3, .pos-top10, .pos-rest { background: rgba(12,163,12,0.15); color: var(--good-text); }
.pos-none { color: var(--muted); font-weight: 500; }
/* Dark mode: lift text off the dark surface so it stays legible. */
:root[data-theme="dark"] .kw-table th { color: var(--brand-cyan); }
:root[data-theme="dark"] .kw-term { color: var(--brand-cyan); }

/* AI Agent toggle switch */
.agent-switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.agent-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.agent-slider {
  position: relative; width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border); transition: background 0.15s ease;
}
.agent-slider::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.15s ease;
}
.agent-switch input:checked + .agent-slider { background: var(--brand); border-color: transparent; }
.agent-switch input:checked + .agent-slider::before { transform: translateX(18px); }
.agent-switch input:focus-visible + .agent-slider { outline: 2px solid var(--brand); outline-offset: 2px; }
.agent-state { font-size: 0.8rem; font-weight: 700; color: var(--muted); min-width: 3.2ch; text-align: left; }
.agent-switch input:checked ~ .agent-state { color: var(--good-text); }
#agents-table thead th.num,
#agents-table tbody td.num { text-align: left; }
.agent-cell { display: inline-flex; align-items: center; gap: 0.5rem; justify-content: flex-start; }
.agent-config-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 2rem; line-height: 1; padding: 0.25rem 0.4rem; border-radius: 6px;
  text-decoration: none; display: inline-flex; align-items: center;
}
.agent-config-btn:hover { color: var(--brand); background: var(--surface-2); }
.agent-run-btn {
  border: none; background: transparent; cursor: pointer; color: var(--good-text);
  font-size: 1.6rem; line-height: 1; padding: 0.25rem 0.4rem; border-radius: 6px;
}
.agent-run-btn:hover:not(:disabled) { background: rgba(12,163,12,0.12); }
.agent-run-btn:disabled { color: var(--muted); opacity: 0.45; cursor: not-allowed; }
/* Training-document list in the Configure dialog. */
.agent-doc-list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.agent-doc {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem; font-size: 0.85rem;
}
.agent-doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.agent-doc-meta { color: var(--muted); font-size: 0.78rem; flex: none; }
.agent-doc-del { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 0.1rem 0.25rem; border-radius: 6px; flex: none; }
.agent-doc-del:hover { color: var(--critical); background: var(--surface); }
.status-pill {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
}
.status-pill.is-published { color: #1a8a3f; background: rgba(26,138,63,0.13); }
.status-pill.is-draft { color: var(--muted); background: var(--surface-2); }
:root[data-theme="dark"] .status-pill.is-published { color: #4ad24a; background: rgba(74,210,74,0.15); }
:root[data-theme="dark"] .pos-top3,
:root[data-theme="dark"] .pos-top10,
:root[data-theme="dark"] .pos-rest { color: #4ad24a; }

.src-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 0.4rem; vertical-align: middle;
}
.src-dot.live { background: var(--good); }
.src-dot.demo { background: transparent; border: 1.5px solid var(--muted); }

.change { font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 0.2rem; }
.change.up { color: var(--good-text); }
.change.down { color: var(--critical); }
.change.flat { color: var(--muted); }

.row-actions { white-space: nowrap; }
.row-icon, .row-del {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 0.2rem 0.4rem; border-radius: 6px; vertical-align: middle;
}
.row-icon:hover { color: var(--text); background: var(--surface-2); }
.row-del:hover { color: var(--critical); background: var(--surface-2); }
/* Flip the edit pencil to point the other way. */
.row-icon-flip { display: inline-block; transform: scaleX(-1); }
/* AIO / AIM lettered action buttons. */
.row-icon-text { font-size: calc(0.72rem + 2px); font-weight: 800; letter-spacing: 0.02em; color: var(--brand-deep); }
:root[data-theme="dark"] .row-icon-text { color: var(--brand-cyan); }
/* Google organic-fetch button: small gap between the G and the magnifier. */
.row-icon-google { display: inline-flex; align-items: center; gap: 0.15rem; }
/* Cute SVG trash can: centered and a touch smaller than the other icons. */
.row-del { display: inline-flex; align-items: center; }
.row-del svg { display: block; }
/* Collapsible row actions: a ⋯ toggle reveals the icon menu inline. */
.row-menu { display: inline-flex; align-items: center; gap: 0.1rem; margin-right: 0.15rem; }

/* Lead Tracker (Leads + Get Started + Agency Partner tabs) */
.leads-toolbar { display: flex; align-items: center; gap: 0.6rem; }
.leads-toolbar input[type="search"] {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); padding: 0.5rem 0.7rem; font: inherit; width: 200px;
}
#leads-table th.sortable, #get-started-table th.sortable, #agency-partner-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
#leads-table th.sortable::after, #get-started-table th.sortable::after, #agency-partner-table th.sortable::after { content: '⇕'; margin-left: 0.35rem; opacity: 0.4; font-size: 0.8em; }
#leads-table th.sortable.is-sorted-asc::after, #get-started-table th.sortable.is-sorted-asc::after, #agency-partner-table th.sortable.is-sorted-asc::after { content: '↑'; opacity: 1; }
#leads-table th.sortable.is-sorted-desc::after, #get-started-table th.sortable.is-sorted-desc::after, #agency-partner-table th.sortable.is-sorted-desc::after { content: '↓'; opacity: 1; }

/* Lead Tracker page-level tabs (Leads / Get Started — separate pages, not panel switches) */
.page-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.1rem; }
.page-tab {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; font-size: 0.88rem;
  padding: 0.55rem 1.1rem; cursor: pointer; text-decoration: none;
}
.page-tab:hover { filter: brightness(0.97); }
.page-tab.is-active { background: var(--brand-grad-btn); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -8px rgba(0,110,254,0.6); }
#leads-table select {
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 0.85rem; padding: 0.3rem 0.4rem; max-width: 140px;
}
.lead-detail-list { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.5rem 1rem; margin: 0; }
.lead-detail-list dt { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
.lead-detail-list dd { margin: 0; font-size: 0.9rem; word-break: break-word; }
.row-toggle {
  border: 1.5px solid rgba(0,110,254,0.35); background: rgba(0,110,254,0.10);
  color: var(--brand); cursor: pointer;
  font-size: 1.3rem; font-weight: 700; line-height: 0.7;
  padding: 0.1rem 0.6rem 0.35rem; border-radius: 999px;
  vertical-align: middle; letter-spacing: 0.08em;
  box-shadow: 0 3px 8px -4px rgba(0,110,254,0.5);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.row-toggle:hover { background: rgba(0,110,254,0.2); border-color: var(--brand); }
.row-toggle[aria-expanded="true"] { background: var(--brand); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .row-toggle { color: var(--brand-cyan); border-color: rgba(52,194,255,0.45); }
:root[data-theme="dark"] .row-toggle[aria-expanded="true"] { color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* Sparkline */
.spark { display: block; }

/* ============ DETAIL DIALOG ============ */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: grid; place-items: center; padding: 1rem; z-index: 50;
}
.detail {
  width: 100%; max-width: 720px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
/* Fetch Rankings (bulk) dialog: wider to fit the results table comfortably. */
#modal_multiple_ranking .detail { max-width: 800px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.detail-chart { width: 100%; }
.detail-foot { display: flex; justify-content: space-between; margin-top: 1rem; }

/* ---- Full-width article editor ---- */
.article-editor {
  max-width: min(1440px, 96vw); width: 96vw; height: 92vh;
  display: flex; flex-direction: column; padding: 1.1rem 1.3rem;
}
.article-editor .detail-head { margin-bottom: 0.7rem; }
.ae-head-left { display: flex; align-items: center; gap: 0.75rem; }
.ae-head-left h2 { margin: 0; }

.ae-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px 1fr; gap: 1.2rem; }
.ae-meta { display: flex; flex-direction: column; gap: 0.85rem; overflow: auto; padding-right: 0.3rem; }
.ae-field { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.85rem; color: var(--text-2); }
.ae-field input, .ae-field textarea { width: 100%; }
.ae-field textarea { resize: vertical; }
.ae-field-row { display: flex; gap: 0.5rem; align-items: center; }
.ae-field-row input { flex: 1; min-width: 0; }
.ae-field-row .btn { flex: none; padding: 0.5rem 0.7rem; font-size: 0.8rem; white-space: nowrap; }
.ae-toggle { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.85rem; }
.ae-toggle input { width: auto; }
.ae-hint { font-size: 0.78rem; margin: 0.1rem 0 0; }

.ae-content { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ae-content-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.55rem; }
.ae-content-label { font-weight: 600; font-size: 0.85rem; color: var(--text-2); }
.ae-viewtabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.16rem; gap: 0.12rem; }
.ae-tab { font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--text-2); background: transparent; border: 0; border-radius: 999px; padding: 0.3rem 0.75rem; cursor: pointer; transition: background 0.14s ease, color 0.14s ease; }
.ae-tab:hover { color: var(--text); }
.ae-tab.is-active { background: var(--brand); color: #fff; }

.ae-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ae-panes.view-edit { grid-template-columns: 1fr; }
.ae-panes.view-edit .ae-preview { display: none; }
.ae-panes.view-preview { grid-template-columns: 1fr; }
.ae-panes.view-preview .ae-editor { display: none; }
.ae-editor {
  width: 100%; height: 100%; resize: none;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9rem; line-height: 1.65; padding: 0.95rem 1.05rem; tab-size: 2;
}
.ae-preview {
  overflow: auto; max-width: none; padding: 1.2rem 1.5rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ae-preview::before { content: none; }
.ae-preview:empty::after {
  content: "Nothing to preview yet."; color: var(--muted); font-size: 0.9rem;
}

.ae-foot { align-items: center; gap: 1rem; margin-top: 0.9rem; }
.ae-foot .form-error { margin: 0; }
.ae-actions { display: flex; gap: 0.6rem; margin-left: auto; }

@media (max-width: 900px) {
  .article-editor { width: 96vw; height: 94vh; }
  .ae-body { grid-template-columns: 1fr; overflow: auto; }
  .ae-panes { grid-template-columns: 1fr; }
  .ae-panes.view-split .ae-editor { min-height: 240px; }
  .ae-panes.view-split .ae-preview { min-height: 240px; }
}

/* Chart tooltip */
.chart-tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--surface);
  font-size: 0.78rem; padding: 0.35rem 0.55rem; border-radius: 6px; transform: translate(-50%, -120%);
  white-space: nowrap; font-weight: 600; opacity: 0; transition: opacity 0.08s;
}

/* Toast */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 0.65rem 1rem;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow); z-index: 60;
}
