/* Shared CRM theme, matched to the approved Leads Analysis page.
   Scope keeps the analytical data and application behavior unchanged.
   Higher specificity is intentional: older modules load their styles lazily. */
:root[data-crm-theme="lead-analysis"] {
  color-scheme: light;
  --bg:#f7f9f7; --card:#fff; --text:#18312d; --muted:#596c65;
  --accent:#0e5148; --accent-soft:#e6f0e8; --border:#d9e3dc; --hero:#0e5148;
  --green:#286634; --green-bg:#dfeddf; --red:#923b14; --red-bg:#ffe5d5;
  --blue:#446057; --blue-bg:#edf2ed; --orange:#765512; --orange-bg:#f8edc6;
  --purple:#5b5481; --purple-bg:#efedf5;
  --hq-bg:var(--bg); --hq-surface:var(--card); --hq-soft:#eff4ef;
  --hq-line:var(--border); --hq-text:var(--text); --hq-muted:var(--muted);
  --hq-olive:var(--accent); --hq-olive-dark:#143c35; --hq-lime:#559782;
  --hq-lime-soft:#e6f0e8; --hq-gold:#a4782b; --hq-gold-soft:#f1ebdc;
  --hq-red:var(--red); --hq-red-soft:var(--red-bg);
  --hq-orange:var(--orange); --hq-orange-soft:var(--orange-bg);
  --hq-blue:#446057; --hq-blue-soft:#edf2ed;
  --hq-green:var(--green); --hq-green-soft:var(--green-bg);
  --hq-shadow:none; --hq-radius:10px;
  --rm-line:var(--border); --rm-ink:var(--text); --rm-muted:var(--muted);
  --rm-olive:var(--accent); --rm-gold:var(--accent); --rm-green:var(--green);
  --rm-orange:var(--orange); --rm-red:var(--red); --rm-blue:#446057;
  --crm-font:'Avenir Next','Segoe UI',sans-serif;
}
:root[data-crm-theme] body {
  background:var(--bg)!important; color:var(--text)!important;
  font:15px/1.55 var(--crm-font)!important;
}
:root[data-crm-theme] :is(button,input,select,textarea) {font-family:var(--crm-font)!important}
:root[data-crm-theme] :is(a,button,input,select,textarea,summary):focus-visible {
  outline:3px solid var(--hq-gold)!important; outline-offset:3px;
}
:root[data-crm-theme] :is(button,a) {touch-action:manipulation}
:root[data-crm-theme] button:disabled {opacity:.45;cursor:default}
:root[data-crm-theme] a {color:var(--accent);text-underline-offset:4px}
:root[data-crm-theme] #appPage>header {
  background:var(--accent)!important;color:#fff;border:0!important;
  box-shadow:none!important;padding:22px 0 0;position:relative;
}
:root[data-crm-theme] .head-row {max-width:1264px!important;padding:0 22px 22px;gap:16px}
:root[data-crm-theme] .logo {color:#fff!important;font:650 20px/1.3 var(--crm-font);letter-spacing:0!important}
:root[data-crm-theme] .logo span {color:inherit!important;font:inherit!important;letter-spacing:inherit!important}
:root[data-crm-theme] .logo .crm-label {font-size:13px!important;opacity:.8}
:root[data-crm-theme] .user-chip {
  background:transparent!important;border-color:#ffffff66!important;
  color:#fff;box-shadow:none!important;padding:6px 11px;
}
:root[data-crm-theme] .user-chip :is(b,span,button) {color:#fff!important}
:root[data-crm-theme] .user-chip button {min-height:32px;padding:2px 4px}
/* Wrap all destinations: the last menu must never disappear beyond the edge. */
:root[data-crm-theme] #nav {
  max-width:none!important;margin:0;display:flex;flex-wrap:wrap;gap:8px!important;
  padding:16px max(22px,calc((100vw - 1220px)/2));overflow:visible;
  background:var(--bg);border-bottom:1px solid var(--border);
}
:root[data-crm-theme] #nav button {
  background:#fff!important;border:1px solid var(--border)!important;
  border-radius:22px!important;color:var(--muted)!important;
  padding:9px 14px!important;min-height:43px;font-size:13px;font-weight:600;
}
:root[data-crm-theme] #nav button:is(.active,:hover) {
  background:var(--accent)!important;color:#fff!important;border-color:var(--accent)!important;
}
:root[data-crm-theme] main {max-width:1264px!important;padding:30px 22px 60px!important}
:root[data-crm-theme] :is(.hq-v2-head h1,.hq-mgmt-title h2,.rm-head h2) {
  color:var(--text);font-weight:650;letter-spacing:-.8px;line-height:1.18;
}
:root[data-crm-theme] .hq-v2-head h1 {font-size:clamp(29px,3.2vw,39px)}
:root[data-crm-theme] :is(.hq-mgmt-title h2,.rm-head h2) {font-size:27px}
:root[data-crm-theme] .section-title {
  color:var(--text)!important;font-size:17px!important;letter-spacing:0!important;
  text-transform:none;font-weight:650!important;margin:24px 0 13px;
}
:root[data-crm-theme] :is(.card,.stat,.lead,.col,.conv-list,.chat-pane,.chat-main,.modal,.login-card,
  .hq-kpi,.hq-panel,.hq-perf,.hq-mgmt-card,.hq-mgmt-kpi,.rm-kpi,.rm-filter-card,.rm-list-card) {
  background:var(--card)!important;border-color:var(--border)!important;
  border-radius:10px!important;box-shadow:none!important;
}
:root[data-crm-theme] :is(.card,.hq-panel,.hq-mgmt-card) {padding:20px}
:root[data-crm-theme] :is(.stat .num,.hq-kpi-value,.hq-mgmt-kpi-value,.hq-perf-value) {
  color:var(--text)!important;font-weight:650;letter-spacing:-.5px;
}
:root[data-crm-theme] :is(.hq-kpi-title,.hq-mgmt-kpi-label) {color:var(--muted);font-size:12px}
:root[data-crm-theme] :is(.hq-kpi-sub,.hq-mgmt-kpi-target,.hq-mgmt-kpi-foot,.hq-perf-sub) {font-size:11px}
:root[data-crm-theme] :is(.hq-mgmt-card-head h3,.hq-panel h3) {font-size:17px;font-weight:650}
:root[data-crm-theme] :is(.hq-mgmt-card-head p,.hq-mgmt-insight p,.hq-mgmt-action small,.hq-mgmt-basis p) {font-size:12px;line-height:1.55}
:root[data-crm-theme] :is(.hq-mgmt-insight b,.hq-mgmt-action b,.hq-mgmt-basis summary) {font-size:13px}
:root[data-crm-theme] .btn {background:var(--accent)!important;color:#fff!important;border-radius:6px!important;min-height:42px}
:root[data-crm-theme] .btn.ghost {background:#fff!important;border:1px solid #acbeb3!important;color:var(--accent)!important}
:root[data-crm-theme] .btn.small {min-height:34px;border-radius:6px!important}
:root[data-crm-theme] .btn[style*="var(--red)"] {background:var(--red)!important}
:root[data-crm-theme] :is(input:not([type=checkbox]):not([type=radio]):not([type=color]),select,textarea) {
  color:var(--text)!important;background:#fff!important;border-color:#acbeb3!important;
  border-radius:6px!important;min-height:42px;
}
:root[data-crm-theme] :is(input[type=checkbox],input[type=radio]) {accent-color:var(--accent)}
:root[data-crm-theme] :is(.brandbar button,.hq-chbtn,.rm-chip,.hq-team-chip) {min-height:38px;color:var(--muted);border-color:var(--border)}
:root[data-crm-theme] :is(.brandbar button.active,.hq-chbtn.active,.rm-chip.active,.hq-team-chip.on) {
  background:var(--accent)!important;border-color:var(--accent)!important;color:#fff!important;
}
:root[data-crm-theme] .badge {border-radius:4px;font-weight:600!important;padding:3px 7px}
:root[data-crm-theme] .b-warm {background:var(--orange-bg)!important;color:var(--orange)!important}
:root[data-crm-theme] .b-cold {background:var(--blue-bg)!important;color:var(--blue)!important}
:root[data-crm-theme] :is(.b-cancel,.b-fake) {background:#ececec;color:#666}
:root[data-crm-theme] :is(.filters,.hq-dashboard-filters,.hq-cs-period-filters) {gap:10px}
:root[data-crm-theme] :is(.hq-dashboard-filters,.hq-cs-period-filters) {
  background:#edf3ee;padding:16px;border-radius:9px;justify-content:flex-start!important;
}
:root[data-crm-theme] :is(.hq-mgmt-funnel-step,.hq-mgmt-funnel-step.blue,.hq-mgmt-funnel-step.orange) {
  background:#f7f9f7;border:1px solid var(--border);border-radius:8px;
}
:root[data-crm-theme] .hq-mgmt-track i {background:var(--accent)}
:root[data-crm-theme] :is(.bar-track,.hq-mgmt-track,.hq-mgmt-brand>div) {background:#e6eee7!important}
:root[data-crm-theme] :is(.hq-mgmt-kpi-foot,.hq-priority-row,.hq-schedule-row,.hq-mgmt-basis) {border-color:var(--border)}
:root[data-crm-theme] .hq-mgmt-action:hover {border-color:#559782;background:#eff4ef}
:root[data-crm-theme] :is(table.rpt,.hq-mgmt-table) {font-size:13px!important}
:root[data-crm-theme] :is(table.rpt,.hq-mgmt-table,.rm-table) :is(th,td) {padding:13px 15px;border-bottom-color:var(--border)!important}
:root[data-crm-theme] :is(table.rpt,.hq-mgmt-table,.rm-table) th {
  background:#eff4ef!important;color:#446057!important;font-size:12px;
  text-transform:none;letter-spacing:0;font-weight:650;
}
:root[data-crm-theme] .note {background:#f1ebdc;border:0;border-left:4px solid var(--hq-gold);color:#685127;border-radius:0 7px 7px 0}
:root[data-crm-theme] .overlay {background:#123c3577;z-index:50}
:root[data-crm-theme] .modal {padding:24px}
:root[data-crm-theme] #ovTambah .lead-create-modal {border-radius:0!important}
:root[data-crm-theme] :is(.msgs,.col,.conv-search,.hq-team-card) {background:var(--bg)!important}
:root[data-crm-theme] .msg.out {background:#e6f0e8;border-color:#cedfcf}
:root[data-crm-theme] .conv-item.active {background:#e6f0e8;border-color:var(--accent)}
:root[data-crm-theme] #tab-monitoring {
  --rm-line:var(--border);--rm-ink:var(--text);--rm-muted:var(--muted);
  --rm-olive:var(--accent);--rm-gold:var(--accent);--rm-green:var(--green);
  --rm-orange:var(--orange);--rm-red:var(--red);--rm-blue:#446057;
}
:root[data-crm-theme] :is(.rm-field label,.rm-section-label,.rm-fact label) {text-transform:none;letter-spacing:0;font-size:12px;color:var(--muted)}
:root[data-crm-theme] :is(.rm-person b,.rm-next b,.rm-step b) {font-size:13px}
:root[data-crm-theme] :is(.rm-meta,.rm-owner,.rm-stage small,.rm-step p) {font-size:11px}
:root[data-crm-theme] :is(.rm-avatar,.rm-kpi-icon) {background:#e6f0e8;color:var(--accent)}
:root[data-crm-theme] .rm-fact {background:var(--bg);border-color:var(--border);border-radius:8px}
:root[data-crm-theme] .rm-table tbody tr:hover {background:#eff4ef}
:root[data-crm-theme] #hqAhOv {font-family:var(--crm-font);color:var(--text)}
:root[data-crm-theme] #hqAhMd {border-radius:12px}
:root[data-crm-theme] #hqAhMd .btn {background:#fff!important;color:var(--text)!important;border-color:var(--border)}
:root[data-crm-theme] #hqAhMd .btn.pri {background:var(--accent)!important;color:#fff!important}
:root[data-crm-theme] :is(#hqAhMd .flow span,#hqAhMd .notice) {background:#eff4ef;border-color:var(--border);color:var(--text)}
:root[data-crm-theme] :is(.hqAhBadge,#closeProfileBox) {font-family:var(--crm-font)}
:root[data-crm-theme] #loginPage {background:var(--bg)}
:root[data-crm-theme] .login-card {border-top:5px solid var(--accent);padding:30px}
:root[data-crm-theme] .login-wordmark {font:650 34px/1.2 var(--crm-font);color:var(--accent);letter-spacing:-.7px}
:root[data-crm-theme] .login-group {color:var(--muted);font-size:16px;margin-bottom:10px}
:root[data-crm-theme] #loginPage .logo {color:var(--accent)!important}
:root[data-crm-theme] .crm-footer {border-color:var(--border);color:var(--muted)}
:root[data-crm-theme] :is(.avatar,.conv.active) {background:#e6f0e8;color:var(--accent)}
:root[data-crm-theme] :is(#qrPanel,#emojiPanel,#aiTestMsgs,#aiHasil,#kwPreview) {background:var(--bg)!important;border-color:var(--border)!important}
:root[data-crm-theme] #adminSubnav {flex-wrap:wrap!important;overflow:visible!important;gap:8px!important}
:root[data-crm-theme] #adminSubnav button {min-height:40px;border-radius:6px!important}
:root[data-crm-theme] #adminSubnav button[style*="accent"] {color:var(--accent)!important;background:var(--accent-soft)!important}
:root[data-crm-theme] :is(.hq-num,.hq-dot) {background:var(--accent)!important}
:root[data-crm-theme] .hq-mgmt-chip.neutral {background:#edf2ed;color:var(--muted)}
:root[data-crm-theme] :is(#crmArchiveModal,#crmWorkflowModal,#crmMediaStatusDialog) {color:var(--text);font-family:var(--crm-font)}
:root[data-crm-theme] .policy-page main {max-width:850px!important;padding-top:48px!important}
:root[data-crm-theme] .policy-page h1 {font:650 clamp(29px,4vw,43px)/1.18 var(--crm-font);letter-spacing:-1.2px}
:root[data-crm-theme] .policy-page .brand {color:var(--accent);letter-spacing:0;font-size:19px;font-weight:650}
:root[data-crm-theme] .policy-page footer {border-color:var(--border);color:var(--muted)}
:root[data-crm-theme] .public-chat main {max-width:580px!important;background:var(--bg)}
:root[data-crm-theme] .public-chat header {background:var(--accent);color:#fff;padding:22px;border:0;border-radius:10px}
:root[data-crm-theme] .public-chat header :is(.brand,p) {color:#fff;font-family:var(--crm-font);letter-spacing:0}
:root[data-crm-theme] .public-chat .brand {font-size:19px;font-weight:650}
:root[data-crm-theme] .public-chat p {color:var(--muted)}
:root[data-crm-theme] .public-chat button {background:var(--accent);border-radius:6px;min-height:42px}
:root[data-crm-theme] .public-chat .quiet {background:transparent;color:var(--muted)}
:root[data-crm-theme] .public-chat .message {background:#fff;border:1px solid var(--border);border-radius:10px}
:root[data-crm-theme] .public-chat .message.mine {background:#e6f0e8;border-color:#cedfcf}
:root[data-crm-theme] .public-chat .message a {color:var(--accent)}
:root[data-crm-theme] .public-chat :is(footer,.message small) {color:var(--muted)}
@media(max-width:760px) {
  :root[data-crm-theme] .head-row {padding:0 16px 17px}
  :root[data-crm-theme] #nav {padding:12px 15px;gap:6px!important}
  :root[data-crm-theme] #nav button {padding:8px 11px!important;font-size:12px;min-height:42px}
  :root[data-crm-theme] main {padding:24px 15px 50px!important}
  :root[data-crm-theme] :is(.hq-mgmt-kpis,.hq-kpi-strip,#dcsStats,#tab-dashboard>.stats) {
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;overflow:visible!important;
  }
  :root[data-crm-theme] :is(.hq-mgmt-kpi,.hq-kpi,#dcsStats>div,#tab-dashboard>.stats>.stat) {min-width:0!important;padding:13px!important}
  :root[data-crm-theme] .hq-mgmt-kpi-top {align-items:flex-start;flex-direction:column;gap:8px}
  :root[data-crm-theme] .hq-mgmt-kpi-foot {flex-wrap:wrap;gap:4px}
  :root[data-crm-theme] :is(.hq-v2-head h1,.hq-mgmt-title h2) {font-size:28px}
  :root[data-crm-theme] .hq-grid-main {grid-template-columns:1fr}
  :root[data-crm-theme] .hq-grid-main>.hq-panel:last-child {grid-column:auto}
}
@media(prefers-reduced-motion:reduce) {
  :root[data-crm-theme] *, :root[data-crm-theme] *::before, :root[data-crm-theme] *::after {
    scroll-behavior:auto!important;animation:none!important;transition:none!important;
  }
}

/* SocialChat coverage is separate from the filtered CRM funnel. */
html[data-crm-theme="lead-analysis"] .hq-source-summary{margin:0 0 24px;padding:20px 22px;background:var(--surface,#fff);border:1px solid #d9e3dc;border-left:4px solid #0e5148;border-radius:10px;color:#18312d}
html[data-crm-theme="lead-analysis"] .hq-source-summary[hidden]{display:none}
html[data-crm-theme="lead-analysis"] .hq-source-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap}
html[data-crm-theme="lead-analysis"] .hq-source-summary h3{margin:0;font-size:21px;line-height:1.3}
html[data-crm-theme="lead-analysis"] .hq-source-summary p,html[data-crm-theme="lead-analysis"] .hq-source-head>span{font-size:13px;line-height:1.6;color:#596c65;margin:8px 0}
html[data-crm-theme="lead-analysis"] .hq-source-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:16px 0}
html[data-crm-theme="lead-analysis"] .hq-source-summary a{color:#0e5148;text-decoration:underline;text-underline-offset:3px}
html[data-crm-theme="lead-analysis"] .hq-source-metric{display:flex;flex-direction:column;gap:4px;padding:12px;background:#f7f9f7;border-radius:6px;text-decoration:none!important}
html[data-crm-theme="lead-analysis"] .hq-source-metric strong{font-size:30px;line-height:1.15}
html[data-crm-theme="lead-analysis"] .hq-source-metric span{font-size:13px}
html[data-crm-theme="lead-analysis"] .hq-source-summary a:focus-visible{outline:3px solid #a4782b;outline-offset:3px}
@media(max-width:600px){html[data-crm-theme="lead-analysis"] .hq-source-metrics{grid-template-columns:1fr}html[data-crm-theme="lead-analysis"] .hq-source-metric{flex-direction:row;align-items:center;gap:16px}html[data-crm-theme="lead-analysis"] .hq-source-summary{padding:16px}}
/* Clickable dashboard source cards and scoped results. */
:root[data-crm-theme="lead-analysis"] .hq-drill-card {font:inherit;color:inherit;text-align:left;cursor:pointer;width:100%;box-sizing:border-box;letter-spacing:normal;text-transform:none;}
:root[data-crm-theme="lead-analysis"] button.hq-mgmt-funnel-step,
:root[data-crm-theme="lead-analysis"] button.hq-mgmt-bar-row,
:root[data-crm-theme="lead-analysis"] button.hq-mgmt-brand,
:root[data-crm-theme="lead-analysis"] button.hq-mgmt-insight,
:root[data-crm-theme="lead-analysis"] button.hq-pipeline-row {background:transparent;border:1px solid transparent;border-radius:8px;}
:root[data-crm-theme="lead-analysis"] .hq-drill-card:hover {border-color:#a4782b;background:#f4f7f1;}
:root[data-crm-theme="lead-analysis"] .hq-drill-card:focus-visible {outline:3px solid #a4782b;outline-offset:3px;}
.hq-number-link{font:inherit;color:#0e5148;background:transparent;border:0;text-decoration:underline;text-underline-offset:4px;cursor:pointer;padding:8px;}
.hq-detail-dialog{background:#f7f9f7;color:#18312d;border:1px solid #d9e3dc;border-radius:16px;max-width:900px;width:calc(100% - 40px);max-height:85vh;padding:24px;box-sizing:border-box;}
.hq-detail-dialog::backdrop{background:rgba(17,49,44,.55);}
.hq-detail-dialog header{display:flex;justify-content:space-between;align-items:start;gap:20px;border-bottom:1px solid #d9e3dc;padding-bottom:12px;}
.hq-detail-dialog h2{margin:0;font-size:24px;}.hq-detail-dialog header p{font-size:14px;color:#596c65;line-height:1.5;}
.hq-detail-dialog .hq-detail-row{display:flex;align-items:center;gap:12px;justify-content:space-between;padding:16px;width:100%;margin:8px 0;border:1px solid #d9e3dc;border-radius:8px;background:white;color:#18312d;text-align:left;font:inherit;cursor:pointer;}
.hq-detail-row small{display:block;color:#596c65;margin-top:6px;}.hq-detail-dialog footer{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:16px;}
