/* ╭──────────────────────────────────────────────────────────────────╮
   │  LeadsHub — design system                                        │
   │                                                                  │
   │  Architecture                                                    │
   │  ─────────────                                                   │
   │  1. Tokens     (custom properties — colours, spacing, radius)    │
   │  2. Reset      (sane defaults so unstyled pages still work)      │
   │  3. Type       (font stack, weights, sizes)                      │
   │  4. Primitives (button, input, card, pill, table)                │
   │  5. Shell      (sidebar + main grid)                             │
   │  6. Pages      (auth, leads, niches, members, activity)          │
   │                                                                  │
   │  No framework. ~17KB.                                            │
   ╰──────────────────────────────────────────────────────────────────╯ */

/* ── 1. Tokens ─────────────────────────────────────────────────────── */
:root {
  /* Surface scale (light → dark) */
  --bg:        #f6f7fb;
  --bg-2:      #eef0f7;
  --surface:   #ffffff;
  --surface-2: #f9fafc;
  --surface-3: #f0f2f7;
  --border:    #e4e7ee;
  --border-2:  #d4d8e2;
  --border-strong: #b6bcc8;

  /* Foreground */
  --fg:    #1a1d29;
  --fg-2:  #3d4453;
  --fg-3:  #5a6273;
  --muted: #818797;

  /* Brand — indigo→purple gradient */
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand: #6366f1;
  --brand-soft: #eef2ff;
  --brand-soft-2: #e0e7ff;
  --brand-fg: #ffffff;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* Semantic */
  --ok: #16a34a; --ok-soft: #dcfce7;
  --warn: #d97706; --warn-soft: #fef3c7;
  --err: #dc2626; --err-soft: #fee2e2;
  --info: #0284c7; --info-soft: #e0f2fe;

  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

  /* Radius */
  --r-1: 4px; --r-2: 6px; --r-3: 8px; --r-4: 12px; --r-5: 16px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-2: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-3: 0 8px 24px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.08);
  --shadow-modal: 0 24px 64px rgba(15, 23, 42, 0.24), 0 4px 12px rgba(15, 23, 42, 0.12);

  /* Focus ring */
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.22);

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 60px;

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0a0d14;
    --bg-2:      #0d111a;
    --surface:   #11151f;
    --surface-2: #161b27;
    --surface-3: #1d2331;
    --border:    #232938;
    --border-2:  #2a3142;
    --border-strong: #3b4257;

    --fg:    #ecf0f8;
    --fg-2:  #c1c8d8;
    --fg-3:  #969eb1;
    --muted: #6f7793;

    --brand: #818cf8;
    --brand-soft: #1e1b3a;
    --brand-soft-2: #2a2552;
    --brand-fg: #0a0d14;

    --ok: #4ade80;   --ok-soft: #14271a;
    --warn: #fbbf24; --warn-soft: #2a1f0a;
    --err: #f87171;  --err-soft: #2a1414;
    --info: #38bdf8; --info-soft: #0d2331;

    --shadow-1: 0 1px 2px rgba(0,0,0,0.40);
    --shadow-2: 0 1px 2px rgba(0,0,0,0.40), 0 4px 12px rgba(0,0,0,0.30);
    --shadow-3: 0 8px 24px rgba(0,0,0,0.50), 0 2px 6px rgba(0,0,0,0.40);
    --shadow-modal: 0 28px 72px rgba(0,0,0,0.80), 0 4px 12px rgba(0,0,0,0.50);

    --ring: 0 0 0 3px rgba(129, 140, 248, 0.30);
  }
}

/* ── 2. Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; transition: color 0.12s; }
a:hover { color: var(--brand-2); text-decoration: underline; text-underline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }

/* ── 3. Type ───────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.dim   { color: var(--fg-3); }
.mono  { font-family: var(--mono); font-size: 12.5px; }
small  { font-size: 12px; color: var(--muted); }

/* ── 4. Primitives ─────────────────────────────────────────────────── */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-4);
  font-size: 13px; font-weight: 500; line-height: 1;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }

.btn.primary {
  background: var(--brand-grad); color: var(--brand-fg);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:active { filter: brightness(0.96); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err); color: white; border-color: var(--err); }
.btn.ghost { border: none; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 var(--s-3); font-size: 12px; }

