/* ============================================
   FLARIZE SOLAR CRM — SOLAR MERIDIAN
   Design tokens + custom components
   ============================================ */

:root {
  --bg: #F5F0E8;
  --surface: #FDFAF5;
  --surface-2: #F8F3EB;
  --orange: #E8682A;
  --orange-d: #C4440C;
  --orange-bg: #FFF0E6;
  --amber: #D09008;
  --amber-bg: #FFF8E2;
  --gold: #C2A052;
  --gold-bg: #FDF6E8;
  --dark: #1E2D40;
  --dark-2: #3A5068;
  --gray: #8C7E6E;
  --gray-light: #C8BEAD;
  --border: #E2D8C8;
  --shadow-sm: 0 1px 3px rgba(30, 45, 64, 0.08);
  --shadow: 0 1px 3px rgba(30, 45, 64, 0.08), 0 4px 16px rgba(30, 45, 64, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--dark);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}

/* ====== LAYOUT ====== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--dark);
  color: #fff;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 40;
}

.sidebar-brand {
  padding: 0 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-brand p {
  margin: 4px 0 0;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.15em;
  padding: 16px 12px 6px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: var(--orange);
  color: #fff;
  font-weight: 600;
}

.nav-item .material-symbols-outlined {
  font-size: 20px;
}

.sidebar-user {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8682A, #C4440C);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user .user-info p {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.sidebar-user .user-info span {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
}

/* Role switcher */
.role-switcher {
  margin-top: 12px;
  padding: 0 4px;
}

.role-switcher select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}

.role-switcher select:focus { outline: 1px solid var(--orange); }

