*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }

/* ── THEME VARIABLES ─────────────────────────────────────── */
:root, [data-theme="light"] {
  --bg:       #f2f4f8;
  --surface:  #ffffff;
  --surface2: #f6f7fb;
  --surface3: #edf0f5;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.14);
  --text:     #1a1d2e;
  --muted:    #6b7280;
  --shadow:   rgba(0,0,0,0.04);
  --map-filter: none;
}

[data-theme="dark"] {
  --bg:       #0b0d12;
  --surface:  #111318;
  --surface2: #181b24;
  --surface3: #1e2130;
  --border:   rgba(255,255,255,0.06);
  --border2:  rgba(255,255,255,0.11);
  --text:     #e4e6f0;
  --muted:    #7a8399;
  --shadow:   rgba(0,0,0,0.28);
  --map-filter: brightness(0.9) invert(1) hue-rotate(180deg);
}

/* Colour tokens */
:root {
  --accent:   #6c5ce7;
  --blue:     #4a90e2;
  --green:    #27d49c;
  --orange:   #f39c12;
  --red:      #e74c3c;
  --yellow:   #f1c40f;
  --pink:     #e84393;
  --wa:       #25d366;
  --fb:       #1877f2;
  --r:        0px;
  --rl:       0px;
  --shadow-card: 0 1px 2px var(--shadow), 0 6px 16px var(--shadow);
  --shadow-card-hover: 0 2px 4px var(--shadow), 0 10px 24px var(--shadow);
}

body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px; display: flex; min-height: 100vh; line-height: 1.6; transition: background 0.25s, color 0.25s; overflow-x: hidden; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar { width: 234px; min-height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; overflow-y: auto; transition: background 0.25s; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; margin-bottom: 28px; }
.brand-dot { width: 30px; height: 30px; background: var(--accent); border-radius: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0; }
.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.2px; }
.brand-sub  { font-size: 10px; color: var(--muted); letter-spacing: 0.5px; text-transform: uppercase; }