button.primary {  /* alias for legacy markup */
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-4);
  font-size: 13px; font-weight: 600; line-height: 1;
  background: var(--brand-grad); color: var(--brand-fg);
  border: none; border-radius: var(--r-2); cursor: pointer;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.25), inset 0 -1px 0 rgba(0,0,0,0.08);
  transition: filter 0.12s, transform 0.06s;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:active { filter: brightness(0.96); transform: translateY(0.5px); }
button.primary:focus-visible { outline: none; box-shadow: var(--ring), 0 1px 2px rgba(99,102,241,0.25); }
button.primary:disabled { filter: grayscale(0.4); opacity: 0.6; cursor: not-allowed; }

button.danger { /* legacy */
  height: 30px; padding: 0 var(--s-3); border-radius: var(--r-2);
  background: var(--surface); color: var(--err); border: 1px solid var(--err);
  font-size: 12px; font-weight: 500;
}
button.danger:hover { background: var(--err); color: white; }

.btn-link {
  background: none; border: none; padding: 0; color: var(--brand);
  font-weight: 500; cursor: pointer; font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }

/* Form controls */
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], input[type=number], select, textarea {
  display: block;
  width: 100%;
  height: 36px; padding: 0 var(--s-3);
  font-size: 13px; line-height: 1;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { height: auto; padding: var(--s-3); resize: vertical; line-height: 1.5; min-height: 64px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

label.field {
  display: flex; flex-direction: column; gap: var(--s-2);
  font-size: 12px; font-weight: 500; color: var(--fg-2);
}
label.field input, label.field select, label.field textarea { font-size: 13.5px; height: 38px; }
label.field textarea { height: auto; }

.checkbox {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: 13px; cursor: pointer; user-select: none;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--s-4);
}
.card h2 { margin-bottom: var(--s-2); }
.card .card-hint { color: var(--muted); font-size: 13px; margin-bottom: var(--s-4); }

/* Pill */
.pill {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 var(--s-3);
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.role-owner  { background: #fef3c7; color: #854d0e; border-color: #fde68a; }
.role-admin  { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.role-member { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.role-viewer { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
@media (prefers-color-scheme: dark) {
  .role-owner  { background: #2a1f0a; color: #fbbf24; border-color: #45330d; }
  .role-admin  { background: #0d2331; color: #60a5fa; border-color: #1c4163; }
  .role-member { background: #14271a; color: #4ade80; border-color: #1e3d27; }
  .role-viewer { background: #232938; color: #c1c8d8; border-color: #2a3142; }
}

/* Status pill */
.status-pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 var(--s-3);
  font-size: 11px; font-weight: 600;
  border-radius: var(--r-1);
  text-transform: capitalize;
}
.status-new        { background: var(--info-soft); color: var(--info); }
.status-contacted  { background: var(--warn-soft); color: var(--warn); }
.status-replied    { background: var(--brand-soft); color: var(--brand); }
.status-won        { background: var(--ok-soft); color: var(--ok); }
.status-lost       { background: var(--err-soft); color: var(--err); }

/* Generic data table */
.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data th, .data td {
  text-align: left; padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data thead th {
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data thead th:first-child { border-top-left-radius: var(--r-3); }
.data thead th:last-child  { border-top-right-radius: var(--r-3); }
.data tbody tr:last-child td { border-bottom: none; }
.data tbody tr:hover td { background: var(--surface-2); }

/* Flash */
.flash {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--info-soft);
  border: 1px solid var(--info);
  color: var(--info);
  border-radius: var(--r-3);
  margin-bottom: var(--s-4);
  font-size: 13px;
}

.callout {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-3);
  margin-bottom: var(--s-4);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
}
.callout.warn    { background: var(--warn-soft); border-color: #fbbf24; color: var(--warn); }
.callout.success { background: var(--ok-soft);   border-color: var(--ok); color: var(--ok); }
.callout.info    { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.callout strong { color: inherit; }

/* ── 5. Shell ──────────────────────────────────────────────────────── */
body.app {
  background: var(--bg);
  min-height: 100vh;
}
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s-5) var(--s-3) var(--s-3);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar .brand-mark {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  margin-bottom: var(--s-7);
  color: var(--fg);
  text-decoration: none;
}
.sidebar .brand-mark:hover { text-decoration: none; }
.sidebar .brand-mark svg { color: var(--fg); }

.side-section { margin-bottom: var(--s-6); }
.side-section .section-label {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  padding: 0 var(--s-3); margin-bottom: var(--s-2);
}
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 7px var(--s-3);
  border-radius: var(--r-2);
  color: var(--fg-2);
  font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.side-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-nav a.active:hover { background: var(--brand-soft-2); }
.side-nav .icon {
  width: 18px; height: 18px; flex-shrink: 0;
  opacity: 0.8;
}
.side-nav a.active .icon { opacity: 1; }

.user-card {
  margin-top: auto;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s-3);
}
.user-card .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-grad);
  color: white; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-card .name {
  flex: 1; font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-card .logout-btn {
  background: none; border: none; color: var(--muted); padding: 6px;
  border-radius: var(--r-2); cursor: pointer;
  display: flex; align-items: center;
}
.user-card .logout-btn:hover { background: var(--surface-2); color: var(--fg); }
.user-card .logout-btn .icon { width: 16px; height: 16px; }

/* Main area */
.main-area {
  padding: var(--s-7) var(--s-8) var(--s-9);
  max-width: 1640px;
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--s-6); gap: var(--s-4);
}
.page-head h1 { font-size: 22px; }
.page-head .subtitle { font-size: 13.5px; color: var(--muted); margin-top: var(--s-1); }
.page-head .actions { display: flex; gap: var(--s-2); align-items: center; flex-shrink: 0; }

/* Stats strip */
.stats-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3); margin-bottom: var(--s-4);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--s-4);
  position: relative; overflow: hidden;
}
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--brand-grad);
  opacity: 0.7;
}
.stat .label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.stat .value {
  font-size: 26px; font-weight: 700; margin-top: var(--s-1);
  letter-spacing: -0.02em; color: var(--fg);
}

/* Empty state */
.empty {
  text-align: center; padding: var(--s-9) var(--s-6);
  background: var(--surface);
  border: 2px dashed var(--border-2);
  border-radius: var(--r-4);
  color: var(--muted);
}
.empty .empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto var(--s-4);
  border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h3 { color: var(--fg); margin-bottom: var(--s-2); font-size: 16px; }
.empty p { margin: 0 0 var(--s-4); }

/* ── 6. Pages ──────────────────────────────────────────────────────── */

/* Auth (sign in / sign up) */
body.minimal {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: var(--s-5);
  background:
    radial-gradient(ellipse at top, rgba(99, 102, 241, 0.10), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.08), transparent 50%),
    var(--bg);
}
.auth-card {
  width: 420px; max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  padding: var(--s-7);
  box-shadow: var(--shadow-3);
}
.auth-card .brand-mark {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--s-6);
  color: var(--fg);
}
.auth-card h1 { text-align: center; margin-bottom: var(--s-5); font-size: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: var(--s-4); }
.auth-card .form-foot {
  text-align: center; margin-top: var(--s-4);
  font-size: 13px; color: var(--muted);
}

/* Companies index */
.company-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.company-list a {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  color: var(--fg);
  transition: border-color 0.12s, transform 0.1s, box-shadow 0.12s;
}
.company-list a:hover {
  border-color: var(--brand);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.company-list .name { font-weight: 600; font-size: 14px; }

/* Leads page */
.leads-toolbar {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-3); flex-wrap: wrap;
}
.leads-toolbar .search-wrap {
  position: relative; flex: 0 0 360px;
}
.leads-toolbar .search-wrap .icon {
  position: absolute; left: var(--s-3); top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--muted); pointer-events: none;
}
.leads-toolbar input[type=search] {
  padding-left: var(--s-7);
  height: 36px;
}
.leads-toolbar .count { color: var(--muted); font-size: 12.5px; }