/* ====== MAIN ====== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: rgba(253, 250, 245, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
}

.topbar .search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px 8px 40px;
  font-size: 13px;
  width: 320px;
  position: relative;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrapper .material-symbols-outlined {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  font-size: 18px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s;
}

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

.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  background: var(--orange);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.page { padding: 28px; max-width: 1600px; }

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

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-hd h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

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

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
  font-weight: 600;
  margin-bottom: 8px;
}

.kpi-value-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
}

.kpi-delta {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.kpi-delta.up { background: #E6F7EE; color: #1F7A40; }
.kpi-delta.down { background: #FDE8E8; color: #B03131; }
.kpi-delta.neutral { background: var(--orange-bg); color: var(--orange-d); }

/* ====== BUTTONS ====== */
.btn {
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover { background: var(--orange-d); }

.btn-ghost {
  background: transparent;
  color: var(--dark);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-link {
  background: transparent;
  color: var(--orange-d);
  padding: 0;
  font-weight: 700;
  font-size: 12px;
}

/* ====== BADGES / CHIPS ====== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-new { background: var(--orange-bg); color: var(--orange-d); }
.badge-contacted { background: var(--amber-bg); color: #8A5F00; }
.badge-stalled { background: var(--gold-bg); color: #7D6216; }
.badge-closed { background: #EBE7DD; color: var(--gray); }
.badge-won { background: #E6F7EE; color: #1F7A40; }
.badge-blue { background: #E6EFFB; color: #1B4A86; }
.badge-dark { background: #E1E6ED; color: var(--dark); }

.badge-tier-elite { background: linear-gradient(135deg, #FFE4D1, #FFCDA8); color: #9B3800; }
.badge-tier-performer { background: #FDF6E8; color: #7D6216; }
.badge-tier-active { background: #FFF8E2; color: #8A5F00; }
.badge-tier-starter { background: #EBE7DD; color: var(--gray); }

/* ====== LEAD CARD ====== */
.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.lead-card:hover { box-shadow: var(--shadow); }
.lead-card.contacted { border-left-color: var(--amber); }
.lead-card.stalled { border-left-color: var(--gold); }
.lead-card.closed { border-left-color: var(--gray); }

.lead-card-hd {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.lead-name {
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 2px;
  font-size: 14px;
}

.lead-meta {
  font-size: 12px;
  color: var(--gray);
}

.lead-kpis {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 10px 0;
}

.lead-kpi {
  flex: 1;
}

.lead-kpi .l {
  font-size: 10px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lead-kpi .v {
  font-weight: 700;
  color: var(--dark);
  font-size: 13px;
}

/* ====== PIPELINE STAGES ====== */
.pipeline {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pipeline-stage {
  flex: 1;
  min-width: 80px;
  background: var(--surface-2);
  color: var(--gray);
  padding: 8px 6px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
}
.pipeline-stage:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); }
.pipeline-stage:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 8px 50%); }

.pipeline-stage.done {
  background: var(--gold);
  color: #fff;
}
.pipeline-stage.active {
  background: var(--orange);
  color: #fff;
}

.pipeline-stage .v {
  display: block;
  font-size: 14px;
  font-weight: 800;
}

/* ====== FUNNEL ====== */
.funnel {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 4px 0 10px;
}

.funnel-step {
  flex: none;
  min-width: 110px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  text-align: center;
  padding: 4px;
}

.funnel-step.step-1 { background: #E8682A; }
.funnel-step.step-2 { background: #E67822; }
.funnel-step.step-3 { background: #D78220; }
.funnel-step.step-4 { background: #C78A1F; }
.funnel-step.step-5 { background: #B5901E; }
.funnel-step.step-6 { background: #9B931D; }
.funnel-step.step-7 { background: #6D8F30; }
.funnel-step.step-8 { background: #3C8350; }
.funnel-step.step-9 {
  background: #217851;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.funnel-step .s-label {
  font-size: 9px;
  text-transform: uppercase;
  opacity: 0.85;
  letter-spacing: 0.04em;
}

.funnel-step .s-value {
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

/* ====== TABLE ====== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }

.tbl thead { background: var(--surface-2); }

.tbl th {
  text-align: left;
  padding: 12px 14px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--dark);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }

.tbl td.lead-border-new { border-left: 3px solid var(--orange); }
.tbl td.lead-border-contacted { border-left: 3px solid var(--amber); }
.tbl td.lead-border-stalled { border-left: 3px solid var(--gold); }
.tbl td.lead-border-closed { border-left: 3px solid var(--gray); }

/* ====== PROGRESS BARS ====== */
.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress > .fill {
  height: 100%;
  background: var(--orange);
  border-radius: 999px;
  transition: width 0.4s;
}

.progress.thin { height: 4px; }
.progress.thick { height: 10px; }

/* ====== AVATAR ====== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8682A, #C4440C);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

/* ====== FILTERS ====== */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  align-items: center;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="date"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  color: var(--dark);
  font-family: inherit;
}

.filter-bar select:focus,
.filter-bar input:focus { outline: 1px solid var(--orange); border-color: var(--orange); }

/* ====== TV LEADERBOARD (DARK) ====== */
.tv-dark {
  background: var(--dark);
  min-height: 100vh;
  color: #fff;
  padding: 28px;
}
.tv-dark .card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.tv-dark .kpi-label { color: rgba(255, 255, 255, 0.5); }
.tv-dark .kpi-value { color: #fff; }

/* ====== URGENT / SLA CARDS ====== */
.urgent-card {
  background: linear-gradient(135deg, #FFE4E1 0%, #FFF0E6 100%);
  border: 1px solid #F7B9A9;
  border-left: 4px solid #D93025;
  border-radius: var(--radius);
  padding: 16px;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.timer-pill.safe { background: #E6F7EE; color: #1F7A40; }
.timer-pill.warn { background: var(--amber-bg); color: #8A5F00; }
.timer-pill.danger { background: #FDE8E8; color: #B03131; }

/* ====== FAB ====== */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(232, 104, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform 0.15s;
}
.fab:hover { transform: scale(1.08); }
.fab .material-symbols-outlined { font-size: 26px; }

/* ====== UTILITIES ====== */
.grid { display: grid; gap: 20px; }
.g-cols-2 { grid-template-columns: repeat(2, 1fr); }
.g-cols-3 { grid-template-columns: repeat(3, 1fr); }
.g-cols-4 { grid-template-columns: repeat(4, 1fr); }
.g-cols-12 { grid-template-columns: repeat(12, 1fr); }

.col-span-4 { grid-column: span 4; }
.col-span-6 { grid-column: span 6; }
.col-span-8 { grid-column: span 8; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.text-gray { color: var(--gray); }
.text-orange { color: var(--orange-d); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* ====== TABLET (900px) ====== */
@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .sidebar-brand p, .sidebar-brand h1 span.brand-text, .nav-item span:not(.material-symbols-outlined),
  .sidebar-user .user-info, .role-switcher, .nav-section-label { display: none; }
  .sidebar-brand h1 { font-size: 16px; text-align: center; }
  .sidebar-user { justify-content: center; }
  .nav-item { justify-content: center; padding: 10px; }
  .g-cols-4, .g-cols-3 { grid-template-columns: repeat(2, 1fr); }
  .g-cols-12 { grid-template-columns: 1fr; }
  .col-span-4, .col-span-6, .col-span-8 { grid-column: span 1; }
  .topbar .search { width: 140px; }
  .page { padding: 16px; }
}

/* ====== MOBILE (<= 700px) — phone-first layout ====== */

/* Top tab nav — replaces sidebar on phone */
.mobile-tabs { display: none; }

@media (max-width: 700px) {
  /* Hide the desktop sidebar entirely; phone gets the top tab bar. */
  .sidebar { display: none; }

  /* Compact topbar — keeps a brand mark + critical actions only. */
  .topbar { padding: 0 12px; height: 56px; }
  .topbar h2 { font-size: 15px; }
  .topbar .search { display: none; }
  .topbar .search-wrapper { display: none; }

  /* Hide screen title on mobile; show brand instead. */
  .topbar .desktop-only-title { display: none; }

  /* Conn pill: shrink to icon-style on phone. */
  .conn-pill {
    padding: 5px 9px;
    font-size: 10px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Hide secondary topbar icons on phone — only essentials remain
     (conn-pill, check-in for CRS, notifications). */
  .topbar-actions [data-action="frappe-schema"],
  .topbar-actions [data-action="settings-reset"] { display: none; }
  .topbar-actions { gap: 4px; }

  /* Mobile top tab nav (below app bar). */
  .mobile-tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    position: sticky;
    top: 56px;
    z-index: 25;
    scroll-snap-type: x mandatory;
  }
  .mobile-tabs .mtab {
    flex: 1 0 auto;
    min-width: 90px;
    padding: 12px 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: inherit;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    cursor: pointer;
    scroll-snap-align: start;
  }
  .mobile-tabs .mtab.active {
    color: var(--orange-d);
    border-bottom-color: var(--orange);
  }
  .mobile-tabs .mtab-badge {
    display: inline-block;
    background: var(--orange);
    color: #fff;
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
  }

  /* Tighten page padding. */
  .page { padding: 12px; }

  /* Grids always stack. */
  .g-cols-4, .g-cols-3, .g-cols-2, .g-cols-12 { grid-template-columns: 1fr; }
  .col-span-4, .col-span-6, .col-span-8 { grid-column: span 1; }

  /* Filter bar — horizontal scroll instead of wrap. */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 8px;
    -webkit-overflow-scrolling: touch;
  }
  .filter-bar > * { flex-shrink: 0; }

  /* Tables hidden on phone — screens render a `.leads-mobile-grid` instead.
     Screens that don't have a card-grid alternative keep their table but
     get horizontal scroll inside `.table-wrap` (already overflow:hidden;
     override here to allow scroll on small screens). */
  .table-wrap { overflow-x: auto; }
  .tbl { font-size: 12px; }

  /* Screens that render BOTH a table (.table-wrap) and a card grid
     (.leads-mobile-grid) flip visibility per viewport. */
  .leads-desktop-only { display: none; }
  .leads-mobile-grid  { display: flex; flex-direction: column; gap: 8px; }

  /* Lead card — more compact padding on phone. */
  .lead-card { padding: 12px 14px; }
  .lead-card .lead-name { font-size: 15px; }
  .lead-card .lead-kpis { display: none; }  /* replaced by meta line + chips */

  /* Bottom-bleed area for FAB not to overlap bottom action buttons. */
  .main { padding-bottom: 70px; }

  /* Tabs at page level shrink. */
  .tabs { overflow-x: auto; padding-bottom: 2px; }
  .tab { padding: 8px 10px; font-size: 12px; }

  /* Urgent / challenge cards stack. */
  .challenge-card { padding: 16px; }
  .challenge-card .flex { flex-wrap: wrap; }
}

/* ========================================
   MINI PIPELINE (single-letter stage chips)
   ======================================== */
/* Default desktop visibility for the dual-render screens. */
.leads-mobile-grid { display: none; }

/* Lead card row layout — name + checkbox + source on top, others below. */
.lead-card-row { display: flex; align-items: flex-start; gap: 10px; }
.lead-card-check { accent-color: var(--orange); width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; cursor: pointer; }

/* ========================================
   BULK-ACTIONS BAR — hidden until selection
   ======================================== */
.bulk-actions-bar { display: none; }
.bulk-actions-bar.has-selection {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--orange-bg);
  border: 1px solid #F7B98A;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 13px;
}
@media (max-width: 700px) {
  .bulk-actions-bar.has-selection {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    z-index: 60;
    box-shadow: 0 12px 28px rgba(30, 45, 64, 0.22);
    margin-bottom: 0;
    flex-wrap: wrap;
  }
  .bulk-actions-bar .btn-link { font-size: 13px; padding: 4px 6px; }
}

.mini-pipeline {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 2px 0;
  margin: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.mini-pipeline .stage-chip {
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-bg);
  color: var(--gray);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.mini-pipeline .stage-chip.done {
  background: var(--gold-bg);
  color: #7D6216;
  border-color: #E8D9A8;
}
.mini-pipeline .stage-chip.active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange-d);
}

/* ========================================
   STATUS TAGS on lead cards (🔥 Hot, ⏰ FU, ✅ Advance)
   ======================================== */
.status-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}
.chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.chip-tag.hot      { background: #FFE0DA; color: #B03131; }
.chip-tag.followup { background: #FFE9C2; color: #8A5F00; }
.chip-tag.advance  { background: #D1F2D6; color: #1F7A40; }
.chip-tag.stalled  { background: #EBE7DD; color: var(--gray); }

/* Stage-driven next-action chip */
.chip-tag.next-action {
  background: var(--surface-2);
  color: var(--gray);
  border: 1px dashed var(--gray-light);
  font-weight: 600;
  font-style: italic;
}
.chip-tag.next-action.urg-medium  { color: #8A5F00; border-color: var(--amber); }
.chip-tag.next-action.urg-high    { color: var(--orange-d); border-color: var(--orange); background: var(--orange-bg); }
.chip-tag.next-action.urg-critical { color: #B03131; border-color: #F7BDBD; background: #FFE0DA; font-weight: 700; }

/* ========================================
   FILTER CHIPS (All 42 · New 8 · Contacted 12 · …)
   ======================================== */
.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 10px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  margin-bottom: 4px;
}
.chip-filter {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--dark);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: all 0.15s;
}
.chip-filter:hover { background: var(--border); }
.chip-filter.active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
.chip-filter .count {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
}
.chip-filter.active .count { opacity: 1; }

/* ========================================
   BIG INCOMING LEAD CARD (mobile focus view)
   ======================================== */
.incoming-focus {
  background: var(--dark);
  color: #fff;
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 28px rgba(30, 45, 64, 0.25);
}
.incoming-focus .source-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--orange);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.incoming-focus h2 {
  margin: 0;
  font-size: 22px;
  color: #fff;
}
.incoming-focus .sub {
  color: var(--orange);
  font-size: 14px;
  font-weight: 600;
}
.incoming-focus .meta {
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.incoming-focus .big-timer {
  background: #FFE3DE;
  color: #B03131;
  font-size: 56px;
  font-weight: 900;
  text-align: center;
  padding: 20px 16px;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  line-height: 1;
}
.incoming-focus .big-timer.safe   { background: #D1F2D6; color: #1F7A40; }
.incoming-focus .big-timer.warn   { background: #FFE9C2; color: #8A5F00; }
.incoming-focus .big-timer.danger { background: #FFDAD4; color: #B03131; }

.btn-big-primary {
  background: var(--orange);
  color: #fff;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
.btn-big-primary:hover { background: var(--orange-d); }

.btn-big-ghost {
  background: rgba(255,255,255,0.06);
  color: #fff;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-big-ghost:hover { background: rgba(255,255,255,0.1); }

.btn-big-success {
  background: #237047;
  color: #fff;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
.btn-big-success:hover { background: #1B5837; }

/* ========================================
   CHECK-IN PANEL (rich modal body)
   ======================================== */
.checkin-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.checkin-panel .ci-lead-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
}
.checkin-panel .ci-lead-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray);
  font-weight: 700;
}
.checkin-panel .ci-lead-card h4 {
  margin: 4px 0 2px;
  font-size: 15px;
}
.checkin-panel .ci-lead-card .line {
  color: var(--gray);
  font-size: 12px;
}

.ci-gps {
  background: #D1F2D6;
  border: 1px solid #A5E0B0;
  border-radius: 10px;
  padding: 12px 14px;
}
.ci-gps strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #1F7A40;
  margin-bottom: 2px;
}
.ci-gps .coords {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: #1F7A40;
}

.ci-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dark);
  padding: 2px 0;
}
.ci-row strong { font-weight: 700; }

.ci-quote {
  font-style: italic;
  color: var(--gray);
  padding: 10px 14px;
  border-left: 3px solid var(--orange);
  background: var(--orange-bg);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
}

/* ============================================================
   CRS MY LEADS — Online / Manual section headers
   ============================================================ */
.my-leads-section-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
}
.my-leads-section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--dark);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   CRS TODAY — working-hours banner + bottom summary bar
   ============================================================ */
.working-hours-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.working-hours-banner.in-hours {
  background: #E6F7EE;
  color: #1F7A40;
  border: 1px solid #B9E3CB;
}
.working-hours-banner.after-hours {
  background: #FDE8E8;
  color: #B03131;
  border: 1px solid #F7BDBD;
}

.day-summary-bar {
  margin-top: 24px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  bottom: 12px;
  z-index: 10;
}
.day-summary-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.day-summary-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.day-summary-stats strong {
  font-size: 18px;
  color: var(--dark);
  font-weight: 800;
}
.day-summary-stats span {
  font-size: 11px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.day-summary-est {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--dark);
  background: var(--orange-bg);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #F7B98A;
}
.day-summary-est strong { color: var(--orange-d); font-weight: 800; }

@media (max-width: 700px) {
  .day-summary-bar { padding: 12px 14px; flex-direction: column; align-items: stretch; }
  .day-summary-stats { gap: 14px; justify-content: space-between; }
}

/* ============================================================
   AFFILIATE PORTAL — mobile-first, separate visual language.
   ============================================================ */

.aff-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 540px;
  margin: 0 auto;
}

/* Hero card — dark navy with affiliate name + earned */
.aff-hero {
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 100%);
  color: #fff;
  border-radius: 14px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.aff-hero-stat {
  text-align: right;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Bonus tracker card */
.aff-bonus-tracker {
  background: linear-gradient(135deg, var(--orange-bg), #FFE4D1);
  border: 1px solid #F7B98A;
  border-radius: 12px;
  padding: 14px;
}

/* Form section */
.aff-form { padding: 18px; }

.aff-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.aff-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  font-weight: 700;
}
.aff-field input,
.aff-field select,
.aff-field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--dark);
  font-family: inherit;
}
.aff-field input:focus,
.aff-field select:focus,
.aff-field textarea:focus {
  outline: none;
  border-color: var(--orange);
  background: #fff;
}
.aff-field textarea { resize: vertical; min-height: 56px; }

/* System size pills (radio group) */
.aff-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.aff-pill {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}
.aff-pill:hover { border-color: var(--orange); }
.aff-pill input[type="radio"] { display: none; }
.aff-pill input[type="radio"]:checked + span,
.aff-pill:has(input:checked) {
  /* keep in sync with parent */
}
.aff-pill:has(input:checked) {
  background: var(--orange-bg);
  border-color: var(--orange);
  color: var(--orange-d);
}
.aff-pill-comm {
  margin-left: auto;
  font-size: 11px;
  color: var(--gray);
  font-weight: 700;
}
.aff-pill:has(input:checked) .aff-pill-comm { color: var(--orange-d); }

/* Mini stat cards */
.aff-mini-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.aff-mini-stat .v { font-size: 20px; font-weight: 900; color: var(--dark); }
.aff-mini-stat .l { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; font-weight: 700; }

/* Pipeline referral cards */
.aff-ref-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gray-light);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.aff-ref-card.stat-installed { border-left-color: #1F7A40; background: #F4FBF6; }
.aff-ref-card.stat-proposal  { border-left-color: var(--orange); }
.aff-ref-card.stat-visit     { border-left-color: #6E5BC0; }
.aff-ref-card.stat-contacted { border-left-color: #1B4A86; }
.aff-ref-card.stat-submitted { border-left-color: var(--amber); }
.aff-ref-card.stat-dead      { border-left-color: var(--gray); }

.aff-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.aff-status-pill.stat-installed { background: #D1F2D6; color: #1F7A40; }
.aff-status-pill.stat-proposal  { background: var(--orange-bg); color: var(--orange-d); }
.aff-status-pill.stat-visit     { background: #E8E0F7; color: #4F3CA0; }
.aff-status-pill.stat-contacted { background: #DAE6F4; color: #1B4A86; }
.aff-status-pill.stat-submitted { background: var(--amber-bg); color: #8A5F00; }
.aff-status-pill.stat-dead      { background: #EBE7DD; color: var(--gray); }

.aff-ref-note {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--gray);
  font-style: italic;
}

.aff-ref-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Earnings cards */
.aff-earn-card {
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  border: 1px solid;
}
.aff-earn-card.gold   { background: linear-gradient(135deg, #FDF6E8, #F4E4B7); border-color: #E8D9A8; }
.aff-earn-card.orange { background: linear-gradient(135deg, var(--orange-bg), #FFD5BA); border-color: #F7B98A; }
.aff-earn-card.amber  { background: linear-gradient(135deg, var(--amber-bg), #FCE8AB); border-color: #F0DA90; }
.aff-earn-card .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray); font-weight: 700; }
.aff-earn-card .val { font-size: 22px; font-weight: 900; color: var(--dark); margin: 4px 0 2px; }
.aff-earn-card .sub { font-size: 11px; color: var(--gray); }

.aff-payout-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.aff-txn-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.aff-txn-row:last-child { border-bottom: none; }

/* Accordions */
.aff-accordion,
.aff-faq {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}
.aff-accordion { border-radius: var(--radius); margin-top: 0; }
.aff-faq { border-radius: 0; border-top: none; }
.aff-faq:first-of-type { border-top: 1px solid var(--border); }
.aff-faq:last-of-type { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }

.aff-accordion summary,
.aff-faq summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.aff-accordion summary::after,
.aff-faq summary::after {
  content: "›";
  font-size: 22px;
  color: var(--gray);
  transition: transform 0.2s;
}
.aff-accordion[open] summary::after,
.aff-faq[open] summary::after { transform: rotate(90deg); }

.aff-accordion-body,
.aff-faq-body {
  padding: 0 16px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--dark);
}

.aff-rate-grid { display: flex; flex-direction: column; gap: 6px; }
.aff-rate-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
}

/* PM Surya Ghar card — solar themed */
.aff-surya-card {
  position: relative;
  background: linear-gradient(135deg, #2E5266 0%, #1E2D40 100%);
  color: #fff;
  border-radius: 14px;
  padding: 20px;
  overflow: hidden;
}
.aff-surya-bg {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255, 197, 138, 0.35), transparent 65%);
  border-radius: 50%;
}
.aff-surya-stat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.aff-surya-stat strong { color: #FFC58A; font-size: 13px; }
.aff-surya-stat span { font-size: 10px; color: rgba(255, 255, 255, 0.7); }

/* Calculator result */
.aff-calc-result {
  margin-top: 10px;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
}
.aff-calc-empty { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.aff-calc-filled {
  background: linear-gradient(135deg, #F4FBF6, var(--gold-bg));
  border: 1px solid #B8DBC2;
  border-style: solid;
}
.aff-calc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 10px;
}
.aff-calc-grid > div { text-align: left; }
.aff-calc-grid .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray); font-weight: 700; }
.aff-calc-grid strong { font-size: 16px; display: block; margin-top: 2px; }
.aff-calc-headline {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 14px;
  text-align: center;
  border: 1px solid #B8DBC2;
}
.aff-calc-headline strong { color: #1F7A40; font-weight: 900; }

/* QR code frame */
.aff-qr-frame {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.aff-qr-fallback {
  width: 200px;
  height: 200px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 6px;
  color: var(--gray);
}
.aff-qr-link {
  font-size: 12px;
  color: var(--orange-d);
  font-family: ui-monospace, monospace;
  margin-top: 12px;
  word-break: break-all;
}

/* Top bar mobile-brand placeholder (when #page-title is hidden by CSS) */
.mobile-brand {
  display: none;
  font-weight: 800;
  font-size: 15px;
  color: var(--dark);
  letter-spacing: -0.01em;
}
@media (max-width: 700px) {
  .mobile-brand { display: inline-flex; align-items: center; gap: 6px; }
  .mobile-brand::before {
    content: "";
    width: 22px; height: 22px;
    background: linear-gradient(135deg, var(--orange), var(--orange-d));
    border-radius: 6px;
    display: inline-block;
  }
}

/* ====== MISC ====== */
.scroll-x { overflow-x: auto; }

.dot-active { width: 8px; height: 8px; border-radius: 50%; background: #1F7A40; display: inline-block; }
.dot-break { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); display: inline-block; }
.dot-offline { width: 8px; height: 8px; border-radius: 50%; background: #B03131; display: inline-block; }

.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 24px; }
.sparkline span {
  width: 4px;
  background: var(--orange);
  border-radius: 1px;
  opacity: 0.7;
}

/* ====== MAP STUB ====== */
.map-stub {
  background: linear-gradient(135deg, #E8E2D4 0%, #D4CBB8 100%);
  border-radius: var(--radius);
  height: 300px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-stub::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.4) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.6;
}

.map-pin {
  position: absolute;
  width: 32px;
  height: 32px;
  background: var(--orange);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 4px 12px rgba(30, 45, 64, 0.3);
}

/* ====== FOLLOW-UP PICKER ====== */
.followup-input {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.followup-input input {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
}

/* ====== DONUT CHART ====== */
.donut {
  --p: 70;
  --c: var(--orange);
  width: 120px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.donut::before {
  content: "";
  position: absolute;
  inset: 12px;
  background: var(--surface);
  border-radius: 50%;
}
.donut .donut-label {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1;
}
.donut .donut-label strong {
  display: block;
  font-size: 24px;
  color: var(--dark);
}
.donut .donut-label span {
  font-size: 10px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Bar chart stub */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 140px;
  padding: 8px 0;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bar-col .bar {
  width: 100%;
  background: linear-gradient(180deg, var(--orange), var(--orange-d));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.bar-col .lbl {
  font-size: 10px;
  color: var(--gray);
  text-transform: uppercase;
}

/* For stacked bar by stage */
.stack-col {
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  min-height: 4px;
}

/* Badge / milestone grid */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.milestone {
  text-align: center;
  padding: 14px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.milestone.unlocked {
  background: linear-gradient(135deg, #FFF0E6, #FFF8E2);
  border-color: #F7CFB3;
}

.milestone .ico { font-size: 28px; display: block; margin-bottom: 6px; }
.milestone.locked .ico { opacity: 0.25; filter: grayscale(1); }
.milestone .name { font-size: 11px; font-weight: 700; color: var(--dark); }
.milestone .desc { font-size: 10px; color: var(--gray); margin-top: 2px; }

/* Team challenge progress card */
.challenge-card {
  background: linear-gradient(135deg, var(--orange-bg), #FFDABD);
  border: 1px solid #F7B98A;
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.challenge-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(232, 104, 42, 0.25), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* Inline radio cards */
.radio-cards { display: grid; gap: 12px; }
.radio-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
}
.radio-card.selected {
  border-color: var(--orange);
  background: var(--orange-bg);
  box-shadow: 0 0 0 3px rgba(232, 104, 42, 0.12);
}
.radio-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 700; }
.radio-card p { margin: 0; font-size: 12px; color: var(--gray); }

/* Slider */
.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-row input[type="range"] { flex: 1; accent-color: var(--orange); }

/* Shift grid */
.shift-grid {
  display: grid;
  grid-template-columns: 110px repeat(7, 1fr);
  gap: 6px;
  font-size: 12px;
}
.shift-cell {
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.shift-cell.hd { background: var(--dark); color: #fff; font-weight: 700; }

/* List-alike */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }

/* Ticker (tv leaderboard) */
.ticker {
  overflow: hidden;
  background: rgba(232, 104, 42, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 0;
  white-space: nowrap;
}
.ticker-track {
  display: inline-block;
  animation: tick 35s linear infinite;
  padding-left: 100%;
  font-size: 14px;
  font-weight: 600;
  color: #FFE4D1;
}
@keyframes tick { to { transform: translateX(-100%); } }

/* checkboxes in table */
.tbl input[type="checkbox"] { accent-color: var(--orange); width: 16px; height: 16px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}

.tab.active {
  color: var(--orange-d);
  border-bottom-color: var(--orange);
}

.tab:hover:not(.active) { color: var(--dark); }

/* ====== HIDDEN SCROLLBAR ====== */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ========================================
   TOAST NOTIFICATIONS (bottom-right stack)
   ======================================== */
#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(30, 45, 64, 0.18);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 400px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1), opacity 0.22s;
  font-size: 13px;
  color: var(--dark);
}
.toast.toast-in  { transform: translateX(0); opacity: 1; }
.toast.toast-out { transform: translateX(20%); opacity: 0; }
.toast .material-symbols-outlined { font-size: 22px; }

.toast-success { border-left-color: #1F7A40; }
.toast-success .material-symbols-outlined { color: #1F7A40; }

.toast-warn { border-left-color: var(--amber); }
.toast-warn .material-symbols-outlined { color: var(--amber); }

.toast-danger { border-left-color: #B03131; background: #FFF5F5; }
.toast-danger .material-symbols-outlined { color: #B03131; }

.toast-info { border-left-color: #1B4A86; }
.toast-info .material-symbols-outlined { color: #1B4A86; }

.toast-msg { flex: 1; line-height: 1.35; }

.toast-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--gray);
  padding: 2px;
  display: flex;
}
.toast-close .material-symbols-outlined { font-size: 16px; }
.toast-close:hover { color: var(--dark); }

/* ========================================
   MODAL DIALOG
   ======================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 45, 64, 0.55);
  backdrop-filter: blur(4px);
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 20px;
}
.modal-backdrop.modal-in  { opacity: 1; }
.modal-backdrop.modal-out { opacity: 0; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(30, 45, 64, 0.35);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1);
}
.modal-in .modal { transform: scale(1) translateY(0); }

.modal-hd {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-hd h3 { margin: 0; font-size: 16px; font-weight: 700; }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-ft {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Modal form fields */
.mf-row { display: flex; flex-direction: column; gap: 6px; }

.mf-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  font-weight: 700;
}

.mf-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--dark);
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.mf-input:focus {
  outline: none;
  border-color: var(--orange);
  background: #fff;
}

textarea.mf-input { resize: vertical; min-height: 70px; }

.mf-hint { font-size: 11px; color: var(--gray); }

/* Danger variant for destructive buttons */
.btn-danger {
  background: #B03131;
  color: #fff;
}
.btn-danger:hover { background: #8E1E1E; }

/* ========================================
   CONNECTION STATUS PILL (topbar)
   ======================================== */
.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: filter 0.15s;
}
.conn-pill:hover { filter: brightness(0.95); }

.conn-demo    { background: #EBE7DD;          color: var(--gray);   border-color: var(--border); }
.conn-loading { background: var(--amber-bg);  color: #8A5F00;       border-color: #F7E3A0; }
.conn-online  { background: #E6F7EE;          color: #1F7A40;       border-color: #B9E3CB; }
.conn-offline { background: #FDE8E8;          color: #B03131;       border-color: #F7BDBD; }
.conn-queue   { background: var(--orange-bg); color: var(--orange-d); border-color: #F7B98A; }

.conn-online::before,
.conn-loading::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: conn-pulse 2s infinite;
}
@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ========================================
   SKELETON LOADERS (shimmer)
   ======================================== */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    var(--border)    50%,
    var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
  color: transparent;
  display: inline-block;
  min-height: 1em;
  min-width: 40px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row td { color: transparent !important; }
.skeleton-row td > span {
  display: inline-block;
  width: 70%;
  height: 12px;
  background: var(--surface-2);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 3px;
}

.pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--amber);
  margin-left: 6px;
}
.pending-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: conn-pulse 1.3s infinite;
}

/* ========================================
   CLICKABLE LEAD NAMES (opens detail modal)
   ======================================== */
.lead-link {
  cursor: pointer;
  transition: color 0.15s;
  display: inline;
  border-bottom: 1px dashed transparent;
}
.lead-link:hover {
  color: var(--orange-d);
  border-bottom-color: var(--orange);
}

/* ========================================
   LEAD DETAIL MODAL (v2 — tabbed)
   ======================================== */
.lead-detail-v2 .lead-detail-panel {
  max-width: 980px;
  width: 100%;
  height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.lead-detail-hd {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--surface), var(--orange-bg));
  display: flex;
  gap: 14px;
  align-items: center;
  flex-shrink: 0;
}
.lead-detail-hd .avatar { flex-shrink: 0; }
.lead-detail-hd .title-block { flex: 1; min-width: 0; }
.lead-detail-hd h2 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lead-detail-hd .meta {
  color: var(--gray);
  font-size: 11px;
  margin-top: 4px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.lead-detail-hd .meta span {
  white-space: nowrap;
}
.lead-detail-hd .actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.lead-detail-tabs {
  display: flex;
  padding: 0 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.lead-detail-tabs .tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lead-detail-tabs .tab:hover:not(.active) { color: var(--dark); }
.lead-detail-tabs .tab.active {
  color: var(--orange-d);
  border-bottom-color: var(--orange);
  background: var(--surface);
}
.lead-detail-tabs .tab-count {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.lead-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
}

/* ---- Overview two-column grid ---- */
.ld-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.ld-col { display: flex; flex-direction: column; gap: 14px; }

.ld-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.ld-section h4 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ld-subhead {
  margin: 12px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ld-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.ld-field { display: flex; flex-direction: column; gap: 2px; }
.ld-field label {
  font-size: 10px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.ld-field strong {
  font-size: 13px;
  color: var(--dark);
  word-break: break-word;
  font-weight: 600;
}

/* ---- Notes ---- */
.note-form {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.note-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  background: var(--surface);
}
.note-form textarea:focus {
  outline: none;
  border-color: var(--orange);
}

.note-card {
  background: #FFFBF2;
  border: 1px solid #FFE0A6;
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.note-card .note-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--gray);
}
.note-card .note-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--dark);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Timeline ---- */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}
.timeline-item {
  position: relative;
  padding: 0 0 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.timeline-item:last-child { padding-bottom: 4px; }
.timeline-item .t-icon {
  position: absolute;
  left: -28px;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--orange);
  color: var(--orange);
  font-size: 12px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.timeline-item.type-call       .t-icon { border-color: #1F7A40; color: #1F7A40; }
.timeline-item.type-whatsapp   .t-icon { border-color: #1F7A40; color: #1F7A40; }
.timeline-item.type-stage      .t-icon { border-color: var(--amber); color: var(--amber); }
.timeline-item.type-proposal   .t-icon { border-color: var(--orange-d); color: var(--orange-d); }
.timeline-item.type-payment    .t-icon { border-color: #1F7A40; color: #1F7A40; }
.timeline-item.type-visit      .t-icon { border-color: #1B4A86; color: #1B4A86; }
.timeline-item.type-installation .t-icon { border-color: #1F7A40; color: #1F7A40; }
.timeline-item.type-note       .t-icon { border-color: var(--gold); color: var(--gold); }
.timeline-item.type-attachment .t-icon { border-color: var(--gray); color: var(--gray); }

.timeline-item .t-body { flex: 1; min-width: 0; }
.timeline-item .t-time {
  font-size: 11px;
  color: var(--gray);
  margin-bottom: 2px;
  text-transform: capitalize;
}
.timeline-item .t-type {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 10px;
}
.timeline-item .t-text {
  font-size: 13px;
  color: var(--dark);
  line-height: 1.4;
}
.timeline-item .t-author {
  font-size: 11px;
  color: var(--gray);
  margin-top: 2px;
  font-style: italic;
}

/* ---- Attachments ---- */
.attachment-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
}
.attachment-upload:hover {
  border-color: var(--orange);
  background: var(--orange-bg);
}
.attachment-upload input[type="file"] { display: none; }

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background 0.15s;
}
.attachment-row:hover { background: var(--surface-2); }
.attachment-row .icon { font-size: 22px; flex-shrink: 0; }
.attachment-row .meta { flex: 1; min-width: 0; }
.attachment-row .name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dark);
}
.attachment-row .sub {
  font-size: 11px;
  color: var(--gray);
  margin-top: 2px;
}

/* ---- Follow-ups ---- */
.followup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.followup-row:hover { background: var(--surface); }
.followup-row input[type="checkbox"] { accent-color: var(--orange); width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }
.followup-row.overdue { border-color: #F7BDBD; background: #FFF5F5; }
.followup-row.done { opacity: 0.65; }
.followup-row.done .fu-text {
  text-decoration: line-through;
  color: var(--gray);
}
.followup-row .fu-text { font-size: 13px; color: var(--dark); }

/* ---- Empty state ---- */
.empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  color: var(--gray);
  text-align: center;
  gap: 10px;
}
.empty-hint p { margin: 0; font-size: 13px; }

/* ---- Pipeline in modal — compact ---- */
.lead-detail-v2 .pipeline { margin: 0; }
.lead-detail-v2 .pipeline-stage { font-size: 9px; min-width: 60px; padding: 10px 6px; }
.lead-detail-v2 .pipeline-stage .v { font-size: 12px; }

/* ---- Mobile fallback ---- */
@media (max-width: 700px) {
  .lead-detail-v2 .lead-detail-panel {
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .ld-grid-2 { grid-template-columns: 1fr; }
  .lead-detail-hd { padding: 10px 12px; gap: 8px; }
  .lead-detail-hd .avatar { width: 40px; height: 40px; font-size: 14px; }
  .lead-detail-hd h2 { font-size: 15px; }
  .lead-detail-hd .meta { font-size: 10px; gap: 6px; }
  .lead-detail-hd .actions { flex-wrap: wrap; }
}

