/* MIDImetrix · CRM — estilos de la aplicación (misma familia visual que el cotizador) */

:root {
  --purple: #553E8A;
  --purple-dk: #3C2B64;
  --purple-lt: #EFEBF7;
  --olive: #6E7A3A;
  --olive-lt: #E6E9D0;
  --marino: #2B374D;
  --ink: #1B1B1F;
  --muted: #5F6472;
  --faint: #8A8E9B;
  --line: #E4E2EC;
  --bg: #F6F5F9;
  --surface: #FFFFFF;
  --danger: #B3261E;
  --danger-lt: #FBE9E7;
  --ok: #1E7A4B;
  --ok-lt: #E3F3EA;
  --warn: #9A5B00;
  --warn-lt: #FFF1D6;
  --info-lt: #E3ECFA;
  --wa: #128C7E;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 16px rgba(30, 20, 60, .06);
  --font: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  /* gráficas: categórico (validado) y rampa ordinal morada para el embudo */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #4a3aa7;
  --o1: #b3a5dc; --o2: #957fcc; --o3: #7660bb; --o4: #5a45a3; --o5: #3e2d78; --o0: #8a8e9b;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--purple); }
small { font-weight: 400; }
::selection { background: var(--purple-lt); }

/* ---------- puerta de acceso ---------- */
body.locked { background: var(--bg); }
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #F6F5F9 0%, #EFEBF7 100%); }
.gate-card { width: 100%; max-width: 400px; background: #fff; border: 1.5px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.gate-card img { height: 46px; width: auto; justify-self: start; }
.gate-card h1 { font-size: 21px; color: var(--purple); }
.gate-card p { color: var(--muted); font-size: 14px; }
.gate-card .err { color: var(--danger); font-size: 13px; min-height: 1.2em; }
.gate-card .link { justify-self: start; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; height: var(--topbar-h); padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand img { height: 38px; width: auto; display: block; }
.app-name { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--purple); font-weight: 700; padding-left: 12px; border-left: 2px solid var(--olive); }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); white-space: nowrap; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.tabs button:hover { background: var(--purple-lt); color: var(--purple); }
.tabs button.on { background: var(--purple); color: #fff; }
.tabs button .n { background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center; }
.tabs button.on .n { background: #fff; color: var(--purple); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { border-color: var(--purple); color: var(--purple); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .n { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center; border: 2px solid #fff; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--purple); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; border: 0; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1.5px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(30, 20, 60, .18); min-width: 220px; padding: 6px; z-index: 50; display: grid; }
.menu button, .menu a { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--ink); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.menu button:hover, .menu a:hover { background: var(--purple-lt); color: var(--purple); }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu .who { padding: 8px 12px 4px; font-size: 12px; color: var(--muted); }
.menu .who b { display: block; color: var(--ink); font-size: 14px; }
.rel { position: relative; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid transparent; border-radius: 10px; padding: 9px 15px; font-weight: 700; font-size: 14px; line-height: 1.2; transition: background .15s, border-color .15s, color .15s; text-align: center; text-decoration: none; white-space: nowrap; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dk); }
.btn-line { background: #fff; border-color: var(--purple); color: var(--purple); }
.btn-line:hover { background: var(--purple-lt); }
.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--purple-lt); color: var(--purple); }
.btn-on { background: var(--olive); color: #fff; }
.btn-on:hover { background: #5b662f; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-lt); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: #0e6f64; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn:focus-visible, .chip:focus-visible, .tabs button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .icon-btn:focus-visible { outline: 3px solid #9F95D1; outline-offset: 1px; }
.link { background: none; border: 0; padding: 0; color: var(--purple); font-weight: 700; font-size: 13px; text-decoration: underline; cursor: pointer; }

input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=email], input[type=tel], input[type=password], input[type=url], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 9px 11px; font-size: 14px; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--purple); }
label.f { display: grid; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
label.f > span { display: flex; justify-content: space-between; }
label.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }
.form { display: grid; gap: 12px; }
.form .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .form .cols, .form .cols3 { grid-template-columns: 1fr; } }
.ayuda { font-size: 12.5px; color: var(--muted); }
.ayuda code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.view { display: none; }
.view.on { display: block; }
.page { max-width: 1480px; margin: 0 auto; padding: 18px 20px 90px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font-size: 22px; color: var(--purple); margin-right: auto; }
.page-head p { width: 100%; color: var(--muted); font-size: 14px; margin-top: -6px; }

