/* =====================================================================
   FRANSCALE CRM — STYLESHEET
   ===================================================================== */

:root {
  --blue:        #1E50FF;
  --blue-soft:   #EBF0FF;
  --ink:         #0A0E1A;
  --ink-2:       #1A1F2E;
  --slate-50:    #F8FAFC;
  --slate-100:   #F1F5F9;
  --slate-200:   #E2E8F0;
  --slate-300:   #CBD5E1;
  --slate-400:   #94A3B8;
  --slate-500:   #64748B;
  --slate-600:   #475569;
  --slate-700:   #334155;
  --slate-800:   #1E293B;
  --slate-900:   #0F172A;

  --green:       #10B981;
  --amber:       #F59E0B;
  --rose:        #EF4444;
  --violet:      #8B5CF6;
}

/* === Reset =========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* === App layout ===================================================== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* === Sidebar ======================================================== */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-body::-webkit-scrollbar { width: 6px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 3px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-logo span {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sidebar-logo em {
  font-style: normal;
  color: var(--blue);
}

.sidebar-section {
  padding: 16px 12px 0;
}
.sidebar-section + .sidebar-section { padding-top: 24px; }

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-400);
  padding: 0 12px 8px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-600);
  transition: background 0.12s;
}
.sidebar nav a:hover { background: var(--slate-50); }
.sidebar nav a.active {
  background: var(--ink);
  color: white;
}
.sidebar .ico { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--slate-700);
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--slate-100);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  flex-direction: column;
  padding: 0 8px 8px;
}
.sidebar-user strong {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}
.sidebar-user span {
  font-size: 11px;
  color: var(--slate-500);
}
.sidebar-logout {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--slate-500);
  text-align: center;
  border: 1px solid var(--slate-200);
}
.sidebar-logout:hover {
  background: var(--slate-50);
  color: var(--ink);
}

/* === Topbar ========================================================= */
.topbar {
  height: 64px;
  padding: 0 28px;
  background: white;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.topbar-subtitle {
  font-size: 12px;
  color: var(--slate-500);
  margin: 2px 0 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search svg {
  position: absolute;
  left: 12px;
  color: var(--slate-400);
}
.topbar-search input {
  width: 280px;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--slate-100);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.topbar-search input:focus {
  background: white;
  border-color: var(--slate-300);
}
.topbar-search input:disabled { cursor: not-allowed; opacity: 0.7; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--ink-2));
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Cards / placeholders =========================================== */
.card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  padding: 24px;
}

.placeholder {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  padding: 64px 32px;
  text-align: center;
  max-width: 640px;
  margin: 24px auto;
}
.placeholder-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--blue-soft);
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.placeholder h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}
.placeholder p {
  font-size: 14px;
  color: var(--slate-500);
  margin: 0 auto 20px;
  max-width: 440px;
}
.placeholder-meta {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 13px;
  color: var(--slate-700);
}
.placeholder-meta strong {
  display: inline-block;
  width: 70px;
  color: var(--slate-500);
  font-weight: 500;
}
.placeholder-badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--blue-soft);
  color: var(--blue);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* === Login ========================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(30, 80, 255, 0.08), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(30, 80, 255, 0.05), transparent 50%),
    var(--slate-50);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 8px 24px rgba(10, 14, 26, 0.04);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}
.auth-logo span {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.auth-logo em {
  font-style: normal;
  color: var(--blue);
}
.auth-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--ink);
  text-align: center;
}
.auth-card .auth-sub {
  text-align: center;
  font-size: 14px;
  color: var(--slate-500);
  margin: 0 0 28px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-700);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: 14px;
  background: white;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 80, 255, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 42px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, transform 0.06s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--blue);
  color: white;
  width: 100%;
}
.btn-primary:hover { background: #1640D6; }

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
}
.alert-info {
  background: var(--blue-soft);
  border: 1px solid #C7D8FF;
  color: #1E40AF;
}

.auth-foot {
  margin-top: 20px;
  font-size: 12px;
  color: var(--slate-500);
  text-align: center;
}
.auth-foot strong { color: var(--slate-700); }

/* === STAGE 2 ADDITIONS ============================================== */

/* === Public form styles ============================================= */
.public-form { max-width: 480px; padding: 36px; }
.public-form h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 6px; text-align: center; color: var(--ink);
}

.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-step-meta { margin-bottom: 18px; text-align: center; }
.form-step-badge {
  display: inline-block; padding: 4px 10px; background: var(--blue-soft);
  color: var(--blue); border-radius: 999px; font-size: 11px; font-weight: 600;
}

.form-step-nav {
  display: flex; gap: 10px; margin-top: 24px;
}
.form-step-nav .btn { flex: 1; }

.btn-ghost {
  background: white; color: var(--slate-700);
  border: 1px solid var(--slate-200);
}
.btn-ghost:hover { background: var(--slate-50); }

.field textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--slate-200);
  border-radius: 10px; font-size: 14px; font-family: inherit;
  background: white; outline: none; resize: vertical;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 80, 255, 0.12);
}

.field select {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--slate-200);
  border-radius: 10px; font-size: 14px; background: white; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%2364748B' stroke-width='2' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 80, 255, 0.12);
}

.req { color: var(--rose); font-weight: 500; }
.field-help { font-size: 11px; color: var(--slate-500); margin-top: 4px; }
.field-error {
  font-size: 12px; color: #991B1B; margin-top: 4px; font-weight: 500;
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: #FECACA; }

.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--slate-200);
  border-radius: 10px; cursor: pointer; transition: all 0.12s;
}
.radio-pill:hover { border-color: var(--slate-300); }
.radio-pill input { margin: 0; accent-color: var(--blue); }
.radio-pill:has(input:checked) {
  border-color: var(--blue); background: var(--blue-soft);
}

.scale-group {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px;
}
.scale-pill {
  position: relative;
  text-align: center; cursor: pointer;
}
.scale-pill input { position: absolute; opacity: 0; pointer-events: none; }
.scale-pill span {
  display: block; padding: 10px 0; border: 1px solid var(--slate-200);
  border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--slate-700); background: white; transition: all 0.12s;
}
.scale-pill:hover span { border-color: var(--slate-300); }
.scale-pill:has(input:checked) span {
  background: var(--blue); border-color: var(--blue); color: white;
}

.submitted { text-align: center; padding: 24px 0; }
.submitted-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: #ECFDF5; color: var(--green); margin-bottom: 18px;
}
.submitted h1 { font-size: 24px; margin: 0 0 12px; color: var(--ink); }
.submitted p { color: var(--slate-600); line-height: 1.6; margin: 0; }

/* === Admin: Forms list & lead pages ================================ */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--slate-500); font-size: 13px; }

.data-table {
  background: white; border: 1px solid var(--slate-200);
  border-radius: 16px;
  overflow-x: auto;          /* horizontal scroll when the table can't fit */
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.data-table::-webkit-scrollbar { height: 8px; }
.data-table::-webkit-scrollbar-track { background: transparent; }
.data-table::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 4px; }
.data-table::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

