/* ============================================================
   Rising Stars · Probable Converts
   Corporate theme · light grey base · Lexend · dark mode
   ============================================================ */

:root {
  --font: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Light theme (default) — light grey base */
  --bg: #eef0f3;
  --bg-soft: #e7eaee;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef1f5;
  --border: #dce0e6;
  --border-strong: #c8cdd5;
  --text: #1c2127;
  --text-muted: #5b636e;
  --text-faint: #8a919b;

  --accent: #2b59d9;
  --accent-hover: #2149b8;
  --accent-soft: #e8eefc;
  --accent-border: #bccdf2;
  --on-accent: #ffffff;

  --danger: #c43d3d;
  --danger-hover: #a83232;
  --danger-soft: #fbeaea;
  --success: #1e8e5a;
  --success-soft: #e2f4eb;
  --warn: #a3690a;
  --warn-soft: #fdf1da;
  --info: #2467b0;
  --info-soft: #e5eff9;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, 0.07), 0 6px 18px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 32px rgba(16, 24, 40, 0.16);

  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
}

[data-theme="dark"] {
  /* Dark theme — grey, deliberately not very dark */
  --bg: #292d33;
  --bg-soft: #24282d;
  --surface: #33383f;
  --surface-2: #3b414a;
  --surface-3: #434a54;
  --border: #474e58;
  --border-strong: #565e6a;
  --text: #e9ebef;
  --text-muted: #aab1bb;
  --text-faint: #868e99;

  --accent: #6f95f0;
  --accent-hover: #85a6f4;
  --accent-soft: #3a4358;
  --accent-border: #4d5c7d;
  --on-accent: #10203f;

  --danger: #e07070;
  --danger-hover: #e98787;
  --danger-soft: #4a3538;
  --success: #5cc492;
  --success-soft: #31423b;
  --warn: #e0b566;
  --warn-soft: #484130;
  --info: #7db3e8;
  --info-soft: #35414f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 36px rgba(0, 0, 0, 0.4);
}

/* ── Base ─────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  vertical-align: -3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); }

/* ── Boot loader / gate ───────────────────────────────────── */

.boot-loader {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.gate-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 36px 28px;
  text-align: center;
}

.gate-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2b59d9, #4a7af0);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.gate-mark .icon { width: 28px; height: 28px; }

.gate-card h1 { font-size: 20px; margin-bottom: 4px; }

.gate-sub {
  color: var(--text-faint);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 18px;
}

.gate-msg { color: var(--text-muted); font-size: 14px; }

.gate-msg + .btn { margin-top: 20px; }

/* ── Header ───────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, #2b59d9, #4a7af0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.brand-mark .icon { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.icon-btn.spin-anim .icon { animation: spin 0.8s linear infinite; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  max-width: 220px;
}

.avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

@media (max-width: 480px) {
  .user-meta { display: none; }
  .user-chip { padding: 4px; border-radius: 50%; }
}

/* ── Tabs ─────────────────────────────────────────────────── */

.tabs {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color 0.15s;
}

.tab .icon { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Main layout ──────────────────────────────────────────── */

.main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 16px 90px;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.view-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.view-sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

.view-head-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon { color: var(--accent); }

/* ── Stats ────────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.stat-value { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 2px;
}

/* 5 tiles: on the 2-column mobile grid the last one spans the full width so it
   never sits as a half-width orphan. */
.stats .stat:nth-child(5) { grid-column: span 2; }

/* Conversion is the headline outcome — give its value the success colour. */
.stat-converted .stat-value { color: var(--success); }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(5, 1fr); }
  .stats .stat:nth-child(5) { grid-column: auto; }
}

/* ── Filters ──────────────────────────────────────────────── */

/* Filters toggle is available on every screen size so leads views can reclaim
   vertical space; the panel collapses/expands on click at all widths. */
.filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin-bottom: 12px;
}

.filter-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.filters-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.filters-panel.collapsed { display: none; }

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

.filters-grid .field { margin-bottom: 0; gap: 4px; }

.filters-grid .span-2 { grid-column: span 2; }