/* ---------- tarjetas y rejillas ---------- */
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { font-size: 15px; color: var(--purple); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h3 .right { margin-left: auto; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.k4, .grid.k6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid.k4, .grid.k3, .grid.k6, .grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .grid.k2.solo1 { grid-template-columns: 1fr; } }
.kpi { display: grid; gap: 2px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .d { font-size: 12px; color: var(--faint); }
.kpi.alerta .v { color: var(--danger); }
.kpi.ok .v { color: var(--ok); }
.widget-tools { margin-left: auto; display: flex; gap: 4px; }
.widget-tools button { border: 0; background: none; color: var(--faint); width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; }
.widget-tools button:hover { background: var(--purple-lt); color: var(--purple); }
.widget-tools svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---------- chips, badges ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip:hover { border-color: var(--purple); color: var(--purple); }
.chip.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.sin::before { display: none; }
.badge.e-prospecto { background: #EEF2F8; color: #3A4D6E; }
.badge.e-whatsapp { background: #E3F5EE; color: #0E6F64; }
.badge.e-cita { background: var(--purple-lt); color: var(--purple); }
.badge.e-seguimiento { background: var(--olive-lt); color: #4C5526; }
.badge.e-contratado { background: var(--ok-lt); color: var(--ok); }
.badge.e-perdido { background: var(--danger-lt); color: var(--danger); }
.badge.p-alta, .badge.urgente { background: var(--danger-lt); color: var(--danger); }
.badge.p-media { background: var(--warn-lt); color: var(--warn); }
.badge.p-baja { background: var(--info-lt); color: #1F4E8C; }
.badge.ok { background: var(--ok-lt); color: var(--ok); }
.badge.warn { background: var(--warn-lt); color: var(--warn); }
.badge.off { background: var(--bg); color: var(--faint); }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--purple-lt); color: var(--purple); font-weight: 600; margin: 1px 2px 1px 0; }
.score { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; font-size: 12.5px; background: var(--bg); color: var(--ink); border: 3px solid var(--line); }
.score.alto { border-color: var(--ok); } .score.medio { border-color: var(--c4); } .score.bajo { border-color: var(--faint); }

/* ---------- barra de herramientas y tablas ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .buscar { width: 260px; max-width: 100%; }
.toolbar select { width: auto; }
.table-wrap { overflow: auto; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 11px 12px; border-bottom: 1.5px solid var(--line); background: #FAF9FC; white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none; }
table.t th.nosort { cursor: default; }
table.t th.asc::after { content: " ↑"; color: var(--purple); } table.t th.desc::after { content: " ↓"; color: var(--purple); }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: #FBFAFD; }
table.t tr.sel { background: var(--purple-lt); }
table.t .nombre { font-weight: 700; color: var(--ink); cursor: pointer; }
table.t .nombre small { display: block; font-weight: 400; color: var(--muted); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.t .acciones { white-space: nowrap; text-align: right; }
table.t .acciones .btn { margin-left: 4px; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.table-foot .pag { margin-left: auto; display: flex; gap: 4px; }
.bulk { display: none; align-items: center; gap: 8px; padding: 8px 12px; background: var(--purple-lt); border-radius: 10px; margin-bottom: 10px; font-size: 14px; flex-wrap: wrap; }
.bulk.on { display: flex; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.lista { display: grid; gap: 8px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; }
.item:hover { border-color: #C9BFE6; }
.item .cuerpo { flex: 1; min-width: 0; }
.item .cuerpo b { display: block; }
.item .cuerpo small { color: var(--muted); display: block; }
.item .fecha { font-size: 12px; color: var(--faint); white-space: nowrap; }
.item.unread { border-left: 4px solid var(--purple); }
.item .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--purple-lt); color: var(--purple); flex-shrink: 0; font-size: 16px; }
.item .ico.wa { background: #E3F5EE; color: var(--wa); }
.item .ico.em { background: var(--info-lt); color: #1F4E8C; }
.item .ico.tk { background: var(--warn-lt); color: var(--warn); }
.item.clickable { cursor: pointer; }

/* ---------- pipeline (kanban) ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: #EFEDF4; border-radius: 14px; padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 8px; }
.col.over { outline: 2px dashed var(--purple); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; font-weight: 700; font-size: 14px; }
.col-head .n { background: #fff; color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.col-head .val { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }
.tarjeta { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); display: grid; gap: 4px; }
.tarjeta:active { cursor: grabbing; }
.tarjeta.dragging { opacity: .5; }
.tarjeta b { font-size: 14px; }
.tarjeta small { color: var(--muted); font-size: 12.5px; }
.tarjeta .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); flex-wrap: wrap; }
.tarjeta .meta .val { font-weight: 700; color: var(--olive); }
.tarjeta .resp { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; background: var(--purple-lt); color: var(--purple); font-size: 10px; font-weight: 700; display: grid; place-items: center; }

/* ---------- panel lateral (ficha del cliente) y modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(27, 27, 31, .45); z-index: 40; display: none; }
.overlay.on { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 100%); background: var(--bg); z-index: 45; transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(30, 20, 60, .2); }
.drawer.on { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.drawer-head h2 { font-size: 18px; }
.drawer-head small { color: var(--muted); display: block; font-size: 13px; }
.drawer-body { flex: 1; overflow: auto; padding: 16px 18px 40px; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) 320px; align-content: start; }
.drawer-body .main { display: grid; gap: 14px; min-width: 0; }
.drawer-body .side { display: grid; gap: 14px; align-content: start; }
@media (max-width: 860px) { .drawer-body { grid-template-columns: 1fr; } .drawer-body .side { order: -1; } }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13.5px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; word-break: break-word; }
.subtabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--line); margin-bottom: 10px; overflow-x: auto; }
.subtabs button { border: 0; background: none; padding: 8px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1.5px; white-space: nowrap; font-size: 13.5px; }
.subtabs button.on { color: var(--purple); border-bottom-color: var(--purple); }
.timeline { display: grid; gap: 10px; }
.ev { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.ev .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 16px; }
.ev .ico.in { background: #E3F5EE; color: var(--wa); } .ev .ico.out { background: var(--purple-lt); color: var(--purple); } .ev .ico.em { background: var(--info-lt); color: #1F4E8C; }
.ev .box { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; min-width: 0; }
.ev .box .h { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 3px; flex-wrap: wrap; }
.ev .box .h b { color: var(--ink); }
.ev .box .txt { white-space: pre-wrap; word-break: break-word; }
.ev.in .box { border-left: 3px solid var(--wa); }
.ev.out .box { border-left: 3px solid var(--purple); }
.chat-box { display: grid; gap: 8px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; }
.chat-box .fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chat-box textarea { min-height: 60px; }
.modal { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; padding: 16px; background: rgba(27, 27, 31, .5); }
.modal.on { display: grid; }
.modal-card { width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 16px; padding: 20px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.modal-card.ancha { max-width: 900px; }
.modal-card h3 { font-size: 18px; color: var(--purple); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .izq { margin-right: auto; }

/* ---------- avisos ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--marino); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); display: flex; gap: 10px; align-items: center; animation: up .2s ease; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }
.toast button { margin-left: auto; background: none; border: 0; color: #fff; font-size: 18px; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: rot .8s linear infinite; }
.spin.dark { border-color: var(--line); border-top-color: var(--purple); }
@keyframes rot { to { transform: rotate(360deg); } }
.cargando { opacity: .6; pointer-events: none; }
.sk { background: linear-gradient(90deg, #EFEDF4 25%, #F7F6FA 50%, #EFEDF4 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
.banner { padding: 10px 14px; border-radius: 10px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-lt); color: var(--warn); }
.banner.info { background: var(--info-lt); color: #1F4E8C; }
.banner.ok { background: var(--ok-lt); color: var(--ok); }
.banner .btn { margin-left: auto; }

/* ---------- gráficas ---------- */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--font); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .lbl { font-size: 11px; fill: var(--muted); }
.chart .val { font-size: 11px; fill: var(--ink); font-weight: 700; }
.chart .ttl { font-size: 12px; fill: var(--muted); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar:hover { filter: brightness(.92); }
.legend { display: flex; gap: 10px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: fixed; z-index: 80; pointer-events: none; background: var(--marino); color: #fff; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); max-width: 260px; display: none; }
.tooltip b { display: block; }
.hbar { display: grid; gap: 7px; }
.hbar .r { display: grid; grid-template-columns: 130px 1fr 54px; align-items: center; gap: 8px; font-size: 13px; }
.hbar .r .b { height: 12px; border-radius: 4px; background: var(--purple); min-width: 2px; }
.hbar .r .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar .r .l { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel { display: grid; gap: 6px; }
.funnel .s { display: grid; grid-template-columns: 150px 1fr 90px; gap: 8px; align-items: center; font-size: 13px; }
.funnel .s .b { height: 22px; border-radius: 4px; min-width: 3px; }
.funnel .s .n { font-weight: 700; } .funnel .s .n small { font-weight: 400; color: var(--muted); }
.view-table-toggle { font-size: 12.5px; }

/* ---------- agenda / calendario ---------- */
.agenda { display: grid; gap: 12px; }
.dia { display: grid; gap: 6px; }
.dia h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dia h4.hoy { color: var(--purple); }
.tarea { display: flex; gap: 10px; align-items: center; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.tarea.vencida { border-color: #F2C4BE; background: #FFF8F7; }
.tarea.hecha { opacity: .55; text-decoration: line-through; }
.tarea input[type=checkbox] { width: 18px; height: 18px; flex-shrink: 0; }
.tarea .cuerpo { flex: 1; min-width: 0; }
.tarea .cuerpo small { display: block; color: var(--muted); font-size: 12.5px; }
.tarea .hora { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dh { font-size: 11px; color: var(--muted); text-align: center; text-transform: uppercase; padding: 4px 0; }
.cal .dc { min-height: 84px; background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 4px; font-size: 12px; display: grid; gap: 2px; align-content: start; }
.cal .dc.otro { opacity: .45; } .cal .dc.hoy { border-color: var(--purple); }
.cal .dc .d { font-weight: 700; color: var(--muted); }
.cal .dc .p { padding: 1px 5px; border-radius: 4px; background: var(--purple-lt); color: var(--purple); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal .dc .p.fb { background: #E3ECFA; color: #1F4E8C; } .cal .dc .p.ig { background: #FCE4F0; color: #9D1B5B; } .cal .dc .p.tt { background: #EAEAEA; color: #222; } .cal .dc .p.wa { background: #E3F5EE; color: var(--wa); }
.cal .dc .p.hecha { opacity: .5; text-decoration: line-through; }
@media (max-width: 720px) { .cal .dc { min-height: 56px; } .cal .dc .p { font-size: 10px; } }

/* ---------- automatizaciones ---------- */
.regla { display: grid; gap: 6px; }
.regla .flujo { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.regla .paso { background: var(--bg); border-radius: 8px; padding: 4px 9px; }
.regla .paso.d { background: var(--purple-lt); color: var(--purple); font-weight: 700; }
.regla .paso.a { background: var(--olive-lt); color: #4C5526; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: #CFCBDC; border: 0; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--ok); } .switch.on::after { left: 20px; }
.accion-row { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: start; padding: 8px; background: var(--bg); border-radius: 10px; }
.accion-row .campos { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .accion-row { grid-template-columns: 1fr; } .accion-row .campos { grid-template-columns: 1fr; } }

/* ---------- configuración ---------- */
.cfg-row { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.cfg-row:last-child { border-bottom: 0; }
.cfg-row .k { font-weight: 700; } .cfg-row .k small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .cfg-row { grid-template-columns: 1fr; } }
.estado { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.estado i { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.estado.ok i { background: var(--ok); } .estado.warn i { background: var(--c4); } .estado.err i { background: var(--danger); }
.copiar { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--bg); padding: 6px 10px; border-radius: 8px; word-break: break-all; display: flex; gap: 8px; align-items: center; }
.copiar button { margin-left: auto; }

/* ---------- navegación móvil ---------- */
.bottom-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, 1fr); }
.bottom-nav button { border: 0; background: none; display: grid; gap: 2px; justify-items: center; font-size: 11px; color: var(--muted); padding: 4px 0; position: relative; }
.bottom-nav button.on { color: var(--purple); font-weight: 700; }
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav .n { position: absolute; top: 0; right: calc(50% - 20px); background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 5px; min-width: 16px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; background: #fff; border-radius: 16px 16px 0 0; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); display: none; grid-template-columns: repeat(3, 1fr); gap: 8px; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); }
.sheet.on { display: grid; }
.sheet button { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 6px; font-size: 13px; font-weight: 600; color: var(--ink); display: grid; gap: 4px; justify-items: center; }
.sheet button.on { border-color: var(--purple); color: var(--purple); background: var(--purple-lt); }
.sheet svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 860px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .tabs { display: none; }
  .app-name { display: none; }
  .bottom-nav { display: grid; }
  .page { padding: 14px 12px 96px; }
  .drawer { width: 100%; }
  .toolbar .buscar { width: 100%; }
  .kanban { grid-auto-columns: 82vw; }
  .dl { grid-template-columns: 100px 1fr; }
  .hbar .r { grid-template-columns: 100px 1fr 48px; }
  .funnel .s { grid-template-columns: 110px 1fr 80px; }
  table.t.resp thead { display: none; }
  table.t.resp tr { display: grid; grid-template-columns: 1fr auto; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  table.t.resp td { border: 0; padding: 2px 4px; }
  table.t.resp td.ocultar-m { display: none; }
  table.t.resp td.acciones { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
}

@media print {
  .topbar, .bottom-nav, .toolbar, .btn, .drawer, .overlay, .toasts { display: none !important; }
  .page { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