.data-table table {
  width: 100%; border-collapse: collapse;
  min-width: 900px;          /* keeps columns readable when scrolling */
}
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--slate-500); padding: 14px 20px;
  background: var(--slate-50); border-bottom: 1px solid var(--slate-200);
}
.data-table td {
  padding: 14px 20px; border-bottom: 1px solid var(--slate-100);
  font-size: 13px; color: var(--ink); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--slate-50); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
}
.pill-live   { background: #ECFDF5; color: #047857; }
.pill-draft  { background: var(--slate-100); color: var(--slate-700); }
.pill-archived { background: #FEF2F2; color: #991B1B; }
.pill-blue   { background: var(--blue-soft); color: var(--blue); }
.pill-amber  { background: #FEF3C7; color: #92400E; }
.pill-violet { background: #F3E8FF; color: #6B21A8; }

.empty-state {
  background: white; border: 1px dashed var(--slate-300);
  border-radius: 16px; padding: 48px 24px; text-align: center;
}
.empty-state h3 {
  font-size: 16px; font-weight: 600; color: var(--ink);
  margin: 0 0 6px;
}
.empty-state p {
  font-size: 13px; color: var(--slate-500); margin: 0 0 16px;
}

.copy-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; color: var(--slate-600);
  background: var(--slate-50); border: 1px solid var(--slate-200);
  padding: 4px 10px; border-radius: 6px;
  cursor: pointer; transition: background 0.12s;
}
.copy-link:hover { background: var(--slate-100); }

.lead-detail {
  display: grid; grid-template-columns: 1fr 320px; gap: 24px;
  align-items: start;
}
.lead-detail-main { display: flex; flex-direction: column; gap: 16px; }
.lead-detail-side { display: flex; flex-direction: column; gap: 16px; }

.section-card {
  background: white; border: 1px solid var(--slate-200);
  border-radius: 16px; padding: 20px;
}
.section-card h3 {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--slate-500);
  margin: 0 0 14px;
}
.section-card .kv {
  display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px;
  font-size: 13px;
}
.section-card .kv dt { color: var(--slate-500); }
.section-card .kv dd { margin: 0; color: var(--ink); font-weight: 500; }

@media (max-width: 800px) {
  .lead-detail { grid-template-columns: 1fr; }
}

.sidebar-user-link {
  display: block;
  padding: 4px 4px;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background 0.12s;
}
.sidebar-user-link:hover { background: var(--slate-50); }

/* === STAGE 3 ADDITIONS ============================================== */

/* === Stage colour tokens (used by kanban dots, chips, pills, strip) == */
:root {
  --stage-slate-bg:   var(--slate-100);
  --stage-slate-fg:   var(--slate-700);
  --stage-slate-dot:  var(--slate-400);

  --stage-blue-bg:    var(--blue-soft);
  --stage-blue-fg:    var(--blue);
  --stage-blue-dot:   var(--blue);

  --stage-violet-bg:  #F3E8FF;
  --stage-violet-fg:  #6B21A8;
  --stage-violet-dot: var(--violet);

  --stage-amber-bg:   #FEF3C7;
  --stage-amber-fg:   #92400E;
  --stage-amber-dot:  var(--amber);

  --stage-orange-bg:  #FFEDD5;
  --stage-orange-fg:  #9A3412;
  --stage-orange-dot: #F97316;

  --stage-green-bg:   #ECFDF5;
  --stage-green-fg:   #047857;
  --stage-green-dot:  var(--green);
}

/* Stage pill — used on /leads list and lead detail status panel */
.stage-pill {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
}
.stage-pill-slate  { background: var(--stage-slate-bg);  color: var(--stage-slate-fg); }
.stage-pill-blue   { background: var(--stage-blue-bg);   color: var(--stage-blue-fg); }
.stage-pill-violet { background: var(--stage-violet-bg); color: var(--stage-violet-fg); }
.stage-pill-amber  { background: var(--stage-amber-bg);  color: var(--stage-amber-fg); }
.stage-pill-orange { background: var(--stage-orange-bg); color: var(--stage-orange-fg); }
.stage-pill-green  { background: var(--stage-green-bg);  color: var(--stage-green-fg); }


/* === Kanban (pipeline) ============================================== */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}
@media (max-width: 1280px) {
  .kanban {
    grid-template-columns: repeat(6, 240px);
    overflow-x: auto;
    padding-bottom: 12px;
  }
}

.kb-col {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  max-height: calc(100vh - 180px);
}
.kb-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--slate-200);
  flex-shrink: 0;
}
.kb-col-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}
.kb-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.kb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stage-slate-dot);
  flex-shrink: 0;
}
.kb-dot-slate  { background: var(--stage-slate-dot); }
.kb-dot-blue   { background: var(--stage-blue-dot); }
.kb-dot-violet { background: var(--stage-violet-dot); }
.kb-dot-amber  { background: var(--stage-amber-dot); }
.kb-dot-orange { background: var(--stage-orange-dot); }
.kb-dot-green  { background: var(--stage-green-dot); }

.kb-col-body {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
  transition: background 0.12s;
}
.kb-col-body::-webkit-scrollbar { width: 6px; }
.kb-col-body::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 3px; }

.kb-drop-active {
  background: var(--blue-soft);
  outline: 2px dashed var(--blue);
  outline-offset: -4px;
}

.kb-card {
  position: relative;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  cursor: grab;
  transition: box-shadow 0.12s, transform 0.06s, border-color 0.12s;
}
.kb-card:hover { border-color: var(--slate-300); box-shadow: 0 2px 8px rgba(10, 14, 26, 0.06); }
.kb-card:active { cursor: grabbing; }
.kb-card-dragging {
  opacity: 0.45;
  transform: rotate(-1deg);
}
.kb-card-flash {
  animation: kb-flash 0.6s ease-out;
}
@keyframes kb-flash {
  0%   { box-shadow: 0 0 0 0 rgba(30, 80, 255, 0.35); }
  100% { box-shadow: 0 0 0 10px rgba(30, 80, 255, 0); }
}

.kb-card-link {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--ink);
}
.kb-card-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.kb-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 11px;
  color: var(--slate-500);
  margin-bottom: 6px;
}
.kb-card-budget {
  color: var(--slate-700);
  font-weight: 500;
}
.kb-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--slate-500);
}
.kb-card-source {
  background: var(--blue-soft);
  color: var(--blue);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.kb-card-age {
  white-space: nowrap;
}

.kb-card-move {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--slate-400);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.kb-card:hover .kb-card-move,
.kb-card:focus-within .kb-card-move {
  opacity: 1;
}
.kb-card-move:hover {
  background: var(--slate-100);
  color: var(--ink);
}
@media (hover: none) {
  /* On touch devices the ⋯ button is the primary move affordance */
  .kb-card-move { opacity: 1; }
}

/* Move-to-stage popover */
.kb-popover {
  position: absolute;
  z-index: 50;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(10, 14, 26, 0.12);
  padding: 6px;
  min-width: 180px;
}
.kb-popover-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--slate-500);
  padding: 6px 10px 4px;
}
.kb-popover-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}
.kb-popover-btn:hover { background: var(--slate-50); }
.kb-popover-btn-active {
  background: var(--slate-50);
  font-weight: 600;
}
.kb-popover-btn-active::after {
  content: '✓';
  margin-left: auto;
  color: var(--blue);
}

