/* ─── DealerDMS — Customer Engagement Analytics ──────────────────────────────
   Theme-token driven (reads ONLY app.css tokens) so every theme — including
   midnight/dark — works without per-theme overrides. Class prefix: .eng-      */

/* header + date range */
.eng-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px;flex-wrap:wrap}
.eng-head .page-title{margin-bottom:6px}
.eng-head .page-sub{margin-bottom:0;max-width:560px}
.eng-range{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.eng-range select,.eng-range input[type=date]{background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:8px;padding:7px 10px;font:inherit;font-size:13px}
.eng-range-sep{color:var(--text-muted)}

/* tabs: the shared underline module-tab component lives in app.css (I13). */

/* KPI cards */
.eng-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px;margin-bottom:16px}
.eng-kpi{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;box-shadow:var(--shadow)}
.eng-kpi-ico{font-size:20px;width:38px;height:38px;display:flex;align-items:center;justify-content:center;background:var(--surface-2);border-radius:10px;flex:none}
.eng-kpi-val{font-size:20px;font-weight:700;color:var(--text);line-height:1.15}
.eng-kpi-label{font-size:12px;color:var(--text-muted);margin-top:2px}

/* cards */
.eng-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 18px;box-shadow:var(--shadow);margin-bottom:16px;min-width:0}
.eng-card-h{display:flex;align-items:center;justify-content:space-between;gap:10px;font-weight:700;font-size:14px;color:var(--text);margin-bottom:12px;flex-wrap:wrap}
.eng-card-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.eng-grid-2{display:grid;grid-template-columns:repeat(auto-fit,minmax(340px,1fr));gap:16px}
.eng-grid-2 .eng-card{margin-bottom:0}
.eng-hint-chip{font-size:10.5px;font-weight:600;color:var(--accent);background:var(--accent-soft,rgba(224,138,30,.12));border-radius:999px;padding:2px 8px;vertical-align:middle;margin-left:6px}

/* charts + legends */
.eng-chart{width:100%;overflow-x:auto}
.eng-chart svg{display:block;max-width:100%}
.eng-legend{display:flex;gap:14px;font-size:12px;font-weight:500;color:var(--text-muted)}
.eng-legend-item{display:flex;align-items:center;gap:5px}
.eng-legend-item i{width:10px;height:10px;border-radius:3px;display:inline-block}
.eng-pie{display:flex;gap:20px;align-items:center;flex-wrap:wrap}
.eng-legend-col{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--text)}
.eng-legend-row{display:flex;align-items:center;gap:7px}
.eng-legend-row span{width:11px;height:11px;border-radius:3px;display:inline-block;flex:none}
.eng-legend-row b{margin-left:2px}

/* tables */
.eng-tablewrap{overflow-x:auto;border:1px solid var(--border);border-radius:8px}
.eng-table{width:100%;border-collapse:collapse;font-size:13px}
.eng-table th{background:var(--surface-3);color:var(--text-muted);text-align:left;font-weight:600;font-size:12px;padding:8px 12px;border-bottom:1px solid var(--border);white-space:nowrap}
.eng-table td{padding:9px 12px;border-bottom:1px solid var(--border);color:var(--text);vertical-align:middle}
.eng-table tbody tr:last-child td{border-bottom:none}
.eng-table-click tbody tr{cursor:pointer}
.eng-table-click tbody tr:hover{background:var(--surface-hover)}
.eng-cell-sum{max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.eng-chip{display:inline-block;font-size:11.5px;font-weight:600;color:var(--text-muted);background:var(--surface-2);border-radius:999px;padding:3px 9px}

/* pager + toggles */
.eng-pager{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:12px;font-size:12.5px}
.eng-pager span:last-child{display:flex;gap:6px}
.eng-toggle{display:inline-flex;background:var(--surface-2);border-radius:8px;padding:3px;gap:2px}
.eng-tab-mini{appearance:none;border:none;background:none;color:var(--text-muted);font:inherit;font-size:12.5px;font-weight:600;padding:5px 12px;border-radius:6px;cursor:pointer}
.eng-tab-mini.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow)}

/* AI analysis panel */
.eng-ai-panel{border-left:3px solid var(--primary)}
.eng-ai-out{font-size:13.5px;line-height:1.6;color:var(--text)}
.eng-ai-text h4{margin:14px 0 6px;font-size:13.5px;color:var(--primary)}
.eng-ai-text h4:first-child{margin-top:0}
.eng-ai-text p{margin:0 0 8px}
.eng-ai-text ul{margin:0 0 10px;padding-left:20px}
.eng-ai-text li{margin:3px 0}
.eng-ai-meta{margin-top:10px;font-size:11.5px;color:var(--text-muted);border-top:1px dashed var(--border);padding-top:8px}

/* states */
.eng-loading{display:flex;align-items:center;gap:10px;color:var(--text-muted);padding:26px 6px;font-size:13.5px}
.eng-empty{text-align:center;padding:34px 16px;color:var(--text-muted)}
.eng-empty-ico{font-size:30px;margin-bottom:8px}
.eng-empty-title{font-weight:700;color:var(--text);font-size:14.5px;margin-bottom:4px}
.eng-empty-hint{font-size:13px;max-width:420px;margin:0 auto}
.eng-muted{color:var(--text-muted)}
.eng-foot-note{font-size:12px;margin:2px 2px 0}

/* transcript view */
.eng-convo-head{display:flex;align-items:center;gap:14px;margin-bottom:14px;flex-wrap:wrap}
.eng-convo-title{display:flex;flex-direction:column;gap:2px;font-size:15px;flex:1;min-width:220px}
.eng-convo-title .eng-muted{font-size:12.5px}
.eng-convo-actions{display:flex;gap:8px;flex-wrap:wrap}
.eng-convo-grid{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:16px;align-items:start}
.eng-convo-side{display:flex;flex-direction:column;gap:0}
.eng-chat{display:flex;flex-direction:column;gap:10px;max-height:62vh;overflow-y:auto;padding:2px}
.eng-msg{max-width:82%;padding:9px 13px;border-radius:12px;font-size:13.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word}
.eng-msg-user{align-self:flex-end;background:var(--primary);color:var(--on-primary,#fff);border-bottom-right-radius:4px}
.eng-msg-assistant{align-self:flex-start;background:var(--surface-2);color:var(--text);border-bottom-left-radius:4px}
.eng-msg-tool{align-self:center;background:none;color:var(--text-muted);font-size:11.5px;padding:2px 8px}
.eng-summary{font-size:13px;line-height:1.55;color:var(--text);white-space:pre-wrap}
.eng-spec{display:flex;justify-content:space-between;gap:10px;font-size:12.5px;padding:6px 0;border-bottom:1px dashed var(--border)}
.eng-spec:last-child{border-bottom:none}
.eng-spec span{color:var(--text-muted)}
.eng-spec b{color:var(--text);font-weight:600;text-align:right;word-break:break-word}

@media (max-width:900px){
  .eng-convo-grid{grid-template-columns:1fr}
  .eng-cell-sum{max-width:180px}
}

/* ── Lead actions (status filter, per-row status, promote to CRM) ─────────── */
.eng-card-tools{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.eng-select{font:inherit;font-size:13px;padding:5px 8px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text)}
.eng-lead-status{font:inherit;font-size:12px;padding:4px 6px;border:1px solid var(--border);border-radius:7px;background:var(--surface);color:var(--text)}
.eng-lead-actions{display:flex;gap:6px;align-items:center;justify-content:flex-end;white-space:nowrap}
.eng-promoted{font-size:12px;font-weight:600;color:var(--good)}