.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); padding: 0 10px; margin: 18px 0 6px; font-weight: 600; }
.nav-links { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 9px; border-radius: 0; color: var(--muted); text-decoration: none; font-size: 13.5px; transition: all 0.12s; }
.nav-link:hover  { background: var(--surface2); color: var(--text); }
.nav-link.active { background: rgba(108,92,231,0.08); color: var(--accent); font-weight: 600; }
.nav-link svg { flex-shrink: 0; width: 16px; height: 16px; }
.nav-link .nav-badge { margin-left:auto; background:var(--accent); color:#fff; border-radius: 0; font-size:10px; padding:1px 6px; font-weight:600; }
.nav-link .nav-badge.green { background:var(--wa); }
.nav-link .nav-badge.blue  { background:var(--fb); }

.sidebar-user { margin-top: auto; padding: 14px 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 10.5px; color: var(--muted); text-transform: capitalize; }

/* ── MAIN ────────────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 32px; padding-top: max(14px, env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; flex-wrap: wrap; transition: background 0.25s; }
.topbar-title { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-body { padding: 28px 32px; flex: 1; overflow-y: auto; }

/* ── FLASH ───────────────────────────────────────────────── */
.flash { padding: 11px 16px; border-radius: 0; margin-bottom: 20px; font-size: 13px; border: 1px solid; }
.flash-success { background: rgba(39,212,156,0.08); border-color: rgba(39,212,156,0.25); color: #1a7a5a; }
.flash-error   { background: rgba(231,76,60,0.08);  border-color: rgba(231,76,60,0.25);  color: #c0392b; }
[data-theme="dark"] .flash-success { color: var(--green); }
[data-theme="dark"] .flash-error   { color: var(--red); }

/* ── STAT GRID ───────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); padding: 18px 20px; box-shadow: var(--shadow-card); transition: background 0.25s, box-shadow 0.15s, transform 0.15s; }
.stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; font-weight:600; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -1px; font-family: 'DM Mono', monospace; }
.stat-sub   { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ── CARDS ───────────────────────────────────────────────── */
.card { background: var(--surface); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-card); transition: background 0.25s, box-shadow 0.15s; }
.card-title { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

/* ── PAGE HEADER (optional, drop at top of a page-body) ──── */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.page-header h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
.page-header .page-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.page-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── GRID HELPERS ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 0; font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif; cursor: pointer; text-decoration: none; border: 1px solid; transition: background 0.12s, border-color 0.12s, opacity 0.12s; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { background: #5d4bd0; }
.btn-green  { background: var(--green);  color: #fff; border-color: transparent; }
.btn-green:hover { opacity: 0.88; }
.btn-ghost  { background: transparent; color: var(--muted); border-color: var(--border2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(231,76,60,0.25); }
.btn-danger:hover { background: rgba(231,76,60,0.08); }
.btn-orange { background: var(--orange); color: #fff; border-color: transparent; }
.btn-orange:hover { opacity: 0.88; }
.btn-wa  { background: var(--wa);  color: #fff; border-color: transparent; }
.btn-wa:hover  { opacity: 0.88; }
.btn-fb  { background: var(--fb);  color: #fff; border-color: transparent; }
.btn-fb:hover  { opacity: 0.88; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 9px; font-size: 11px; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 0; font-size: 11px; font-weight: 500; border: 1px solid; }
.badge-pending    { background: rgba(122,131,153,0.1);  border-color: rgba(122,131,153,0.25); color: var(--muted); }
.badge-approved   { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-flagged    { background: rgba(243,156,18,0.1);   border-color: rgba(243,156,18,0.25);  color: #b7770d; }
.badge-rejected   { background: rgba(231,76,60,0.1);    border-color: rgba(231,76,60,0.25);   color: #c0392b; }
.badge-hot        { background: rgba(231,76,60,0.1);    border-color: rgba(231,76,60,0.25);   color: #c0392b; }
.badge-warm       { background: rgba(243,156,18,0.1);   border-color: rgba(243,156,18,0.25);  color: #b7770d; }
.badge-cold       { background: rgba(74,144,226,0.1);   border-color: rgba(74,144,226,0.25);  color: #2563a8; }
.badge-new        { background: rgba(108,92,231,0.1);   border-color: rgba(108,92,231,0.25);  color: #5b48c9; }
.badge-contacted  { background: rgba(74,144,226,0.1);   border-color: rgba(74,144,226,0.25);  color: #2563a8; }
.badge-demo       { background: rgba(243,156,18,0.1);   border-color: rgba(243,156,18,0.25);  color: #b7770d; }
.badge-proposal   { background: rgba(232,67,147,0.1);   border-color: rgba(232,67,147,0.25);  color: #b5005b; }
.badge-converted  { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-lost       { background: rgba(231,76,60,0.1);    border-color: rgba(231,76,60,0.25);   color: #c0392b; }
.badge-active     { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-paid       { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-draft      { background: rgba(122,131,153,0.1);  border-color: rgba(122,131,153,0.25); color: var(--muted); }
.badge-published  { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-scheduled  { background: rgba(74,144,226,0.1);   border-color: rgba(74,144,226,0.25);  color: #2563a8; }
.badge-queued     { background: rgba(122,131,153,0.1);  border-color: rgba(122,131,153,0.25); color: var(--muted); }
.badge-sent       { background: rgba(74,144,226,0.1);   border-color: rgba(74,144,226,0.25);  color: #2563a8; }
.badge-delivered  { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-replied    { background: rgba(108,92,231,0.1);   border-color: rgba(108,92,231,0.25);  color: #5b48c9; }
.badge-failed     { background: rgba(231,76,60,0.1);    border-color: rgba(231,76,60,0.25);   color: #c0392b; }
.badge-whatsapp   { background: rgba(37,211,102,0.1);   border-color: rgba(37,211,102,0.25);  color: #1a8a42; }
.badge-facebook   { background: rgba(24,119,242,0.1);   border-color: rgba(24,119,242,0.25);  color: #0d4fa8; }
.badge-both       { background: rgba(108,92,231,0.1);   border-color: rgba(108,92,231,0.25);  color: #5b48c9; }
.badge-admin      { background: rgba(232,67,147,0.1);   border-color: rgba(232,67,147,0.25);  color: #b5005b; }
.badge-team_leader{ background: rgba(108,92,231,0.1);   border-color: rgba(108,92,231,0.25);  color: #5b48c9; }
.badge-agent      { background: rgba(74,144,226,0.1);   border-color: rgba(74,144,226,0.25);  color: #2563a8; }
.badge-in_person  { background: rgba(39,212,156,0.1);   border-color: rgba(39,212,156,0.25);  color: #1a7a5a; }
.badge-phone_call { background: rgba(74,144,226,0.1);   border-color: rgba(74,144,226,0.25);  color: #2563a8; }
.badge-email      { background: rgba(108,92,231,0.1);   border-color: rgba(108,92,231,0.25);  color: #5b48c9; }
[data-theme="dark"] .badge-approved, [data-theme="dark"] .badge-active,
[data-theme="dark"] .badge-paid, [data-theme="dark"] .badge-published,
[data-theme="dark"] .badge-converted, [data-theme="dark"] .badge-delivered,
[data-theme="dark"] .badge-whatsapp, [data-theme="dark"] .badge-in_person { color: var(--green); }
[data-theme="dark"] .badge-hot, [data-theme="dark"] .badge-rejected,
[data-theme="dark"] .badge-lost, [data-theme="dark"] .badge-failed { color: var(--red); }
[data-theme="dark"] .badge-warm, [data-theme="dark"] .badge-flagged,
[data-theme="dark"] .badge-demo { color: var(--orange); }
[data-theme="dark"] .badge-cold, [data-theme="dark"] .badge-contacted,
[data-theme="dark"] .badge-sent, [data-theme="dark"] .badge-scheduled,
[data-theme="dark"] .badge-agent, [data-theme="dark"] .badge-phone_call,
[data-theme="dark"] .badge-email, [data-theme="dark"] .badge-facebook { color: var(--blue); }
[data-theme="dark"] .badge-proposal, [data-theme="dark"] .badge-admin { color: var(--pink); }
[data-theme="dark"] .badge-new, [data-theme="dark"] .badge-team_leader,
[data-theme="dark"] .badge-replied, [data-theme="dark"] .badge-both { color: var(--accent); }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 0; box-shadow: var(--shadow-card); }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--surface2); }
th { text-align: left; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; padding: 10px 14px; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13px; }
tbody tr:first-child td { border-top: none; }
tr:hover td { background: var(--surface2); }
.tlink { color: var(--text); text-decoration: none; font-weight: 500; }
.tlink:hover { color: var(--accent); }

/* ── PROGRESS ────────────────────────────────────────────── */
.progress-bar  { height: 5px; background: var(--surface3); border-radius: 0; overflow: hidden; }
.progress-bar.thick { height: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 0; transition: width 0.4s ease; }
.progress-fill.green { background: var(--green); }
.progress-fill.orange { background: var(--orange); }
.progress-fill.red { background: var(--red); }
.progress-fill.blue { background: var(--blue); }
.progress-fill.wa { background: var(--wa); }
.progress-fill.fb { background: var(--fb); }

/* ── PIPELINE BOARD ──────────────────────────────────────── */
.pipeline-col { flex: 0 0 230px; display: flex; flex-direction: column; gap: 0; }
.pipeline-col-header { background: var(--surface); border-radius: 0; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-card); }
.pipeline-count { background: var(--surface3); color: var(--muted); border-radius: 0; font-size: 11px; padding: 1px 7px; font-family: 'DM Mono', monospace; font-weight: 600; }
.pipeline-cards { display: flex; flex-direction: column; gap: 8px; background: var(--surface2); border-radius: 0; padding: 10px; min-height: 120px; box-shadow: var(--shadow-card); }
.pipeline-card { display: block; background: var(--surface); border-radius: 0; padding: 12px 13px; text-decoration: none; color: var(--text); box-shadow: var(--shadow-card); transition: box-shadow 0.15s, transform 0.15s, background 0.12s; }
.pipeline-card:hover { background: var(--surface2); box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
.pipeline-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.pipeline-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.pipeline-card-biz  { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.pipeline-card-product { font-size: 11px; background: var(--surface3); padding: 2px 7px; border-radius: 0; display: inline-block; margin-bottom: 5px; color: var(--muted); }
.pipeline-card-value { font-size: 12px; font-family: 'DM Mono', monospace; color: var(--green); font-weight: 600; margin-bottom: 5px; }
.pipeline-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.form-control { width: 100%; padding: 9px 12px; background: var(--surface2); border: 1px solid var(--border2); border-radius: 0; color: var(--text); font-size: 13.5px; font-family: 'Inter', sans-serif; transition: border 0.15s, box-shadow 0.15s; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,92,231,0.12); }
.form-control::placeholder { color: var(--muted); opacity: 0.7; }
textarea.form-control { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 6px 0; }
.form-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.char-counter { font-size: 11px; color: var(--muted); text-align: right; margin-top: 4px; }

/* ── TAGS ────────────────────────────────────────────────── */
.proof-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 0; border: 1px solid; font-weight: 500; }
.proof-tag.yes { background: rgba(39,212,156,0.08); border-color: rgba(39,212,156,0.2); color: #1a7a5a; }
.proof-tag.no  { background: rgba(231,76,60,0.08);  border-color: rgba(231,76,60,0.2);  color: #c0392b; }
.gps-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 0; background: rgba(108,92,231,0.08); border: 1px solid rgba(108,92,231,0.2); color: #5b48c9; }
[data-theme="dark"] .proof-tag.yes { color: var(--green); }
[data-theme="dark"] .proof-tag.no  { color: var(--red); }
[data-theme="dark"] .gps-tag       { color: var(--accent); }

/* ── LEADERBOARD ─────────────────────────────────────────── */
.lb-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.lb-rank { width: 24px; height: 24px; border-radius: 0; background: var(--surface3); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.lb-rank.gold   { background: rgba(241,196,15,0.15); color: #9a7b00; border: 1px solid rgba(241,196,15,0.4); }
.lb-rank.silver { background: rgba(122,131,153,0.15); color: var(--muted); border: 1px solid rgba(122,131,153,0.4); }
.lb-rank.bronze { background: rgba(243,156,18,0.15); color: #b7770d; border: 1px solid rgba(243,156,18,0.3); }
.lb-avatar { width: 30px; height: 30px; border-radius: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub  { font-size: 11px; color: var(--muted); }
.checkin-dot { width: 8px; height: 8px; border-radius: 0; flex-shrink: 0; }
.checkin-dot.active   { background: var(--green); box-shadow: 0 0 0 2px rgba(39,212,156,0.2); }
.checkin-dot.inactive { background: var(--surface3); }
[data-theme="dark"] .lb-rank.gold { color: var(--yellow); }
[data-theme="dark"] .lb-rank.bronze { color: var(--orange); }

/* ── MARKETING SPECIFIC ─────────────────────────────────── */
.channel-icon { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 0; }
.channel-icon.wa { background: rgba(37,211,102,0.1); color: #1a8a42; border: 1px solid rgba(37,211,102,0.25); }
.channel-icon.fb { background: rgba(24,119,242,0.1); color: #0d4fa8; border: 1px solid rgba(24,119,242,0.25); }
.channel-icon.both { background: rgba(108,92,231,0.1); color: #5b48c9; border: 1px solid rgba(108,92,231,0.25); }
[data-theme="dark"] .channel-icon.wa   { color: var(--wa); }
[data-theme="dark"] .channel-icon.fb   { color: var(--fb); }
[data-theme="dark"] .channel-icon.both { color: var(--accent); }

.campaign-card { background: var(--surface); padding: 18px 20px; box-shadow: var(--shadow-card); transition: box-shadow 0.15s, background 0.12s, transform 0.15s; cursor: pointer; text-decoration: none; color: var(--text); display: block; }
.campaign-card:hover { background: var(--surface2); box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }

.post-card { background: var(--surface); overflow: hidden; box-shadow: var(--shadow-card); transition: box-shadow 0.15s, background 0.12s; }
.post-card:hover { background: var(--surface2); box-shadow: var(--shadow-card-hover); }
.post-card-body { padding: 16px 18px; }
.post-card-footer { padding: 10px 18px; border-top: 1px solid var(--border); background: var(--surface2); display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.wa-preview { background: #e8f8f0; border-radius: 0; padding: 14px 16px; font-size: 13.5px; line-height: 1.6; color: #1a1d2e; border: 1px solid rgba(37,211,102,0.2); max-width: 420px; position: relative; }
.wa-preview::before { content: ''; width: 12px; height: 12px; background: #e8f8f0; border-left: 1px solid rgba(37,211,102,0.2); border-bottom: 1px solid rgba(37,211,102,0.2); position: absolute; bottom: -1px; left: -8px; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
[data-theme="dark"] .wa-preview { background: rgba(37,211,102,0.08); color: var(--text); }

.fb-preview { background: var(--surface2); border-radius: 0; overflow: hidden; box-shadow: var(--shadow-card); }
.fb-preview-header { padding: 12px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.fb-avatar { width: 38px; height: 38px; border-radius: 0; background: var(--fb); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; }
.fb-preview-body { padding: 14px; font-size: 13.5px; line-height: 1.65; }
.fb-preview-actions { padding: 8px 14px; border-top: 1px solid var(--border); display: flex; gap: 20px; }
.fb-action { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 0; transition: background 0.15s; }
.fb-action:hover { background: var(--surface3); }

.contact-select-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 0; margin-bottom: 6px; cursor: pointer; transition: all 0.15s; background: var(--surface); box-shadow: var(--shadow-card); }
.contact-select-item:hover { background: rgba(37,211,102,0.04); }
.contact-select-item.selected { background: rgba(37,211,102,0.08); }
.contact-avatar-sm { width: 30px; height: 30px; border-radius: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.contact-quick-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.contact-quick-btn { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface2); transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.contact-quick-btn:hover { background: var(--wa); color: #fff; }

.msg-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 0; margin-bottom: 5px; font-size: 13px; background: var(--surface); box-shadow: var(--shadow-card); transition: background 0.15s, box-shadow 0.15s; }
.msg-row:hover { background: var(--surface2); }
.msg-status { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 0; }

/* ── TEMPLATE CHIPS ──────────────────────────────────────── */
.template-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 0; font-size: 12px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); cursor: pointer; transition: all 0.15s; }
.template-chip:hover { border-color: var(--accent); color: var(--accent); background: rgba(108,92,231,0.06); }
.var-chip { display: inline-block; background: rgba(108,92,231,0.1); color: #5b48c9; border: 1px solid rgba(108,92,231,0.2); border-radius: 0; padding: 1px 7px; font-size: 11.5px; cursor: pointer; font-family: 'DM Mono', monospace; margin: 2px; }
.var-chip:hover { background: rgba(108,92,231,0.18); }
[data-theme="dark"] .var-chip { color: var(--accent); }

/* ── ACTIVITY CHART ──────────────────────────────────────── */
.activity-bar { width: 8px; border-radius: 0; background: var(--accent); display: inline-block; margin: 0 1px; vertical-align: bottom; transition: height 0.3s ease; }

/* ── MARKETING STATS ROW ─────────────────────────────────── */
.mktg-stat { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mktg-stat:last-child { border-bottom: none; }
.mktg-stat-icon { width: 36px; height: 36px; border-radius: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.mktg-stat-icon.wa { background: rgba(37,211,102,0.1); }
.mktg-stat-icon.fb { background: rgba(24,119,242,0.1); }
.mktg-stat-icon.camp { background: rgba(108,92,231,0.1); }
.mktg-stat-info { flex: 1; }
.mktg-stat-label { font-size: 11.5px; color: var(--muted); }
.mktg-stat-value { font-size: 16px; font-weight: 700; font-family: 'DM Mono', monospace; }
.mktg-stat-bar { width: 80px; }

/* ── QUICK MESSAGE PANEL ─────────────────────────────────── */
.phone-mockup { width: 240px; background: #1e1e1e; border-radius: 0; padding: 16px 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.phone-screen { background: #fff; border-radius: 0; overflow: hidden; min-height: 320px; }
.phone-wa-header { background: var(--wa); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.phone-wa-body { padding: 14px; background: #ece5dd; min-height: 220px; }
.phone-wa-bubble { background: #dcf8c6; border-radius: 0; padding: 10px 12px; font-size: 12px; line-height: 1.5; max-width: 90%; margin-left: auto; box-shadow: 0 1px 3px rgba(0,0,0,0.1); word-break: break-word; }

/* ── MISC ────────────────────────────────────────────────── */
.stage-fields { border-radius: 0; padding: 14px; margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.3; }
.empty-state-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ── CALENDAR ────────────────────────────────────────────── */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav-btn { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 0; border: 1px solid var(--border2); background: var(--surface); color: var(--text); text-decoration: none; transition: all 0.15s; }
.cal-nav-btn:hover { background: var(--surface2); }
.cal-month-label { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; min-width: 168px; text-align: center; }
.cal-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-select { padding: 7px 12px; border-radius: 0; border: 1px solid var(--border2); background: var(--surface); color: var(--text); font-size: 12.5px; font-family: 'Inter', sans-serif; }
.cal-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-filter-chip { display: flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 0; border: 1px solid var(--border2); background: var(--surface); font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer; user-select: none; transition: all 0.15s; }
.cal-filter-chip .dot { width: 7px; height: 7px; border-radius: 0; flex-shrink: 0; }
.cal-filter-chip.off { opacity: 0.4; }
.cal-filter-chip:hover { background: var(--surface2); }

.cal-layout { display: grid; grid-template-columns: 1fr 260px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .cal-layout { grid-template-columns: 1fr; } }

.cal-grid { background: var(--surface); border-radius: 0; overflow: hidden; box-shadow: var(--shadow-card); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); background: var(--surface2); }
.cal-weekday { padding: 9px 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); text-align: center; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week + .cal-week { border-top: 1px solid var(--border); }
.cal-day-cell { min-height: 96px; padding: 6px 6px 8px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; transition: background 0.15s; }
.cal-day-cell:last-child { border-right: none; }
.cal-day-cell.other-month { background: var(--surface2); opacity: 0.55; }
.cal-day-cell.today { background: rgba(108,92,231,0.06); }
.cal-day-num { font-size: 11.5px; font-weight: 600; color: var(--muted); width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 0; }
.cal-day-cell.today .cal-day-num { background: var(--accent); color: #fff; }
.cal-event-chip { font-size: 10px; padding: 2px 6px; border-radius: 0; font-weight: 500; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.cal-event-chip.t-visit          { background: rgba(39,212,156,0.1);  color: #1a7a5a; }
.cal-event-chip.t-visit_followup { background: rgba(243,156,18,0.1);  color: #b7770d; }
.cal-event-chip.t-lead_followup  { background: rgba(232,67,147,0.1);  color: #b5005b; }
.cal-event-chip.t-campaign       { background: rgba(108,92,231,0.1);  color: #5b48c9; }
.cal-event-chip.t-post           { background: rgba(24,119,242,0.1); color: #0d4fa8; }
[data-theme="dark"] .cal-event-chip.t-visit          { color: var(--green); }
[data-theme="dark"] .cal-event-chip.t-visit_followup { color: var(--orange); }
[data-theme="dark"] .cal-event-chip.t-lead_followup  { color: var(--pink); }
[data-theme="dark"] .cal-event-chip.t-campaign       { color: var(--accent); }
[data-theme="dark"] .cal-event-chip.t-post           { color: var(--fb); }
.cal-more { font-size: 9.5px; color: var(--muted); padding-left: 3px; cursor: pointer; }

.cal-agenda-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.cal-agenda-item:last-child { border-bottom: none; }
.cal-agenda-date { flex-shrink: 0; width: 38px; text-align: center; }
.cal-agenda-date .d { font-size: 15px; font-weight: 700; font-family: 'DM Mono', monospace; }
.cal-agenda-date .m { font-size: 9px; text-transform: uppercase; color: var(--muted); }
.cal-agenda-title { font-size: 12.5px; font-weight: 500; }
.cal-agenda-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── PITCH HELPER ────────────────────────────────────────── */
.pitch-helper { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.pitch-helper summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--accent); list-style: none; display: flex; align-items: center; gap: 6px; }
.pitch-helper summary::before { content: '▸'; font-size: 10px; transition: transform 0.15s; }
.pitch-helper[open] summary::before { transform: rotate(90deg); }
.pitch-helper summary::-webkit-details-marker { display: none; }
.pitch-helper-block { margin-top: 10px; }
.pitch-helper-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.pitch-helper-block p { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.objection-qa { margin-bottom: 8px; padding: 8px 10px; background: var(--surface2); border-radius: 0; }
.objection-qa .q { font-size: 12px; font-style: italic; color: var(--muted); margin-bottom: 3px; }
.objection-qa .a { font-size: 12.5px; color: var(--text); }
.pitch-helper-live { background: var(--surface2); border-radius: 0; padding: 14px 16px; margin: -4px 0 18px; box-shadow: var(--shadow-card); }

.demo-guide-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.demo-guide-num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 0; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 4px; }
.demo-guide-remove { flex-shrink: 0; color: var(--muted); margin-top: 4px; }
.demo-guide-step { padding: 12px 14px; border-radius: 0; background: var(--surface2); margin-bottom: 8px; display: flex; gap: 12px; align-items: flex-start; }
.demo-guide-step .num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 0; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.demo-guide-step .step-title { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.demo-guide-step .step-detail { font-size: 12px; color: var(--muted); }

/* ── LIVE CAMERA CAPTURE ─────────────────────────────────── */
.camera-capture-field { margin-bottom: 4px; }
.cam-stage { display: flex; }
.cam-live { background: #000; border-radius: 0; overflow: hidden; }
.cam-video { width: 100%; max-height: 340px; object-fit: cover; display: block; background: #000; }
.cam-live-controls { display: flex; gap: 8px; padding: 10px; background: var(--surface2); }
.cam-preview { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cam-img { max-width: 100%; max-height: 240px; border-radius: 0; box-shadow: var(--shadow-card); }

/* ── ROUTE PLANNER ───────────────────────────────────────── */
.geofence-banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 0; margin-bottom: 16px; font-size: 13px; font-weight: 500; border: 1px solid; }
.geofence-banner.in     { background: rgba(39,212,156,0.08);  border-color: rgba(39,212,156,0.3);  color: #1a7a5a; }
.geofence-banner.out    { background: rgba(243,156,18,0.08);  border-color: rgba(243,156,18,0.3);  color: #b7770d; }
.geofence-banner.none   { background: var(--surface2); border-color: var(--border); color: var(--muted); }
[data-theme="dark"] .geofence-banner.in  { color: var(--green); }
[data-theme="dark"] .geofence-banner.out { color: var(--orange); }

.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-bar input[type="text"] { flex: 1; min-width: 200px; }
.category-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.category-chip { padding: 6px 12px; border-radius: 0; border: 1px solid var(--border2); background: var(--surface); font-size: 12px; color: var(--muted); cursor: pointer; transition: all 0.12s; }
.category-chip:hover { background: var(--surface2); color: var(--text); }
.category-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.route-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .route-layout { grid-template-columns: 1fr; } }

/* ── Mobile navigation: the sidebar is fixed-width and was never made to
   collapse, so on a narrow viewport it permanently squeezed every page's
   content into an unusably thin column. Below 860px it now slides off-canvas
   behind a hamburger toggle instead. ── */
.sidebar-toggle-btn { display: none; background: none; border: none; padding: 6px; margin-right: 4px; color: var(--text); cursor: pointer; border-radius: 0; }
.sidebar-toggle-btn:hover { background: var(--surface2); }
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  body { display: block; }
  .sidebar-toggle-btn { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; z-index: 1000;
    transform: translateX(-100%); transition: transform 0.22s ease;
    box-shadow: 4px 0 18px rgba(0,0,0,0.25);
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 999;
    opacity: 0; pointer-events: none; transition: opacity 0.22s ease;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  body.sidebar-open { overflow: hidden; } /* stop background scroll while the drawer is open */
  .main-content { width: 100%; min-height: 100vh; }
  .topbar { padding: 12px 16px; }
  .page-body { padding: 16px; }
  .stat-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Route planner: fixed pixel heights and non-shrinking inputs were the
   specific things breaking this page on phones even once the sidebar issue
   above is fixed. ── */
@media (max-width: 640px) {
  #plannerMap { height: 320px !important; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar input[type="text"] { min-width: 0; width: 100%; }
  .search-bar #radiusSelect { max-width: none !important; width: 100%; }
  .search-bar .btn { width: 100%; }
  .route-layout .card[style*="max-height"] { max-height: 420px !important; }
  #routePlanBar { flex-direction: column; align-items: stretch !important; }
  #routePlanBar > div { justify-content: stretch; }
  #routePlanBar .btn { flex: 1; }
  .page-header-actions { width: 100%; }
  .page-header-actions .cal-select { flex: 1; }
}

/* iOS Safari (including installed PWAs) auto-zooms the whole page when a
   focused input's font-size is under 16px — jarring and easy to miss on
   desktop since it's iOS-only. Bump to 16px on small screens; desktop keeps
   the more compact 13.5px. */
@media (max-width: 640px) {
  .form-control, select, textarea, input[type="text"], input[type="search"],
  input[type="email"], input[type="tel"], input[type="number"], input[type="password"] {
    font-size: 16px !important;
  }
}

.result-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.result-item:last-child { border-bottom: none; }
.result-item.clickable { cursor: pointer; border-radius: 0; margin: 0 -8px; padding: 11px 8px; transition: background 0.12s; }
.result-item.clickable:hover { background: var(--surface2); }
.result-item.selected { background: rgba(108,92,231,0.08); }
.result-marker { flex-shrink: 0; width: 26px; height: 26px; border-radius: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; margin-top: 1px; }
.result-info { flex: 1; min-width: 0; }

.spinner-inline { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(122,131,153,0.3); border-top-color: var(--accent); border-radius: 0; animation: mc-spin 0.7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes mc-spin { to { transform: rotate(360deg); } }
.search-provider-note { font-size: 11px; color: var(--muted); margin: -6px 0 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search-provider-note .stale-flag { color: #b7770d; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

.travel-mode-group { display: inline-flex; border: 1px solid var(--border2); border-radius: 0; overflow: hidden; }
.travel-mode-btn { background: var(--surface); border: none; padding: 6px 12px; font-size: 12px; color: var(--muted); cursor: pointer; border-right: 1px solid var(--border2); transition: all 0.12s; }
.travel-mode-btn:last-child { border-right: none; }
.travel-mode-btn:hover { background: var(--surface2); color: var(--text); }
.travel-mode-btn.active { background: var(--accent); color: #fff; }

.route-leg { border-bottom: 1px solid var(--border); padding: 10px 0; }
.route-leg:last-child { border-bottom: none; }
.route-leg-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 8px; }
.route-leg-header:hover .route-leg-title { text-decoration: underline; }
.route-leg-title { font-weight: 600; font-size: 12.5px; }
.route-leg-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.route-steps { list-style: none; margin: 8px 0 0; padding: 0; display: none; }
.route-leg.expanded .route-steps { display: block; }
.route-leg-header .chevron { transition: transform 0.15s; color: var(--muted); flex-shrink: 0; }
.route-leg.expanded .chevron { transform: rotate(90deg); }
.route-step { display: flex; gap: 8px; padding: 5px 0; font-size: 12px; align-items: flex-start; }
.route-step-icon { flex-shrink: 0; width: 20px; height: 20px; border-radius: 0; background: var(--surface3); display: flex; align-items: center; justify-content: center; font-size: 11px; margin-top: 1px; }
.route-step-text { flex: 1; }
.route-step-dist { color: var(--muted); font-size: 10.5px; }
.route-summary { background: var(--surface2); border-radius: 0; padding: 10px 12px; margin-bottom: 12px; font-size: 12.5px; box-shadow: var(--shadow-card); }
.route-summary-warning { color: #b7770d; font-size: 11px; margin-top: 4px; }
.result-name { font-size: 13px; font-weight: 600; }
.result-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.result-dist { font-size: 11px; color: var(--accent); font-weight: 600; flex-shrink: 0; }

.route-stat { text-align: center; padding: 12px; background: var(--surface2); border-radius: 0; }
.route-stat .val { font-size: 20px; font-weight: 700; font-family: 'DM Mono', monospace; }
.route-stat .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }

/* ── CALL ROOM ────────────────────────────────────────────── */
.call-wrap { position: fixed; inset: 0; background: #14151c; display: flex; flex-direction: column; }
.call-header { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; color: #fff; }
.call-brand { font-size: 14px; font-weight: 700; opacity: 0.9; }
.call-status { font-size: 12.5px; color: rgba(255,255,255,0.6); }
.call-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.call-remote-video, .call-local-video { width: 100%; height: 100%; object-fit: cover; background: #1c1d26; }
.call-local-video { position: absolute; bottom: 96px; right: 20px; width: 130px; height: 174px; border-radius: 0; border: 2px solid rgba(255,255,255,0.15); box-shadow: 0 4px 16px rgba(0,0,0,0.4); z-index: 3; }
.call-avatar-tile { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; }
.call-avatar-circle { width: 96px; height: 96px; border-radius: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; }
.call-avatar-circle.small { width: 56px; height: 56px; font-size: 20px; position: absolute; bottom: 96px; right: 20px; z-index: 3; border: 2px solid rgba(255,255,255,0.15); }
.call-name { font-size: 15px; font-weight: 600; }
.call-controls { padding: 20px; display: flex; align-items: center; justify-content: center; gap: 16px; }
.call-btn { width: 52px; height: 52px; border-radius: 0; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; background: rgba(255,255,255,0.12); color: #fff; transition: background 0.15s; }
.call-btn:hover { background: rgba(255,255,255,0.2); }
.call-btn-off { background: #fff !important; color: #14151c !important; }
.call-btn-end { background: #e74c3c; }
.call-btn-end:hover { background: #c0392b; }

/* Map filter for dark */
[data-theme="dark"] .leaflet-tile-pane { filter: var(--map-filter); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 0; }