/* Toast */
.kb-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(10, 14, 26, 0.18);
}
.kb-toast-error { background: #991B1B; }


/* === Leads filters toolbar ========================================== */
.leads-toolbar {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.leads-search {
  position: relative;
  display: flex;
  align-items: center;
}
.leads-search svg {
  position: absolute;
  left: 12px;
  color: var(--slate-400);
  pointer-events: none;
}
.leads-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: 13px;
  outline: none;
}
.leads-search input:focus {
  background: white;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 80, 255, 0.12);
}
.leads-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.leads-filter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--slate-500);
  margin-right: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-700);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { background: var(--slate-100); border-color: var(--slate-300); }
.chip-active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.chip-active:hover { background: var(--ink-2); }
.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--slate-300);
}
.chip-slate  .chip-dot { background: var(--stage-slate-dot); }
.chip-blue   .chip-dot { background: var(--stage-blue-dot); }
.chip-violet .chip-dot { background: var(--stage-violet-dot); }
.chip-amber  .chip-dot { background: var(--stage-amber-dot); }
.chip-orange .chip-dot { background: var(--stage-orange-dot); }
.chip-green  .chip-dot { background: var(--stage-green-dot); }
.chip-active .chip-dot { background: white; }

.leads-clear {
  font-size: 12px;
  color: var(--slate-500);
  text-decoration: underline;
}
.leads-clear:hover { color: var(--ink); }


/* === Stage strip on lead detail ===================================== */
.stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stage-strip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
  cursor: pointer;
  transition: all 0.12s;
}
.stage-strip-btn:hover {
  border-color: var(--slate-300);
  background: var(--slate-50);
}
.stage-strip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--slate-400);
}
.stage-strip-slate  .stage-strip-dot { background: var(--stage-slate-dot); }
.stage-strip-blue   .stage-strip-dot { background: var(--stage-blue-dot); }
.stage-strip-violet .stage-strip-dot { background: var(--stage-violet-dot); }
.stage-strip-amber  .stage-strip-dot { background: var(--stage-amber-dot); }
.stage-strip-orange .stage-strip-dot { background: var(--stage-orange-dot); }
.stage-strip-green  .stage-strip-dot { background: var(--stage-green-dot); }

.stage-strip-current {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
  cursor: default;
}
.stage-strip-current .stage-strip-dot { background: white; }
.stage-strip-current:hover { background: var(--ink); border-color: var(--ink); }

.stage-strip-help {
  margin-top: 12px;
  font-size: 11px;
  color: var(--slate-500);
}


/* === Notes (lead detail) ============================================ */
.note-compose {
  margin-bottom: 16px;
}
.note-compose textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  outline: none;
  resize: vertical;
  min-height: 70px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.note-compose textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 80, 255, 0.12);
}
.note-compose-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.note-compose-hint {
  font-size: 11px;
  color: var(--slate-500);
}
.btn-sm {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
  width: auto;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.note-empty {
  font-size: 13px;
  color: var(--slate-500);
  font-style: italic;
  padding: 8px 0;
}
.note {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 12px 14px;
}
.note-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.note-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--ink-2));
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.note-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.note-meta strong {
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
}
.note-meta span {
  font-size: 11px;
  color: var(--slate-500);
}
.note-actions {
  display: flex;
  gap: 4px;
}
.note-action-btn {
  font-size: 11px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  color: var(--slate-600);
  cursor: pointer;
}
.note-action-btn:hover { background: white; color: var(--ink); border-color: var(--slate-300); }
.note-action-danger { color: #B91C1C; }
.note-action-danger:hover { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.note-body {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.note-edit-area textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  outline: none;
  resize: vertical;
  min-height: 60px;
}
.note-edit-area textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 80, 255, 0.12);
}
.note-edit-foot {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}


/* === Activity timeline (lead detail sidebar) ======================== */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--slate-200);
}
.timeline-empty {
  font-size: 12px;
  color: var(--slate-500);
  font-style: italic;
}
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  position: relative;
}
.timeline-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--slate-300);
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  line-height: 1;
}
.timeline-icon[data-type="stage_changed"] {
  border-color: var(--blue);
  color: var(--blue);
}
.timeline-icon[data-type="note_added"] {
  border-color: var(--violet);
  color: var(--violet);
}
.timeline-icon[data-type="note_deleted"] {
  border-color: var(--rose);
  color: var(--rose);
}
.timeline-icon[data-type="lead_created"] {
  border-color: var(--green);
  color: var(--green);
}
.timeline-body {
  flex: 1;
  min-width: 0;
}
.timeline-text {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
}
.timeline-time {
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 2px;
}

/* =========================================================
 * STAGE 4 ADDITIONS — lead scoring
 * ========================================================= */

:root {
  --score-hot-bg:  #fef2f2;
  --score-hot-fg:  #b91c1c;
  --score-hot-dot: #dc2626;
  --score-warm-bg: #fffbeb;
  --score-warm-fg: #b45309;
  --score-warm-dot:#f59e0b;
  --score-cold-bg: #f1f5f9;
  --score-cold-fg: #475569;
  --score-cold-dot:#94a3b8;
}

/* --- Score pill (compact, used in /leads table + breakdown header) --- */
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.score-pill-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.score-pill-tag {
  font-weight: 500;
  font-size: 11px;
  opacity: 0.85;
}
.score-pill-hot  { background: var(--score-hot-bg);  color: var(--score-hot-fg); }
.score-pill-warm { background: var(--score-warm-bg); color: var(--score-warm-fg); }
.score-pill-cold { background: var(--score-cold-bg); color: var(--score-cold-fg); }

/* --- Tag filter chips on /leads --- */
.chip-tag-hot  .chip-dot { background: var(--score-hot-dot); }
.chip-tag-warm .chip-dot { background: var(--score-warm-dot); }
.chip-tag-cold .chip-dot { background: var(--score-cold-dot); }