.leads-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  overflow: auto;
  max-height: calc(100vh - 320px);
  box-shadow: var(--shadow-1);
}
.leads-table {
  width: max-content; min-width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
.leads-table th, .leads-table td {
  padding: 9px var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top; white-space: nowrap;
}
.leads-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.leads-table tbody tr { transition: background 0.06s; }
.leads-table tbody tr:hover td { background: var(--surface-2); }
.leads-table tbody tr:nth-child(even) td { background: var(--bg-2); }
.leads-table tbody tr:nth-child(even):hover td { background: var(--surface-3); }
.leads-table td.long, .leads-table td.hours {
  white-space: normal; max-width: 280px;
}
.leads-table .checkmark { color: var(--ok); font-weight: 600; font-size: 14px; }
.leads-table .name-cell { font-weight: 600; color: var(--fg); }
.leads-table a { color: var(--brand); }
.leads-table a:hover { color: var(--brand-2); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border-radius: var(--r-4);
  width: 760px; max-width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.modal-card header h2 { font-size: 16px; }
.close-x {
  background: none; border: none; padding: 6px;
  font-size: 20px; line-height: 1; color: var(--muted);
  border-radius: var(--r-2); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.close-x:hover { color: var(--fg); background: var(--surface-2); }

.modal-card form { display: contents; }
.modal-card .grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--s-4) var(--s-5);
  padding: var(--s-5);
  overflow-y: auto;
}
.modal-card .grid label.field { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.modal-card .grid label.field input,
.modal-card .grid label.field select,
.modal-card .grid label.field textarea { text-transform: none; letter-spacing: 0; font-weight: normal; color: var(--fg); }
.modal-card .grid label.full { grid-column: span 2; }
.modal-card .grid label.checkbox-row { flex-direction: row; align-items: center; text-transform: none; letter-spacing: normal; font-weight: 500; font-size: 13.5px; color: var(--fg); }
.modal-card .grid label.checkbox-row input[type=checkbox] { width: 16px; height: 16px; margin-right: var(--s-2); accent-color: var(--brand); }
.modal-card footer {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-card .spacer { flex: 1; }

.modal-conflict {
  margin: 0 var(--s-5) var(--s-4);
  background: var(--warn-soft);
  border: 1px solid #fbbf24;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-3);
  font-size: 13px;
}
.modal-conflict button { margin-left: var(--s-2); }

/* Niches page */
.niche-finder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--s-6);
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.niche-finder::before {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.10), transparent 60%);
  pointer-events: none;
}
.niche-finder h2 { margin-bottom: var(--s-1); position: relative; }
.niche-finder .desc { color: var(--muted); font-size: 13.5px; margin-bottom: var(--s-4); position: relative; }
.niche-finder .field-row {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: var(--s-3); margin-bottom: var(--s-4); position: relative;
}
.niche-finder textarea { min-height: 84px; }
.niche-finder .actions { display: flex; gap: var(--s-2); position: relative; }