.filters-actions {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.result-meta {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 12px;
}

@media (min-width: 720px) {
  .filters-toggle { width: auto; justify-content: flex-start; }
  .filters-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
  .filters-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── Forms ────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.req { color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  appearance: none;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a919b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input.invalid, .select.invalid, .rte.invalid { border-color: var(--danger); }

.input::placeholder { color: var(--text-faint); }

input[type="date"], input[type="month"] { min-height: 41px; }

.field-error {
  font-size: 12px;
  color: var(--danger);
  display: none;
}

.field-error.show { display: block; }

.hint { font-size: 12px; color: var(--text-faint); }

.money-input { position: relative; }

.money-input .input { padding-left: 30px; }

.money-input::before {
  content: "₹";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
}

.readonly-box {
  background: var(--surface-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.readonly-box .icon { width: 15px; height: 15px; color: var(--text-faint); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }

@media (min-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: span 2; }
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn .icon { width: 16px; height: 16px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
[data-theme="dark"] .btn-danger { color: #2b1214; }

.btn-danger-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--danger);
}
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 7px; }
.btn-sm .icon { width: 14px; height: 14px; }

.btn-block { width: 100%; }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn-ghost.btn-loading::after, .btn-danger-ghost.btn-loading::after {
  border-color: var(--border-strong);
  border-top-color: var(--text-muted);
}

/* ── Chips & pills ────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip .icon { width: 12px; height: 12px; margin-right: 4px; }

/* Filled, unlike the soft status chips — a converted lead is a milestone, and
   the solid fill keeps it distinct from the green "High Intent" chip. */
.chip-converted {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

[data-theme="dark"] .chip-converted { color: #12291f; }

.chip-green { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.chip-amber { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.chip-blue { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.chip-red { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.chip-grey { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.pill-yes::before { background: var(--success); }
.pill-no::before { background: var(--border-strong); }
.pill-no { color: var(--text-faint); }

/* ── Lead cards ───────────────────────────────────────────── */

.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }

@media (min-width: 760px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .cards { grid-template-columns: repeat(3, 1fr); } }

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.lead-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.lead-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.lead-chips {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

/* Quiet accent so converted leads are scannable in a long list without
   shouting over the intent colours. */
.lead-card.is-converted { border-left: 3px solid var(--success); }
.lead-row-item.is-converted { border-left: 3px solid var(--success); }

.lead-name {
  font-size: 15.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.meta-item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }

.meta-item .icon { width: 14px; height: 14px; color: var(--text-faint); }

.meta-strong { font-weight: 600; color: var(--text); }

.lead-comments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.comment-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}

.comment-flag .icon { width: 13px; height: 13px; }

.comment-flag.has { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }

.lead-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.lead-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
}

.lead-link .icon { width: 14px; height: 14px; }

.lead-actions { display: flex; gap: 7px; flex: 0 0 auto; }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty-state .icon { width: 34px; height: 34px; color: var(--text-faint); margin-bottom: 10px; }

.empty-state h3 { font-size: 15px; margin-bottom: 4px; color: var(--text); }

.empty-state p { font-size: 13.5px; }

/* ── Admin ────────────────────────────────────────────────── */

.admin-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }

@media (min-width: 900px) {
  .admin-grid { grid-template-columns: 360px 1fr; }
  .admin-grid .add-card { position: sticky; top: calc(var(--header-h) + 58px); }
}

.list-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.list-head h3 { font-size: 15px; }

.count-badge {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 9px;
}

/* Mentor filter inside the "All advisors" header */
.list-filter {
  margin-left: auto;
  width: auto;
  min-width: 150px;
  max-width: 220px;
  font-size: 13px;
  padding: 7px 30px 7px 11px;
}

@media (max-width: 560px) {
  .list-head { flex-wrap: wrap; }
  .list-filter { margin-left: 0; width: 100%; max-width: none; }
}

.person-list { display: flex; flex-direction: column; }

.person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
}

.person-row:last-child { border-bottom: 0; }

.person-main { display: flex; align-items: center; gap: 12px; min-width: 0; }

.person-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.person-meta {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.person-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.person-actions .icon-btn { width: 33px; height: 33px; border-radius: 8px; }
.person-actions .icon-btn .icon { width: 15px; height: 15px; }

.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin: 10px 0 4px;
}

.link-box .mono { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mono {
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.warn-note {
  display: flex;
  gap: 9px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.danger-note {
  display: flex;
  gap: 9px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ── Modal ────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 18, 24, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.16s ease;
}

@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.modal-sm { max-width: 430px; }

@keyframes slideUp { from { transform: translateY(28px); opacity: 0.6; } }

@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 16px; max-height: 86dvh; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-subtitle { font-size: 12.5px; color: var(--text-faint); margin-top: 1px; }

.modal-body { padding: 18px 20px; overflow-y: auto; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
  background: var(--surface);
  border-radius: 0 0 16px 16px;
}

.modal-foot .btn-danger-ghost { margin-right: auto; }

/* ── Rich text editor ─────────────────────────────────────── */

.rte {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rte:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

.rte-toolbar {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
  flex-wrap: wrap;
}

.rte-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.rte-btn:hover { background: var(--surface); color: var(--text); }

.rte-btn .icon { width: 15px; height: 15px; }

.rte-btn[data-cmd="italic"] { font-style: italic; font-family: Georgia, serif; }
.rte-btn[data-cmd="underline"] { text-decoration: underline; }

.rte-area {
  min-height: 96px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  color: var(--text);
}

.rte-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

.rte-area a { text-decoration: underline; }

/* Rendered comment blocks (read-only) */

.comment-block { margin-bottom: 14px; }

.comment-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.comment-label .lock-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 999px;
}

.comment-view {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.comment-view p, .rte-area p, .comment-view div, .rte-area div { margin: 0 0 6px; }
.comment-view p:last-child, .comment-view div:last-child { margin-bottom: 0; }
.comment-view ul, .comment-view ol, .rte-area ul, .rte-area ol { margin: 4px 0; padding-left: 22px; }

.comment-view.empty { color: var(--text-faint); font-style: italic; }

/* ── Toasts ───────────────────────────────────────────────── */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
  max-width: 100%;
  cursor: pointer;
}

[data-theme="dark"] .toast { background: #f0f2f5; color: #23262b; }

.toast .icon { width: 17px; height: 17px; flex: 0 0 auto; }

.toast-success .icon { color: #4ade80; }
.toast-error .icon { color: #f87171; }

[data-theme="dark"] .toast-success .icon { color: #15803d; }
[data-theme="dark"] .toast-error .icon { color: #b91c1c; }

@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } }

.toast.leaving { transition: opacity 0.25s, transform 0.25s; opacity: 0; transform: translateY(8px); }

/* ── Utilities ────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* Label above the batch-advisor tabs (admin) */
.batch-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 4px 0 8px;
}

/* ── Add-Lead draft tabs ──────────────────────────────────── */

.draft-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.draft-tabs::-webkit-scrollbar { height: 6px; }
.draft-tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.draft-tab {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding-right: 4px;
  transition: background 0.15s, border-color 0.15s;
}

.draft-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.draft-tab-label {
  appearance: none;
  border: 0;
  background: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 6px 7px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 999px 0 0 999px;
}

.draft-tab-label span {
  min-width: 0;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-tab-label .icon { width: 14px; height: 14px; flex: 0 0 auto; color: var(--text-faint); }

.draft-tab.active .draft-tab-label { color: var(--accent); font-weight: 600; }
.draft-tab.active .draft-tab-label .icon { color: var(--accent); }

.draft-tab-close {
  appearance: none;
  border: 0;
  background: none;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.draft-tab-close:hover { background: var(--danger-soft); color: var(--danger); }
.draft-tab-close .icon { width: 13px; height: 13px; }

.draft-tab-add {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1px dashed var(--accent-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}

.draft-tab-add:hover { background: var(--accent-soft); }
.draft-tab-add .icon { width: 14px; height: 14px; }

/* ── Leads loading state (server-side paging) ─────────────── */

.list-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.list-loading .icon { width: 18px; height: 18px; }

.icon.spin { animation: spin 0.8s linear infinite; }

/* ── Pagination (20 leads / page) ─────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 20px;
}

.pager-nums { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }

.pager-btn,
.pager-num {
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
}

.pager-num {
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pager-btn .icon { width: 15px; height: 15px; }

.pager-btn:hover:not(:disabled),
.pager-num:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }

.pager-num.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  cursor: default;
}

.pager-btn:disabled,
.pager-num:disabled { opacity: 0.45; cursor: default; }

.pager-gap { padding: 0 4px; color: var(--text-faint); font-weight: 600; align-self: flex-end; }

@media (max-width: 480px) {
  .pager-btn span { display: none; }
}

/* ── Grid / List view toggle ──────────────────────────────── */

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}

.view-toggle-btn {
  appearance: none;
  border: 0;
  background: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn .icon { width: 16px; height: 16px; }

.view-toggle-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── List view rows ───────────────────────────────────────── */

.lead-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lead-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lead-row-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.lrow-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }

.lrow-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lrow-title .lead-name { font-size: 15px; font-weight: 600; }

.lrow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.lrow-side {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .lead-row-item { flex-direction: column; align-items: stretch; }
  .lrow-side { justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); }
}

/* ── Read-only lead detail (admin viewer) ─────────────────── */

.detail-row {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-row:last-of-type { border-bottom: 0; }

.detail-k {
  flex: 0 0 42%;
  max-width: 200px;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