/* --- Sort toggle on /leads --- */
.leads-sort {
  margin-left: auto;
  font-size: 12px;
  color: var(--slate-500);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.leads-sort a {
  color: var(--slate-500);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 4px;
}
.leads-sort a:hover { color: var(--blue, #2563eb); }
.leads-sort-active {
  color: var(--blue, #2563eb) !important;
  font-weight: 600;
}

/* --- Score breakdown panel on /leads/{id} --- */
.score-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.score-card-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.score-card-out-of {
  color: var(--slate-400);
  font-size: 12px;
  font-weight: 500;
}
.score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.score-row {
  display: grid;
  grid-template-columns: 140px 1fr 32px;
  align-items: center;
  gap: 12px;
}
.score-row-label {
  font-size: 13px;
  color: var(--slate-700, #334155);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.score-row-weight {
  font-size: 10px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}
.score-row-bar {
  height: 8px;
  background: var(--slate-100, #f1f5f9);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.score-row-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.score-row-fill-hot  { background: var(--score-hot-dot); }
.score-row-fill-warm { background: var(--score-warm-dot); }
.score-row-fill-cold { background: var(--score-cold-dot); }
.score-row-value {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--slate-700, #334155);
}
.score-card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-100, #f1f5f9);
  font-size: 11px;
  color: var(--slate-400);
  font-style: italic;
}

@media (max-width: 600px) {
  .score-row { grid-template-columns: 110px 1fr 28px; gap: 8px; }
  .score-row-label { font-size: 12px; }
}

/* =========================================================
 * UI fix — wider meta labels + real PNG logo
 * ========================================================= */
.placeholder-meta strong {
  width: auto;
  min-width: 110px;
  white-space: nowrap;
}
.sidebar-logo-img {
  display: block;
  height: 28px;
  width: auto;
  max-width: 100%;
}

/* =========================================================
 * STAGE 5 ADDITIONS — email templates + send modal
 * ========================================================= */

/* Buttons not previously defined */
.btn-link {
  background: transparent;
  border: 0;
  padding: 0 8px;
  height: 36px;
  color: var(--slate-500);
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
}
.btn-link:hover { color: var(--ink); background: var(--slate-50); }
.btn-danger { color: #b91c1c !important; }
.btn-danger:hover { background: #fef2f2 !important; }

/* Flash messages */
.flash {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-ok  { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash-err { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* Form fields */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--slate-500);
  margin-bottom: 14px;
}
.form-field span em {
  font-style: normal;
  color: var(--slate-400);
  font-weight: 400;
}
.form-field input[type=text],
.form-field input[type=email],
.form-field input[type=password],
.form-field input[type=tel],
.form-field input[type=number],
.form-field input[type=url],
.form-field textarea,
.form-field select {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  width: 100%;
  box-sizing: border-box;
}
.form-field textarea { resize: vertical; min-height: 160px; line-height: 1.55; }
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus { outline: 2px solid var(--blue, #2563eb); outline-offset: -1px; border-color: transparent; }

/* Template editor layout */
.template-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: start;
}
.template-form-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}
.template-form-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.template-form-side {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 18px;
  position: sticky;
  top: 20px;
}
.template-form-side h4 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.template-form-side p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.5;
}
.merge-fields {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.merge-fields li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--slate-200);
}
.merge-fields li:last-child { border-bottom: 0; padding-bottom: 0; }
.merge-fields code {
  font-size: 12px;
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--slate-200);
  align-self: flex-start;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.merge-fields span { font-size: 11px; color: var(--slate-500); }

@media (max-width: 800px) {
  .template-form-grid  { grid-template-columns: 1fr; }
  .template-form-side  { position: static; }
  .template-form-row   { grid-template-columns: 1fr; }
}

/* Email send modal */
.email-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.email-modal[hidden] { display: none; }
.email-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.email-modal-card {
  position: relative;
  background: white;
  border-radius: 14px;
  width: min(640px, 92vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 30px 60px rgba(15,23,42,0.25);
  display: flex;
  flex-direction: column;
}
.email-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--slate-100);
}
.email-modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.email-modal-close {
  background: transparent; border: 0; font-size: 22px; line-height: 1;
  color: var(--slate-500); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px;
}
.email-modal-close:hover { background: var(--slate-100); color: var(--ink); }
.email-modal-body {
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.email-modal-row label {
  display: block;
  font-size: 12px;
  color: var(--slate-500);
  margin-bottom: 6px;
}
.email-modal-row label em { font-style: normal; color: var(--slate-400); font-weight: 400; }
.email-modal-row input,
.email-modal-row select,
.email-modal-row textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  box-sizing: border-box;
}
.email-modal-row textarea { resize: vertical; line-height: 1.55; }
.email-modal-row input:focus,
.email-modal-row select:focus,
.email-modal-row textarea:focus { outline: 2px solid var(--blue, #2563eb); outline-offset: -1px; border-color: transparent; }
.email-modal-static { font-size: 14px; color: var(--ink); padding: 6px 0; }
.email-modal-advanced summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--slate-500);
  padding: 4px 0;
}
.email-modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
 * STAGE 6 ADDITIONS — auth pages, users mgmt
 * ========================================================= */

/* Auth-page body styling so login / forgot / reset / set-password match */
.auth-body {
  min-height: 100vh;
  margin: 0;
  padding: 40px 16px;
  background: linear-gradient(180deg, var(--slate-50, #f8fafc) 0%, white 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink, #0f172a);
}
.auth-body .auth-card {
  background: white;
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 16px;
  padding: 36px 32px;
  width: min(420px, 100%);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
}
.auth-body .auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.auth-body .auth-logo-img {
  display: block;
  height: 36px;
  width: auto;
}
.auth-body h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink, #0f172a);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  text-align: center;
}
.auth-body .auth-sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--slate-500, #64748b);
  text-align: center;
  line-height: 1.55;
}
.auth-body .auth-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.auth-body .auth-submit {
  width: 100%;
  margin-top: 6px;
  height: 42px;
}
.auth-body .auth-msg {
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
  margin: 0;
  padding: 14px;
  border-radius: 10px;
}
.auth-body .auth-msg-ok {
  background: #f0fdf4;
  color: #166534;
}

/* Users page */
.users-invite {
  margin: 0 0 18px;
  background: var(--slate-50, #f8fafc);
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 12px;
  padding: 14px 18px;
}
.users-invite > summary {
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.users-invite > summary::marker { color: var(--slate-400); }
.users-invite-form {
  display: grid;
  grid-template-columns: 1fr 1fr 180px;
  gap: 12px;
  margin-top: 14px;
}
@media (max-width: 720px) {
  .users-invite-form { grid-template-columns: 1fr; }
}
.user-role {
  font-size: 13px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 4px 8px;
  background: white;
}
.user-role:disabled { background: var(--slate-50); color: var(--slate-400); cursor: not-allowed; }
.user-row-disabled { opacity: 0.55; }
.user-row-disabled td { background: var(--slate-50); }

/* =========================================================
 * UI HOTFIX (post-Stage-6-Chunk-A) — logo size, public form
 * layout, radio buttons, login autofill
 * ========================================================= */

/* 1. Logo image — constrain everywhere it's used (login, /f/main-enquiry,
 *    forgot/reset/set-password). Override any ancestor scoping. */
.auth-logo-img {
  display: block !important;
  height: 36px !important;
  width: auto !important;
  max-width: 240px;
  margin: 0 auto;
}
.auth-logo {
  /* Reset any leftover layout from the old SVG-and-text version. */
  margin-bottom: 22px;
  padding: 0;
  text-align: center;
  justify-content: center;
}

/* 2. Public form (/f/main-enquiry) — make sure the card stays inside
 *    the viewport on every step and on small screens. */
.auth-page {
  min-height: 100vh;
  margin: 0;
  padding: 32px 16px;
  background: linear-gradient(180deg, var(--slate-50, #f8fafc) 0%, white 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink, #0f172a);
}
.auth-page .auth-card {
  width: min(560px, 100%);
  box-sizing: border-box;
  padding: 28px;
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 16px;
  background: white;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
  overflow-wrap: break-word;
}
.auth-page .public-form {
  width: min(560px, 100%);
  max-width: 100%;
  padding: 28px;
}
/* Form-step container should never overflow horizontally */
.form-step {
  max-width: 100%;
  box-sizing: border-box;
}
.form-step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.form-step-nav .btn { flex: 0 0 auto; }
.form-step-nav .btn-primary { margin-left: auto; }

/* Turnstile widget — its own row, centred, breathing room above + below */
.cf-turnstile-wrap {
  margin: 14px 0 0;
  display: flex;
  justify-content: center;
}
.cf-turnstile {
  /* Cloudflare iframe is ~300x65; let it size itself but keep centred */
  max-width: 100%;
  overflow: hidden;
}

/* 3. Defensive radio styling — force input-left, text-right layout
 *    and full-width labels so even custom-added radio fields behave. */
.public-form .radio-group {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px;
  width: 100%;
}
.public-form .radio-pill {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100%;
  box-sizing: border-box;
  text-align: left !important;
  padding: 12px 14px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
  background: white;
}
.public-form .radio-pill input[type="radio"] {
  flex: 0 0 auto !important;
  margin: 0 !important;
  width: 18px;
  height: 18px;
  accent-color: var(--blue, #2563eb);
}
.public-form .radio-pill span {
  flex: 1 1 auto;
  display: inline-block !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--ink, #0f172a);
  font-size: 14px;
  font-weight: 500;
  text-align: left !important;
}
.public-form .radio-pill:hover { border-color: var(--slate-300); }
.public-form .radio-pill:has(input:checked) {
  border-color: var(--blue, #2563eb);
  background: var(--blue-soft, #eef2ff);
}

/* 4. Login form — override Chrome/Safari autofill yellow/blue background
 *    so the password field stays visually consistent with email. */
.auth-body input:-webkit-autofill,
.auth-body input:-webkit-autofill:hover,
.auth-body input:-webkit-autofill:focus,
.auth-page input:-webkit-autofill,
.auth-page input:-webkit-autofill:hover,
.auth-page input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px white inset !important;
  -webkit-text-fill-color: var(--ink, #0f172a) !important;
  caret-color: var(--ink, #0f172a);
  transition: background-color 9999s ease-in-out 0s;
  border: 1px solid var(--slate-200) !important;
}

/* Strip the default browser <fieldset> border on the public form steps */
.public-form fieldset.form-step,
.public-form .form-step {
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* =========================================================
 * STAGE 6 CHUNK B — real dashboard
 * ========================================================= */

/* Headline metric cards */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .dash-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .dash-cards { grid-template-columns: 1fr; } }

.dash-card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--slate-500);
}
.dash-card-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--ink, #0f172a);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.dash-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}
.dash-card-foot-meta { color: var(--slate-500); }
.dash-delta { font-weight: 600; }
.dash-delta-up   { color: #16a34a; }
.dash-delta-down { color: #b91c1c; }

/* Funnel + activity feed split */
.dash-split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .dash-split { grid-template-columns: 1fr; } }

.dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dash-section-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.dash-section-link {
  font-size: 12px;
  color: var(--blue, #2563eb);
  text-decoration: none;
}
.dash-section-link:hover { text-decoration: underline; }
.dash-empty {
  color: var(--slate-500);
  font-size: 13px;
  margin: 0;
}

/* Funnel */
.funnel {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.funnel-row {
  display: grid;
  grid-template-columns: 130px 1fr 50px;
  align-items: center;
  gap: 12px;
}
.funnel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--slate-700, #334155);
  text-decoration: none;
}
.funnel-label:hover { color: var(--ink, #0f172a); }
.funnel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.funnel-dot-slate  { background: #94a3b8; }
.funnel-dot-blue   { background: #3b82f6; }
.funnel-dot-violet { background: #8b5cf6; }
.funnel-dot-amber  { background: #f59e0b; }
.funnel-dot-orange { background: #f97316; }
.funnel-dot-green  { background: #16a34a; }

.funnel-bar-wrap {
  height: 22px;
  background: var(--slate-50, #f8fafc);
  border-radius: 6px;
  overflow: hidden;
}
.funnel-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}
.funnel-bar-slate  { background: #cbd5e1; }
.funnel-bar-blue   { background: #93c5fd; }
.funnel-bar-violet { background: #c4b5fd; }
.funnel-bar-amber  { background: #fcd34d; }
.funnel-bar-orange { background: #fdba74; }
.funnel-bar-green  { background: #86efac; }

.funnel-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink, #0f172a);
}

/* Activity feed */
.dash-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-feed-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--slate-100);
}
.dash-feed-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.dash-feed-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--slate-50, #f8fafc);
  color: var(--slate-500);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.dash-feed-icon[data-type="lead_created"]   { background: #dcfce7; color: #166534; }
.dash-feed-icon[data-type="stage_changed"]  { background: #dbeafe; color: #1e40af; }
.dash-feed-icon[data-type="note_added"]     { background: #f3e8ff; color: #6b21a8; }
.dash-feed-icon[data-type="email_sent"]     { background: #fef3c7; color: #b45309; }
.dash-feed-text {
  font-size: 13px;
  color: var(--ink, #0f172a);
  line-height: 1.45;
}
.dash-feed-lead {
  font-weight: 600;
  color: var(--blue, #2563eb);
  text-decoration: none;
}
.dash-feed-lead:hover { text-decoration: underline; }
.dash-feed-time {
  font-size: 11px;
  color: var(--slate-400);
  margin-top: 2px;
}

/* =========================================================
 * Pipeline layout — stages stacked top→bottom, cards flow left→right
 * (override of the original grid-of-columns layout)
 * ========================================================= */

.kanban {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  gap: 12px !important;
  overflow: visible !important;
  padding-bottom: 0 !important;
}
@media (max-width: 1280px) {
  .kanban {
    grid-template-columns: none !important;
    overflow-x: visible !important;
  }
}

/* Each "column" is now a horizontal lane */
.kb-col {
  flex-direction: row !important;
  min-height: auto !important;
  max-height: none !important;
}

/* Lane header — fixed-width strip on the left */
.kb-col-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 160px;
  flex: 0 0 160px;
  padding: 14px 14px;
  border-bottom: 0;
  border-right: 1px solid var(--slate-200);
}
.kb-col-head h3 { font-size: 13px; flex: 0 0 auto; }
.kb-col-head .kb-count {
  margin-top: 2px;
  align-self: flex-start;
}

/* Lane body — cards flow horizontally with horizontal scroll only when needed */
.kb-col-body {
  flex: 1 1 auto;
  flex-direction: row !important;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 92px;
  scrollbar-width: thin;
}
.kb-col-body::-webkit-scrollbar { height: 6px; width: 6px; }

/* Cards: fixed width so they don't stretch to fill the lane */
.kb-card {
  flex: 0 0 220px;
  width: 220px;
  max-width: 220px;
}

/* Empty-state placeholder inside a lane */
.kb-col-body:empty::before {
  content: "Drag a lead here";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 12px;
  color: var(--slate-400);
  font-style: italic;
}

/* Mobile: stack head above the body so cards still get full width */
@media (max-width: 720px) {
  .kb-col { flex-direction: column !important; }
  .kb-col-head {
    width: 100%;
    flex-basis: auto;
    border-right: 0;
    border-bottom: 1px solid var(--slate-200);
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .kb-card { flex-basis: 200px; width: 200px; max-width: 200px; }
}

/* =========================================================
 * Pipeline drop-zone slots + visible scrollbar
 * ========================================================= */

/* Decorative ghost slots — same width as cards, dashed border, big "+". */
.kb-card-slot {
  flex: 0 0 220px;
  width: 220px;
  max-width: 220px;
  min-height: 84px;
  border: 1.5px dashed var(--slate-200, #e2e8f0);
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  color: var(--slate-300, #cbd5e1);
  user-select: none;
  pointer-events: none; /* drop targets are the lane, not these */
  transition: border-color 0.12s, color 0.12s;
}
/* When the user is dragging a card over the lane, the slots highlight too */
.kb-drop-active .kb-card-slot {
  border-color: var(--blue, #2563eb);
  color: var(--blue, #2563eb);
}

/* Visible horizontal scrollbar on lanes — old style was too discreet */
.kb-col-body {
  scrollbar-width: auto;
  scrollbar-color: var(--slate-300, #cbd5e1) transparent;
}
.kb-col-body::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
.kb-col-body::-webkit-scrollbar-track {
  background: var(--slate-100, #f1f5f9);
  border-radius: 6px;
  margin: 0 6px;
}
.kb-col-body::-webkit-scrollbar-thumb {
  background: var(--slate-300, #cbd5e1);
  border-radius: 6px;
  border: 2px solid var(--slate-100, #f1f5f9);
}
.kb-col-body::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400, #94a3b8);
}

/* Mobile: shrink slots to match smaller cards */
@media (max-width: 720px) {
  .kb-card-slot { flex-basis: 200px; width: 200px; max-width: 200px; min-height: 78px; }
}

/* =========================================================
 * Forms editor (/form-edit) + delete-lead button polish
 * ========================================================= */

.form-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) { .form-edit-grid { grid-template-columns: 1fr; } }

.form-field-card {
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: white;
}
.form-field-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}
.form-field-num {
  background: var(--slate-100);
  color: var(--slate-500);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.form-field-key {
  color: var(--slate-500);
  font-size: 11px;
}
.form-field-key code {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
}
.form-field-meta {
  margin-left: auto;
  color: var(--slate-400);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-field-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--slate-700);
}
.form-field-checkbox input { accent-color: var(--blue, #2563eb); }

.form-field-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  gap: 6px;
  align-items: center;
}
.form-field-actions button {
  font-family: inherit;
  font-size: 12px;
  height: 30px;
  padding: 0 10px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  cursor: pointer;
  color: var(--slate-700);
}
.form-field-actions button:hover:not(:disabled) {
  border-color: var(--slate-300);
  background: var(--slate-50);
}
.form-field-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.form-field-actions button.btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
  margin-left: auto;
}
.form-field-actions button.btn-danger:hover:not(:disabled) {
  background: #fef2f2;
}

.form-field-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 8px;
}

/* Wider placeholder layout for the scoped /calendar /reports /territories /settings pages */
.placeholder-wide {
  max-width: 720px;
  text-align: left;
  padding: 48px 40px;
}
.placeholder-wide .placeholder-icon { margin: 0 auto 14px; }
.placeholder-wide .placeholder-badge { display: inline-block; margin-bottom: 12px; }
.placeholder-wide h2 { text-align: left; font-size: 22px; }
.placeholder-wide > p {
  max-width: none;
  text-align: left;
  margin: 0 0 14px;
  line-height: 1.6;
  font-size: 14px;
  color: var(--slate-700, #334155);
}
.placeholder-list {
  margin: 8px 0 14px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--slate-600, #475569);
  line-height: 1.7;
}
.placeholder-list li { margin-bottom: 4px; }
.placeholder-list code,
.placeholder-wide code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  background: var(--slate-50, #f8fafc);
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 4px;
  padding: 1px 5px;
}
.placeholder-foot {
  margin: 14px 0 0 !important;
  padding-top: 14px;
  border-top: 1px solid var(--slate-100, #f1f5f9);
  font-size: 12px !important;
  color: var(--slate-500, #64748b) !important;
}
@media (max-width: 600px) {
  .placeholder-wide { padding: 32px 22px; }
}

/* =========================================================
 * STAGE 7 — extended pipeline colour palette
 * (10 stages now: new, contacted, discovery_booked, discovery_complete,
 *  due_diligence, fdd_sent, validation_calls, agreement_sent, signed, lost)
 * ========================================================= */

:root {
  --stage-sky-bg:  #f0f9ff; --stage-sky-fg:  #0369a1; --stage-sky-dot:  #38bdf8;
  --stage-pink-bg: #fdf2f8; --stage-pink-fg: #9d174d; --stage-pink-dot: #ec4899;
  --stage-teal-bg: #f0fdfa; --stage-teal-fg: #0f766e; --stage-teal-dot: #14b8a6;
  --stage-red-bg:  #fef2f2; --stage-red-fg:  #b91c1c; --stage-red-dot:  #ef4444;
}

.stage-pill-sky   { background: var(--stage-sky-bg);   color: var(--stage-sky-fg); }
.stage-pill-pink  { background: var(--stage-pink-bg);  color: var(--stage-pink-fg); }
.stage-pill-teal  { background: var(--stage-teal-bg);  color: var(--stage-teal-fg); }
.stage-pill-red   { background: var(--stage-red-bg);   color: var(--stage-red-fg); }

.stage-strip-sky  .stage-strip-dot { background: var(--stage-sky-dot); }
.stage-strip-pink .stage-strip-dot { background: var(--stage-pink-dot); }
.stage-strip-teal .stage-strip-dot { background: var(--stage-teal-dot); }
.stage-strip-red  .stage-strip-dot { background: var(--stage-red-dot); }

.funnel-dot-sky  { background: var(--stage-sky-dot); }
.funnel-dot-pink { background: var(--stage-pink-dot); }
.funnel-dot-teal { background: var(--stage-teal-dot); }
.funnel-dot-red  { background: var(--stage-red-dot); }

.funnel-bar-sky  { background: #bae6fd; }
.funnel-bar-pink { background: #fbcfe8; }
.funnel-bar-teal { background: #99f6e4; }
.funnel-bar-red  { background: #fecaca; }

/* =========================================================
 * STAGE 8 — Tasks: list, compose, next-step pills, dashboard cards
 * ========================================================= */

/* Next-step pill — appears on /leads, /tasks, lead detail */
.next-step-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.next-step-overdue { background: #fef2f2; color: #b91c1c; }
.next-step-today   { background: #fff7ed; color: #c2410c; }
.next-step-soon    { background: #fefce8; color: #854d0e; }
.next-step-later   { background: #f0fdf4; color: #166534; }
.next-step-none    { background: transparent; color: var(--slate-400, #94a3b8); padding: 3px 0; }
.next-step-done    { background: #ecfdf5; color: #047857; }

/* Compose form on lead detail */
.task-compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--slate-100, #f1f5f9);
}
.task-compose input[type=text] {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  box-sizing: border-box;
  background: white;
}
.task-compose input[type=text]:focus {
  outline: 2px solid var(--blue, #2563eb);
  outline-offset: -1px;
  border-color: transparent;
}
.task-compose-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 8px;
  align-items: center;
}
.task-compose-row input[type=date],
.task-compose-row select {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  height: 36px;
  box-sizing: border-box;
}
.task-compose-row .btn { height: 36px; }
@media (max-width: 600px) {
  .task-compose-row { grid-template-columns: 1fr; }
}

/* Task list on lead detail */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task-empty {
  padding: 10px 0;
  font-size: 13px;
  color: var(--slate-500);
  font-style: italic;
}

.task-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.task-item:hover { background: var(--slate-50, #f8fafc); }
.task-item.task-done { opacity: 0.55; }
.task-item.task-done .task-title { text-decoration: line-through; }

.task-tick {
  width: 20px; height: 20px;
  border: 2px solid var(--slate-300, #cbd5e1);
  border-radius: 50%;
  background: white;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s;
}
.task-tick:hover:not(:disabled) {
  border-color: var(--blue, #2563eb);
  background: #eff6ff;
}
.task-tick:disabled { opacity: 0.5; cursor: not-allowed; }
.task-tick-done {
  background: #16a34a !important;
  border-color: #16a34a !important;
}
.task-tick-done::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: 700;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.task-body { min-width: 0; }
.task-title { font-size: 13px; font-weight: 500; color: var(--ink, #0f172a); line-height: 1.4; }
.task-desc {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 2px;
  line-height: 1.45;
}
.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--slate-500);
}
.task-assignee { color: var(--slate-500); }

.task-delete {
  background: transparent;
  border: 0;
  width: 24px; height: 24px;
  font-size: 18px;
  line-height: 1;
  color: var(--slate-400);
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.task-item:hover .task-delete { opacity: 1; }
.task-delete:hover { background: #fef2f2; color: #b91c1c; }

/* Dashboard task cards: red number when overdue is non-zero */
.dash-card-value-warn { color: #b91c1c; }

/* Tasks page tick — slightly bigger, table-cell style */
#tasksTable .task-tick { margin: 0 auto; display: block; }

/* =========================================================
 * STAGE 9 — Sequences card (lead detail) and timeline icons
 * ========================================================= */
.seq-active-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink, #0f172a);
  margin-bottom: 4px;
}
.seq-active-progress {
  font-size: 12px;
  color: var(--slate-500, #64748b);
  line-height: 1.55;
  margin-bottom: 10px;
}
.seq-active-actions {
  display: flex;
  gap: 6px;
}
.seq-enrol-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.seq-enrol-row select {
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 6px 8px;
  height: 32px;
  background: white;
  width: 100%;
  box-sizing: border-box;
}
.seq-enrol-row .btn-sm { height: 32px; }

/* Sequence-related timeline icons */
.timeline-icon[data-type^="sequence_"] { background: #ede9fe; color: #6d28d9; }
.timeline-icon[data-type="sequence_completed"] { background: #dcfce7; color: #166534; }
.timeline-icon[data-type="sequence_cancelled"] { background: #fef2f2; color: #b91c1c; }
.timeline-icon[data-type="sequence_paused"]    { background: #fef3c7; color: #b45309; }

/* =========================================================
 * STAGE 10 — Reports & Analytics
 * ========================================================= */

.report-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
}
.report-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.report-section { margin-bottom: 16px; }
.report-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.report-head h3 { margin: 0; }
.report-head-meta {
  font-size: 12px;
  color: var(--slate-500);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.report-head-meta strong { color: var(--ink); }

.report-export-link {
  font-size: 12px;
  color: var(--blue, #2563eb);
  text-decoration: none;
  white-space: nowrap;
}
.report-export-link::before { content: '↓ '; }
.report-export-link:hover { text-decoration: underline; }

.report-empty {
  margin: 0;
  padding: 20px 0;
  font-size: 13px;
  color: var(--slate-500);
  font-style: italic;
}

/* Time-series SVG bar chart */
.report-chart {
  width: 100%;
  height: auto;
  display: block;
  font-family: inherit;
}
.report-chart .report-grid { stroke: #e2e8f0; stroke-width: 1; }
.report-chart .report-axis { font-size: 10px; fill: #94a3b8; }
.report-chart .report-bar  { fill: #3b82f6; transition: fill 0.15s; }
.report-chart .report-bar:hover { fill: #1d4ed8; }

/* Horizontal bar groups */
.report-hbars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.report-hbar-row {
  display: grid;
  grid-template-columns: 180px 1fr 110px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
@media (max-width: 720px) {
  .report-hbar-row { grid-template-columns: 130px 1fr 90px; }
}
.report-hbar-label { color: var(--slate-700); display: flex; align-items: center; gap: 6px; }
.report-hbar-track {
  background: var(--slate-50, #f8fafc);
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
}
.report-hbar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}
.report-hbar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

/* Tables inside reports */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.report-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--slate-500);
  padding: 8px 10px;
  border-bottom: 1px solid var(--slate-200);
}
.report-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}
.report-table tbody tr:last-child td { border-bottom: 0; }
.report-table tbody td strong { color: var(--ink); }

.report-funnel td:first-child { display: flex; align-items: center; gap: 8px; padding-top: 14px; padding-bottom: 14px; }

.report-drop {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 11px;
  font-weight: 600;
}

.report-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.report-two-col h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--slate-500);
}
@media (max-width: 900px) {
  .report-two-col { grid-template-columns: 1fr; }
}

/* =========================================================
 * STAGE 11 — Territories: list, map, conflict banner
 * ========================================================= */

/* Status pills */
.terr-pill { font-weight: 600; }
.terr-pill-available { background: #dcfce7; color: #166534; }
.terr-pill-reserved  { background: #fef3c7; color: #92400e; }
.terr-pill-sold      { background: #fef2f2; color: #b91c1c; }

/* Map container */
.terr-map {
  height: 480px;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  z-index: 0; /* Leaflet markers/popups have higher z, but stay below modals */
}
.terr-map-card { padding: 16px; }

.terr-map-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--slate-500);
}
.terr-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}
.terr-dot-available { background: #16a34a; }
.terr-dot-reserved  { background: #f59e0b; }
.terr-dot-sold      { background: #ef4444; }

/* Conflict banner on lead detail */
.terr-conflict-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #7f1d1d;
}
.terr-conflict-banner a {
  color: #b91c1c;
  font-weight: 600;
}
.terr-conflict-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-weight: 700;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Timeline icon for territory_conflict */
.timeline-icon[data-type="territory_conflict"] {
  background: #fef2f2; color: #b91c1c;
}

/* =========================================================
 * STAGE 12 — Calendar (month grid of tasks)
 * ========================================================= */

.cal-wrap {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  overflow: hidden;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--slate-100, #f1f5f9);
}

.cal-dow {
  background: var(--slate-50, #f8fafc);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--slate-500);
}

.cal-cell {
  background: white;
  min-height: 110px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  font-size: 12px;
}
.cal-cell-out      { background: var(--slate-50, #f8fafc); }
.cal-cell-out .cal-cell-date { color: var(--slate-400); }
.cal-cell-weekend  { background: #fcfcfd; }
.cal-cell-out.cal-cell-weekend { background: #f5f6f8; }

.cal-cell-today    {
  background: #eff6ff;
}
.cal-cell-today .cal-cell-date {
  background: var(--blue, #2563eb);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
}

.cal-cell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.cal-cell-date {
  font-weight: 600;
  font-size: 12px;
  color: var(--slate-700);
}
.cal-cell-count {
  font-size: 10px;
  color: var(--slate-400);
  background: var(--slate-100);
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 600;
}

.cal-pill {
  display: block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.35;
  text-decoration: none;
  color: var(--ink, #0f172a);
  border-left: 3px solid transparent;
  background: white;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background 0.12s;
}
.cal-pill:hover { background: var(--slate-50); }

.cal-pill-overdue {
  background: #fef2f2;
  border-left-color: #ef4444;
  color: #991b1b;
}
.cal-pill-today {
  background: #fff7ed;
  border-left-color: #f97316;
  color: #9a3412;
}
.cal-pill-future {
  background: #f0fdf4;
  border-left-color: #22c55e;
  color: #166534;
}
.cal-pill-done {
  background: var(--slate-50);
  border-left-color: var(--slate-300);
  color: var(--slate-500);
  text-decoration: line-through;
}

.cal-pill-title { font-weight: 500; }
.cal-pill-lead  { color: var(--slate-500); font-weight: 400; }

.cal-more {
  font-size: 11px;
  color: var(--slate-500);
  text-decoration: none;
  padding: 2px 6px;
}
.cal-more:hover { color: var(--blue); text-decoration: underline; }

/* Mobile: stack to a list view rather than a grid */
@media (max-width: 720px) {
  .cal-grid { grid-template-columns: 1fr; }
  .cal-dow { display: none; }
  .cal-cell {
    min-height: auto;
    padding: 10px 12px;
  }
  .cal-cell-out { display: none; }
  .cal-cell-head { border-bottom: 1px solid var(--slate-100); padding-bottom: 4px; margin-bottom: 6px; }
  .cal-cell-date::after {
    content: ' ' attr(data-day-name);
    color: var(--slate-500);
    font-weight: 400;
  }
}

/* =========================================================
 * Stage 13 — compact /leads filter bar
 * ========================================================= */

.leads-toolbar-compact {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leads-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.leads-row-primary {
  gap: 10px;
}

.leads-row-primary .leads-search {
  flex: 1 1 240px;
  min-width: 200px;
  margin: 0;
}

.leads-select {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 7px 10px;
  background: white;
  height: 36px;
  color: var(--slate-700);
  cursor: pointer;
  max-width: 200px;
}
.leads-select:focus {
  outline: 2px solid var(--blue, #2563eb);
  outline-offset: -1px;
  border-color: transparent;
}

.leads-row-divider {
  width: 1px;
  height: 18px;
  background: var(--slate-200);
  margin: 0 6px;
}

.leads-row-primary .leads-sort {
  margin-left: auto;
  font-size: 12px;
  color: var(--slate-500);
}

@media (max-width: 720px) {
  .leads-row-primary .leads-search { flex-basis: 100%; order: -1; }
  .leads-row-primary .leads-sort   { margin-left: 0; }
  .leads-row-divider { display: none; }
}

/* =========================================================
 * STAGE 15 — Help system
 * ========================================================= */

.help-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .help-shell { grid-template-columns: 1fr; }
}

/* Sidebar */
.help-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;            /* keep sidebar at top of cell, content-height */
  max-height: calc(100vh - 100px); /* don't run off screen on tall sidebars */
  overflow-y: auto;             /* scroll internally if content overflows */
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 14px;
}
@media (max-width: 900px) {
  .help-sidebar {
    position: static;           /* on mobile the sidebar stacks above article */
    max-height: none;
  }
}
.help-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--slate-50, #f8fafc);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 14px;
  color: var(--slate-500);
}
.help-search input {
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  color: var(--ink);
}

.help-nav-cat { margin-bottom: 14px; }
.help-nav-cat:last-child { margin-bottom: 0; }
.help-nav-cat h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--slate-500);
}
.help-nav-cat ul { list-style: none; padding: 0; margin: 0; }
.help-nav-cat li { margin: 0; }
.help-nav-cat a {
  display: block;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--slate-700);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.4;
}
.help-nav-cat a:hover { background: var(--slate-50); color: var(--ink); }
.help-nav-cat a.help-nav-active {
  background: #eff6ff;
  color: var(--blue, #2563eb);
  font-weight: 600;
}

/* Main pane */
.help-main {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 28px 36px;
  min-height: 400px;
}
@media (max-width: 720px) {
  .help-main { padding: 20px 18px; }
}

.help-breadcrumb {
  font-size: 12px;
  color: var(--slate-500);
  margin-bottom: 14px;
}
.help-breadcrumb a { color: var(--blue, #2563eb); text-decoration: none; }
.help-breadcrumb a:hover { text-decoration: underline; }

/* Article typography */
.help-article {
  font-size: 14px;
  line-height: 1.65;
  color: var(--slate-700);
  max-width: 720px;
}
.help-article h1.help-h1 { font-size: 24px; line-height: 1.25; margin: 0 0 14px; color: var(--ink); }
.help-article h2.help-h2 { font-size: 18px; line-height: 1.3;  margin: 28px 0 10px; color: var(--ink); }
.help-article h3.help-h3 { font-size: 15px; line-height: 1.35; margin: 22px 0 8px; color: var(--ink); }
.help-article p { margin: 0 0 12px; }
.help-article ul.help-ul, .help-article ol.help-ol {
  margin: 0 0 14px;
  padding-left: 20px;
}
.help-article ul.help-ul li, .help-article ol.help-ol li { margin: 4px 0; }
.help-article a { color: var(--blue, #2563eb); }
.help-article strong { color: var(--ink); }
.help-article code.help-inline-code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  background: var(--slate-50, #f8fafc);
  border: 1px solid var(--slate-200);
  border-radius: 4px;
  padding: 1px 6px;
}
.help-article pre.help-code {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  margin: 14px 0;
}
.help-article pre.help-code code { background: none; border: 0; padding: 0; color: inherit; }
.help-article blockquote.help-quote {
  border-left: 3px solid var(--slate-300);
  padding: 4px 0 4px 14px;
  margin: 14px 0;
  color: var(--slate-600);
}
.help-article table {
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
  width: 100%;
}
.help-article th, .help-article td {
  border: 1px solid var(--slate-200);
  padding: 6px 10px;
  text-align: left;
}
.help-article th { background: var(--slate-50); font-weight: 600; }

/* Search results */
.help-search-summary {
  font-size: 13px;
  color: var(--slate-500);
  margin-bottom: 18px;
}
.help-search-summary strong { color: var(--ink); }
.help-search-summary a { color: var(--slate-500); margin-left: 6px; }

.help-results {
  list-style: none;
  padding: 0;
  margin: 0;
}
.help-results li {
  padding: 14px 0;
  border-bottom: 1px solid var(--slate-100);
}
.help-results li:last-child { border-bottom: 0; }
.help-result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.help-result-title:hover { color: var(--blue, #2563eb); }
.help-result-meta {
  font-size: 11px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}
.help-result-snippet {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--slate-600);
  line-height: 1.55;
}
mark.help-mark {
  background: #fef08a;
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}

.help-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--slate-500);
}
.help-empty h3 { color: var(--ink); margin: 0 0 6px; }