.suggestions { display: grid; gap: var(--s-2); margin-top: var(--s-5); }
.suggestion {
  display: grid; grid-template-columns: auto 1fr;
  gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.suggestion:hover { border-color: var(--brand); background: var(--brand-soft); }
.suggestion input[type=checkbox] {
  margin-top: 3px; width: 16px; height: 16px;
  accent-color: var(--brand);
}
.suggestion .q { font-weight: 600; font-size: 14px; color: var(--fg); }
.suggestion .reason { color: var(--fg-3); font-size: 12.5px; margin-top: 2px; }

.niche-list { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.niche-row {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  background: var(--surface);
  transition: border-color 0.12s;
}
.niche-row:hover { border-color: var(--border-strong); }
.niche-row .q { font-weight: 600; font-size: 14px; }
.niche-row .reason { color: var(--fg-3); font-size: 12.5px; margin-top: 2px; }
.niche-row .meta { font-size: 11.5px; color: var(--muted); margin-top: var(--s-1); }
.niche-row .actions { display: flex; gap: var(--s-2); }
.niche-row.has-pending {
  border-color: var(--warn);
  background: linear-gradient(to right, var(--warn-soft) 0%, var(--surface) 30%);
}

.jobs-table .badge {
  display: inline-flex; align-items: center; height: 20px;
  padding: 0 var(--s-3);
  border-radius: var(--r-2);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-queued    { background: var(--info-soft); color: var(--info); }
.badge-running   { background: var(--brand-soft); color: var(--brand); }
.badge-done      { background: var(--ok-soft); color: var(--ok); }
.badge-failed,
.badge-cancelled { background: var(--err-soft); color: var(--err); }

/* Animated thinking spinner for AI suggest */
.thinking {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: 13px; color: var(--muted);
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* API token disclosure */
.token-once {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  margin-top: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  font-family: var(--mono); font-size: 12px;
  word-break: break-all;
  color: var(--fg);
}

/* Activity log */
.activity .kv { margin-right: var(--s-2); font-size: 12px; }
.activity code {
  background: var(--surface-3);
  padding: 1px 6px; border-radius: 3px;
  font-family: var(--mono); font-size: 11.5px;
}

/* Responsive */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    padding: var(--s-3) var(--s-4);
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand-mark { margin-bottom: var(--s-3); }
  .side-section { margin-bottom: var(--s-3); }
  .user-card { display: none; }
  .main-area { padding: var(--s-5); }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
}
