:root {
  --bg: #f4f6fa; --panel: #fff; --ink: #172033; --muted: #66708a; --line: #e3e7ef;
  --brand: #e4402f; --brand-ink: #fff; --brand-soft: #fdecea;
  --side: #121826; --side-ink: #aab3c8; --side-active: #1f2738;
  --ok: #1a9b62; --ok-soft: #e3f6ec; --warn: #c98a06; --warn-soft: #fdf3dc;
  --bad: #d13a3a; --bad-soft: #fde6e6; --info: #2f6fdb; --info-soft: #e5eefc;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.05);
}
/* Tema oscuro: sigue al sistema, salvo que se elija uno con el botón (data-theme en <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121b; --panel: #161c28; --ink: #e6eaf2; --muted: #8d97ad; --line: #252d3d;
    --brand-soft: #3a1c1a; --side: #0a0d14; --side-active: #1a2130;
    --ok-soft: #12301f; --warn-soft: #33290e; --bad-soft: #3a1717; --info-soft: #14254a;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e121b; --panel: #161c28; --ink: #e6eaf2; --muted: #8d97ad; --line: #252d3d;
  --brand-soft: #3a1c1a; --side: #0a0d14; --side-active: #1a2130;
  --ok-soft: #12301f; --warn-soft: #33290e; --bad-soft: #3a1717; --info-soft: #14254a;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
.theme-btn { background: transparent; border: 1px solid var(--line); color: var(--ink); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 17px; line-height: 1; flex: none; }
.theme-btn:hover { background: var(--bg); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg); color: var(--ink); display: flex;
}
a { color: inherit; }
.sidebar {
  width: 232px; flex: none; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; color: #fff; }
.brand small { display: block; color: var(--side-ink); font-size: 11px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; font-weight: 500; margin: 1px 0;
}
nav a i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
nav a:hover { background: var(--side-active); color: #fff; }
nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; opacity: .6; }
.reset { margin-top: auto; color: var(--side-ink) !important; border-color: #2a3346 !important; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 0; font-size: 22px; color: var(--ink); cursor: pointer; }
.view { padding: 24px 28px 48px; }

.btn {
  border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); padding: 8px 14px;
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cols-2 { grid-template-columns: 1.4fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { max-width: 300px; }
.toolbar select { width: auto; }
.toolbar .count { color: var(--muted); margin-left: auto; font-size: 13px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--bg); cursor: pointer; user-select: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg); }
tbody tr { cursor: pointer; }
tr:last-child td { border-bottom: 0; }
td .row-actions { opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 420px; }
.col-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); }
.col-head b { display: flex; justify-content: space-between; }
.col-head small { color: var(--muted); font-variant-numeric: tabular-nums; }
.col-head .bar { height: 3px; border-radius: 3px; margin-top: 8px; }
.col-body { padding: 8px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.col.drag-over { outline: 2px dashed var(--brand); outline-offset: -4px; }
.lead {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: grab;
}
.lead:active { cursor: grabbing; }
.lead.dragging { opacity: .4; }
.lead .t { font-weight: 600; }
.lead .c { color: var(--muted); font-size: 12px; }
.lead .m { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12px; }
.lead .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.lead .due { font-size: 11px; }
.lead .due.late { color: var(--bad); font-weight: 600; }

/* Charts */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { background: var(--bg); border-radius: 6px; height: 22px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 6px; background: var(--brand); transition: width .4s; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.vbars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-top: 10px; }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.vbar .col-fill { width: 100%; max-width: 56px; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.vbar .col-fill:hover::after { content: attr(data-v); position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; white-space: nowrap; color: var(--ink); }
.vbar small { color: var(--muted); font-size: 12px; }
.funnel-viz { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.funnel-step { background: var(--brand); color: #fff; text-align: center; padding: 7px 0; border-radius: 6px; font-size: 13px; font-weight: 600; min-width: 120px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .muted, .muted { color: var(--muted); font-size: 12px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,14,22,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-bg[hidden] { display: none; }
.modal { background: var(--panel); border-radius: 14px; width: min(680px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal-head h2 { margin: 0; font-size: 17px; }
.x { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 18px 20px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
.form-foot .left { margin-right: auto; }
.detail { padding: 18px 20px; }
.detail .info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.detail .info div small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.timeline .ev { position: relative; padding-bottom: 12px; }
.timeline .ev::before { content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: none; }
.pl td { font-variant-numeric: tabular-nums; }
.pl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.pos { color: var(--ok); } .neg { color: var(--bad); }

@media (max-width: 1000px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  .sidebar.open { left: 0; }
  .menu-btn { display: block; }
  .view, .topbar { padding-left: 16px; padding-right: 16px; }
  .form { grid-template-columns: 1fr; }
  .detail .info { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 80px; }
}

/* --- MotorMarket DR: metas, campaña y alertas --- */
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 8px; position: relative; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }
.progress .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .45; }
.banner { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.banner b { font-size: 15px; }
.banner .pill { background: var(--bg); border-radius: 99px; padding: 3px 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.alert { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.card table th { background: transparent; }
.card .table-wrap { box-shadow: none; }
.star { color: #e0a100; }
.cfg { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.cfg .form { padding: 0; grid-template-columns: 1fr; }
.lead .trial { font-size: 11px; color: var(--info); font-weight: 600; }

/* --- Inicio, tareas, campañas y métricas --- */
.nbadge { margin-left: auto; background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; font-weight: 700; }
.nbadge:empty { display: none; }
.hoy { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; font-size: 15px; }
.agenda .ag-sec { padding: 10px 0; border-top: 1px solid var(--line); }
.agenda .ag-sec:first-of-type { border-top: 0; padding-top: 0; }
.ag-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.agenda .list li { align-items: center; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); color: transparent; cursor: pointer; font-weight: 700; line-height: 1; padding: 0; flex: none; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.camp { padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.camp:first-of-type { border-top: 0; padding-top: 0; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.mtile { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.mtile small { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.mtile b { font-size: 18px; font-variant-numeric: tabular-nums; }
.mtile span { color: var(--muted); font-size: 11px; }

/* --- Campo de varios valores (responsables) --- */
.form .fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form .fld.full { grid-column: 1 / -1; }
.multi { display: flex; flex-direction: column; gap: 6px; }
.multi-row { display: flex; gap: 6px; }
.multi-x { flex: none; width: 36px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 18px; }
.multi-x:hover { color: var(--bad); border-color: var(--bad); }
.multi-add { align-self: flex-start; border: 1px dashed var(--line); background: transparent; color: var(--brand); border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.multi-add:hover { border-color: var(--brand); background: var(--brand-soft); }
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; font-size: 12px; margin: 1px 0; }

/* =============================== Outreach (v2) =============================== */
.toast.bad { background: var(--bad); color: #fff; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.danger-t { color: var(--bad) !important; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; text-decoration: underline; }
.sec { margin: 6px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: 12px; }
.trunc { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
label.inline input { width: auto; }

/* Login y primer administrador */
body.auth-mode .sidebar, body.auth-mode main { display: none; }
.auth { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 16px; z-index: 80; }
.auth[hidden] { display: none; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(16,24,40,.12); }
.auth-brand { color: var(--ink); padding: 0 0 18px; }
.auth-card h2 { margin: 0 0 8px; font-size: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.auth-err { color: var(--bad); font-size: 13px; min-height: 1em; }

/* Usuario y aviso de simulación */
.user-box { border-top: 1px solid #2a3346; margin-top: 12px; padding: 12px 8px 8px; color: var(--side-ink); font-size: 13px; }
.user-box .u-name { color: #fff; font-weight: 600; }
.user-box .u-role { font-size: 11px; opacity: .8; }
.user-box .linkbtn { color: var(--side-ink); font-size: 12px; }
.reset { margin-top: 6px; }
.mode-banner { background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 13px; padding: 8px 28px; border-bottom: 1px solid var(--line); }
.mode-banner[hidden] { display: none; }
nav a[hidden] { display: none; }

/* Dealers */
.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.filters select, .filters input { padding: 7px 9px; font-size: 13px; }
.bulkbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
table.dealers td, table.dealers th { white-space: nowrap; font-size: 13px; padding: 8px 10px; vertical-align: top; }
th.ck, td.ck { width: 34px; padding-right: 0 !important; }
td.ck input, th.ck input { width: 16px; height: 16px; }
tr.dnc td { opacity: .6; }
.outreach-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: var(--bg); }
.ob-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.outreach-box .info { margin-bottom: 10px; }
.ob-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 14px; }
.mapgrid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.mapgrid select { padding: 6px 8px; font-size: 13px; }
.detail h3 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.row-err td { background: var(--bad-soft); }

/* Canales */
.badge.ch-whatsapp { background: #dcfce7; color: #15803d; }
.badge.ch-email { background: var(--info-soft); color: var(--info); }
.badge.ch-messenger { background: #e0e7ff; color: #4338ca; }
.badge.ch-instagram { background: #fce7f3; color: #be185d; }
.badge.ch-all { background: var(--bad-soft); color: var(--bad); }
:root[data-theme="dark"] .badge.ch-whatsapp { background: #0f2e1d; color: #4ade80; }
:root[data-theme="dark"] .badge.ch-messenger { background: #1e1b4b; color: #a5b4fc; }
:root[data-theme="dark"] .badge.ch-instagram { background: #3b0a24; color: #f9a8d4; }

/* Vista previa de mensajes */
.preview-msg { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel); }
.preview-msg.whatsapp .pre { background: #dcf8c6; color: #111; border-radius: 10px; padding: 8px 10px; display: inline-block; max-width: 100%; }
.pre { white-space: pre-wrap; word-break: break-word; margin-top: 6px; }

/* Campañas: pasos del envío */
.steps { display: grid; gap: 16px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.step > summary, .step > .step-h { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-weight: 700; }
.step > summary::-webkit-details-marker { display: none; }
.step .num-c { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line); font-size: 13px; flex: none; }
.step.done .num-c { background: var(--ok); color: #fff; border-color: var(--ok); }
.step-body { padding: 0 18px 18px; }
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--ink); cursor: pointer; }
.daypick input { width: auto; }
.excl { display: flex; flex-wrap: wrap; gap: 6px; }
.progress-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.mini { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.mini small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 600; }
.mini b { font-size: 20px; font-variant-numeric: tabular-nums; }
.review-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.review-list { display: grid; gap: 8px; max-height: 560px; overflow-y: auto; }
.review-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Métricas */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }

/* Bandeja */
.inbox { display: grid; grid-template-columns: 320px 1fr 300px; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); height: calc(100vh - 150px); min-height: 520px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .toolbar { padding: 10px; margin: 0; border-bottom: 1px solid var(--line); }
.inbox-list .toolbar input, .inbox-list .toolbar select { font-size: 13px; padding: 7px 9px; }
.conv-items { overflow-y: auto; flex: 1; }
.conv { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 2px; }
.conv:hover { background: var(--bg); }
.conv.active { background: var(--brand-soft); }
.conv .top { display: flex; justify-content: space-between; gap: 8px; }
.conv .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .who::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-left: 6px; vertical-align: 1px; }
.conv .snip { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { display: flex; flex-direction: column; min-height: 0; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.bubble { max-width: 72%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bubble.in { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #dcf8c6; color: #111; border-bottom-right-radius: 4px; }
:root[data-theme="dark"] .bubble.out { background: #134e3a; color: #e6eaf2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble.out { background: #134e3a; color: #e6eaf2; } }
.bubble .meta { display: block; font-size: 11px; opacity: .7; margin-top: 4px; text-align: right; }
.bubble.failed { border: 1px solid var(--bad); }
.bubble .tag { font-size: 10px; font-weight: 700; text-transform: uppercase; opacity: .7; display: block; margin-bottom: 2px; }
.composer { border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 8px; }
.composer textarea { min-height: 60px; }
.composer .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.side { border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }
.side h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.side select, .side textarea { font-size: 13px; }
.window-note { font-size: 12px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.window-note.ok { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 1100px) { .inbox { grid-template-columns: 280px 1fr; } .side { display: none; } }
@media (max-width: 760px) { .inbox { grid-template-columns: 1fr; height: auto; } .inbox-list { max-height: 320px; } .bubble { max-width: 90%; } .filters { grid-template-columns: 1fr 1fr; } }

/* Integraciones */
.integ { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.integ .card h3 { display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.warn-t { color: var(--warn); }
