/* ============================================================
   NOX LABS — Panel de la agencia · Design system v3 (claro)
   Identidad: blanco, Inter, tinta casi negra, sin gradientes.
   ============================================================ */
:root {
  /* Paleta: blanco + lima señal. El lima se usa SOLO en llamados a la acción. */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #ededed;
  --line: #ededed;
  --line-2: #dcdcdc;
  --text: #0a0a0a;
  --muted: #6e6e6e;
  --muted-2: #9c9c9c;
  --accent: #d4ff00;          /* lima señal — solo CTAs */
  --accent-ink: #0a0a0a;      /* tinta sobre lima */
  --accent-dim: #f2f2f2;      /* estado activo: gris neutro, nunca lima */
  /* Estados funcionales, desaturados para que el lima siga siendo el único grito */
  --alta: #c81e1e;
  --alta-dim: #fdf2f2;
  --alta-line: #f2d2d2;
  --media: #a15c07;
  --media-dim: #fdf8ef;
  --media-line: #eeddbc;
  --ok: #0a7040;
  --ok-dim: #f0faf4;
  --ok-line: #c6e5d5;
  --info: #1a4fbf;
  --info-dim: #f2f6fd;
  --info-line: #d0dcf5;
  --radius: 14px;
  --radius-s: 10px;
  --side-w: 238px;
  --rail-w: 68px;
  --top-h: 58px;
  --shadow: 0 1px 2px rgba(10, 10, 10, 0.05), 0 10px 28px rgba(10, 10, 10, 0.07);
  --shadow-s: 0 1px 2px rgba(10, 10, 10, 0.05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
/* Pantallas de conexión / PIN: sin barra lateral, sin desplazamiento */
body.nochrome { padding-left: 0 !important; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text); text-decoration: none; }
h1, h2, h3 { margin: 0; }
::selection { background: var(--text); color: #fff; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d8d8dc; border-radius: 99px; border: 2px solid #fff; }
::-webkit-scrollbar-thumb:hover { background: #c2c2c8; }
::-webkit-scrollbar-track { background: transparent; }

/* Micro-etiqueta reutilizable */
.microlabel, .field label, .section-title, .tile .l, .view-title, .kpi .l {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  color: var(--muted);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 900; letter-spacing: 0.2em; text-transform: uppercase; font-size: 13px;
  display: flex; align-items: center; gap: 2px; white-space: nowrap;
}
.brand span { color: var(--muted-2); }
.topbar .spacer { flex: 1; }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; flex-shrink: 0;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--surface-2); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn svg { width: 17px; height: 17px; }

/* Botón hamburguesa (las tres líneas) */
.menu-btn { position: relative; }
.menu-btn svg { width: 19px; height: 19px; }
.menu-btn .dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--alta); color: #fff; border: 2px solid #fff;
  font-size: 9.5px; font-weight: 800; display: grid; place-items: center; line-height: 1;
}

/* ---------- Notificaciones ---------- */
/* La campana reusa el mismo punto rojo del menú: dos formas distintas de decir
   "hay algo pendiente" harían dudar de si significan lo mismo. */
#bellBtn { position: relative; }
#bellBtn .dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--alta); color: #fff; border: 2px solid #fff;
  font-size: 9.5px; font-weight: 800; display: grid; place-items: center; line-height: 1;
}

.notif-lista { display: flex; flex-direction: column; gap: 2px; }
.notif {
  display: flex; gap: 11px; align-items: flex-start; width: 100%; text-align: left;
  padding: 11px 12px; border: 0; border-radius: 11px; background: transparent;
  cursor: pointer; font: inherit; color: var(--text);
}
.notif:hover { background: var(--surface-2); }
.notif .ic {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
}
.notif .ic svg { width: 15px; height: 15px; }
.notif .tx { flex: 1; min-width: 0; }
/* Una línea por parte. Sin esto, un título largo en pantalla angosta hacía filas
   del doble de alto y el listado dejaba de escanearse de un vistazo. */
.notif .tx b {
  display: block; font-size: 13.5px; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notif .tx small {
  display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notif .cuando { color: var(--muted-2); font-size: 11.5px; white-space: nowrap; flex: none; padding-top: 2px; }
/* Sin ver: una barra a la izquierda en vez de fondo de color. El fondo compite
   con el estado de hover y deja de leerse cuál es cuál. */
.notif.sinver { box-shadow: inset 2px 0 0 var(--alta); }
.notif.sinver .tx b { font-weight: 800; }
.notif.hot .ic { background: var(--alta-dim); color: var(--alta); }
.notif.ok .ic { background: var(--accent-dim); color: var(--text); }

/* ---------- Desktop nav ---------- */
.desknav { display: none; gap: 2px; margin-left: 18px; }
.desknav a {
  color: var(--muted); padding: 7px 12px; border-radius: 9px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.11em; font-weight: 700;
  transition: color .15s, background .15s;
}
.desknav a:hover { color: var(--text); background: var(--surface-2); }
.desknav a.active { color: var(--text); background: var(--accent-dim); }

/* ---------- Drawer (menú lateral) ---------- */
.drawer-back {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(15, 15, 20, 0.32);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: fadeIn .16s ease;
}
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(390px, 88vw);
  background: var(--bg); border-right: 1px solid var(--line);
  box-shadow: 0 0 48px rgba(16, 24, 40, 0.14);
  display: flex; flex-direction: column;
  animation: slideIn .24s cubic-bezier(.32, .84, .3, 1);
  overflow-y: auto; overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head .sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.drawer-sec {
  padding: 16px 18px 4px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.13em; font-weight: 700; color: var(--muted-2);
}
.drawer-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 18px 6px; }
.dk {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  background: var(--surface); text-align: left; display: block;
}
.dk:hover { background: var(--surface-2); }
.dk .n { font-size: 22px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dk .l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--muted); margin-top: 3px; }
.dk.hot { border-color: var(--alta-line); background: var(--alta-dim); }
.dk.hot .n { color: var(--alta); }
.drawer-nav { padding: 4px 10px 10px; }
.drawer-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px; font-size: 14.5px; font-weight: 600;
  color: var(--text); transition: background .12s;
}
.drawer-nav a:hover { background: var(--surface-2); }
.drawer-nav a.active { background: var(--accent-dim); }
.drawer-nav a .ic { line-height: 0; color: var(--muted); }
.drawer-nav a.active .ic { color: var(--text); }
.drawer-nav a .ic svg { width: 19px; height: 19px; }
.drawer-nav a .count {
  margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 99px; font-variant-numeric: tabular-nums;
}
.drawer-nav a .count.hot { color: var(--alta); background: var(--alta-dim); border-color: var(--alta-line); }
.drawer-foot { margin-top: auto; padding: 12px 18px 4px; border-top: 1px solid var(--line); }

/* ---------- Content ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 22px 18px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 2px 2px 22px; gap: 12px; }
.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 5px; font-weight: 450; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-s);
  font-weight: 600; font-size: 13.5px; letter-spacing: 0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
  box-shadow: var(--shadow-s);
  transition: background .15s, border-color .15s, transform .1s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
/* El lima vive aquí: solo llamados a la acción. */
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700;
}
.btn.primary:hover { background: #c2ea00; border-color: #c2ea00; }
.btn.dark { background: var(--text); color: #fff; border-color: var(--text); font-weight: 650; }
.btn.dark:hover { background: #262626; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.danger { color: var(--alta); border-color: var(--alta-line); }
.btn.danger:hover { background: var(--alta-dim); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }
:is(button, input, select, textarea):focus-visible {
  outline: 2px solid var(--text); outline-offset: 2px; border-radius: 8px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-s);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
a.card:hover, .card[data-action]:hover { border-color: var(--line-2); box-shadow: var(--shadow); }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 26px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-s);
  transition: border-color .15s, box-shadow .15s;
}
a.tile:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.tile .n {
  font-size: 34px; font-weight: 800; letter-spacing: -0.045em; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.tile .l { margin-top: 9px; display: block; }
.tile.alert { border-color: var(--alta-line); }
.tile.alert .n { color: var(--alta); }
.tile.alert::after, .tile.accent::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--alta);
}
.tile.accent { border-color: var(--line-2); }
.tile.accent::after { background: var(--text); }

.section-title { margin: 30px 2px 12px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted);
  background: var(--surface-2);
}
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.u-alta, .st-failed, .st-rejected, .st-descartada, .cat-caliente {
  color: var(--alta); border-color: var(--alta-line); background: var(--alta-dim);
}
.u-media, .st-awaiting_approval, .st-ready, .st-pendiente, .ls-nuevo {
  color: var(--media); border-color: var(--media-line); background: var(--media-dim);
}
.st-approved, .st-published, .st-hecha, .ls-ganado {
  color: var(--ok); border-color: var(--ok-line); background: var(--ok-dim);
}
.st-en_progreso, .st-generating, .st-draft, .ls-contactado, .cat-tibio {
  color: var(--info); border-color: var(--info-line); background: var(--info-dim);
}
.u-baja, .ls-perdido, .cat-frio { color: var(--muted); }
.ls-agendado, .cat-potencial {
  color: var(--text); border-color: var(--line-2); background: var(--accent-dim);
}

/* ---------- Rows ---------- */
.row-item { display: flex; gap: 13px; align-items: flex-start; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 7px; }
.row-item .who { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; }
.row-item .summary { font-size: 15px; line-height: 1.45; }
.row-item .raw { color: var(--muted); font-size: 13px; margin-top: 7px; font-style: italic; line-height: 1.45; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .search input {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  padding: 9px 12px; border-radius: var(--radius-s); font-size: 13.5px;
  box-shadow: var(--shadow-s);
  transition: border-color .15s;
}
.filters select:hover, .search input:hover { border-color: #b9b9c1; }
.search { flex: 1; min-width: 150px; }
.search input { width: 100%; }
.search input::placeholder { color: var(--muted-2); }

/* ---------- Piece ---------- */
.piece { display: flex; gap: 13px; }
.piece .thumb {
  width: 76px; height: 76px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line);
}
.piece .thumb.ph { display: grid; place-items: center; color: var(--muted-2); }
.piece .thumb.ph svg { width: 24px; height: 24px; }

/* ---------- Client ---------- */
.client-row { display: flex; align-items: center; gap: 13px; }
.client-row .avatar, .avatar {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--muted);
}
.client-row.inactive { opacity: 0.5; }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  padding: 12px 13px; border-radius: var(--radius-s);
  box-shadow: var(--shadow-s);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--text); outline: none; box-shadow: 0 0 0 3px var(--accent-dim);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted-2); }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.field .hint { color: var(--muted-2); font-size: 12px; margin-top: 6px; line-height: 1.45; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 15, 20, 0.36);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg); border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  padding: 20px 20px calc(26px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 48px rgba(16, 24, 40, 0.18);
  animation: slideUp .22s cubic-bezier(.3, .9, .3, 1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal .modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal .modal-head h3 { font-size: 18px; font-weight: 800; letter-spacing: -0.025em; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal .modal-actions .btn { flex: 1; }

/* ---------- Sidebar (menú lateral fijo) ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 45;
  width: var(--side-w);
  display: none; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 16px) 12px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
}
.side-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 20px; font-weight: 900; letter-spacing: 0.2em;
  text-transform: uppercase; font-size: 13px; white-space: nowrap;
}
.side-brand .mark {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: var(--text); color: var(--accent);
  display: grid; place-items: center; font-size: 13px; letter-spacing: 0;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-sec {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.13em;
  font-weight: 700; color: var(--muted-2); padding: 16px 10px 7px;
}
.side-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: background .12s, color .12s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--accent-dim); color: var(--text); font-weight: 650; }
.side-nav a .ic { line-height: 0; flex-shrink: 0; }
.side-nav a .ic svg { width: 18px; height: 18px; }
.side-nav a .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav a .count {
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 99px;
  background: var(--surface-3); color: var(--muted);
}
.side-nav a .count.hot { background: var(--alta-dim); color: var(--alta); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- Dashboard ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow-s); display: block;
  transition: border-color .15s, box-shadow .15s;
}
a.kpi:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.kpi .n {
  font-size: 28px; font-weight: 800; letter-spacing: -0.045em; line-height: 1.05;
  font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 5px;
}
.kpi .n .unit { font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.kpi .l { margin-top: 8px; display: block; }
.kpi .d { font-size: 11.5px; font-weight: 650; margin-top: 5px; color: var(--muted); }
.kpi .d.up { color: var(--ok); }
.kpi .d.down { color: var(--alta); }
.kpi.hot { border-color: var(--alta-line); background: var(--alta-dim); }
.kpi.hot .n { color: var(--alta); }

/* Barras horizontales — marca fina, punta redondeada, valor en la punta */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 12px; }
.bar-row .bl {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-track { height: 10px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bar-fill {
  display: block; height: 100%;
  border-radius: 0 4px 4px 0;   /* punta redondeada, base cuadrada */
  transition: width .5s cubic-bezier(.3, .9, .3, 1);
}
.bar-row .bv {
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: right; color: var(--text);
}
.bar-row .bv small { font-weight: 600; color: var(--muted); font-size: 11px; margin-left: 4px; }

/* Embudo */
.funnel { display: flex; flex-direction: column; gap: 2px; }
.fn-step { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.fn-step + .fn-step { border-top: 1px solid var(--line); }
.fn-bar { flex: 1; height: 30px; border-radius: 8px; background: var(--surface-3); position: relative; overflow: hidden; }
.fn-bar i {
  position: absolute; inset: 0 auto 0 0; display: block;
  border-radius: 0 6px 6px 0;
  transition: width .5s cubic-bezier(.3, .9, .3, 1);
}
.fn-bar span {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 12.5px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.fn-step .fv { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
.fn-step .fp { font-size: 11.5px; font-weight: 650; color: var(--muted); min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* Gráfico de área con cursor */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .gl { stroke: var(--line); stroke-width: 1; }          /* cuadrícula tenue, sólida */
.chart .ax { fill: var(--muted-2); font-size: 10px; font-weight: 600; }
.chart .ax.val { fill: var(--text); font-size: 11.5px; font-weight: 800; }
.chart .cl { stroke: var(--line-2); stroke-width: 1; }
.chart .cursor { transition: opacity .12s; pointer-events: none; }
.chart .hit { cursor: crosshair; }
.chart-wrap .tip {
  position: absolute; transform: translate(-50%, calc(-100% - 14px));
  background: var(--text); color: #fff; border-radius: 8px;
  padding: 7px 11px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  pointer-events: none; box-shadow: var(--shadow); z-index: 5;
}
.chart-wrap .tip b { font-weight: 800; font-variant-numeric: tabular-nums; }
.chart-wrap .tip span { display: block; color: rgba(255, 255, 255, .62); font-size: 11px; }

/* Puntaje de prospecto */
.score {
  display: inline-flex; align-items: baseline; gap: 1px; flex-shrink: 0;
  padding: 2px 7px; border-radius: 7px; border: 1px solid;
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.score b { font-size: 12.5px; font-weight: 800; }
.score span { font-size: 9.5px; font-weight: 600; opacity: .6; }
.sc-alta { color: #0a7040; background: #f0faf4; border-color: #c6e5d5; }
.sc-media { color: #6b8100; background: #f6faea; border-color: #dbe8ac; }
.sc-baja { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.mini-row.prio { cursor: pointer; border-radius: 8px; padding: 10px 8px; margin: 0 -8px; }
.mini-row.prio:hover { background: var(--surface-2); }
.mini-row.prio + .mini-row.prio { border-top: 1px solid var(--line); }

/* Lectura de la conversación */
.card.insight { border-color: var(--line-2); box-shadow: var(--shadow); margin-bottom: 14px; }
.card.insight .card-h .t { display: inline-flex; align-items: center; gap: 7px; }
.card-h .t svg { width: 15px; height: 15px; color: #6b8100; }
.card.insight.cargando { border-style: dashed; }
.ins-res { margin: 0 0 16px; font-size: 15px; line-height: 1.5; }
.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.ins-grid p { margin: 5px 0 0; font-size: 13.5px; line-height: 1.45; }
.ins-draft {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.ins-draft p {
  margin: 7px 0 0; padding: 12px 14px; font-size: 14.5px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.chip.int-alto { color: #0a7040; background: #f0faf4; border-color: #c6e5d5; }
.chip.int-medio { color: #6b8100; background: #f6faea; border-color: #dbe8ac; }
.chip.int-bajo, .chip.int-indeterminado { color: var(--muted); }
@media (min-width: 560px) { .ins-grid { grid-template-columns: repeat(4, 1fr); } }

/* Donas y anillos */
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; display: block; }
.dn-seg { transition: opacity .15s; cursor: default; }
.donut:hover .dn-seg { opacity: .45; }
.donut .dn-seg:hover { opacity: 1; }
.dn-mid {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.dn-mid b {
  font-size: 30px; font-weight: 800; letter-spacing: -0.045em; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.dn-mid b em { font-size: 16px; font-style: normal; font-weight: 700; color: var(--muted); }
.dn-mid span {
  margin-top: 5px; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.12em; font-weight: 700; color: var(--muted);
}
.dn-leg { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 148px; }
.dn-leg li { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 13px; }
.dn-leg li + li { border-top: 1px solid var(--line); }
.dn-leg i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dn-leg .dn-l {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dn-leg .dn-v { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.dn-leg .dn-v small { font-weight: 600; color: var(--muted); font-size: 11px; margin-left: 5px; }
.dn-note { flex: 1; min-width: 148px; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* Disquito del canal sobre el avatar */
.av-wrap { position: relative; flex-shrink: 0; }
.av-ch {
  position: absolute; right: -1px; bottom: -1px;
  border-radius: 50%; display: grid; place-items: center;
  color: #fff; box-shadow: 0 0 0 2px #fff;
}
/* Trazo más grueso: a este tamaño el original se desvanece */
.av-ch svg { width: 62%; height: 62%; display: block; stroke-width: 2.6; }

/* Qué necesita el prospecto — lo dedujo el agente en la conversación */
.day-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 18px 2px 8px; padding-bottom: 7px;
  border-bottom: 1px solid var(--line-2);
}
.day-h:first-child { margin-top: 2px; }
.day-h > span:first-child {
  font-size: 13px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text);
}
.day-h .day-n { font-size: 12px; color: var(--muted); font-weight: 600; }

.salud { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.al { border-radius: 12px; padding: 12px 14px; border: 1px solid; }
.al-t { font-weight: 800; font-size: 14px; }
.al-d { font-size: 13px; margin-top: 3px; }
.al-q { font-size: 12px; margin-top: 6px; font-weight: 700; opacity: .85; }
.al-alta { color: var(--alta); background: var(--alta-dim); border-color: var(--alta-line); }
.al-media { color: var(--media); background: var(--media-dim); border-color: var(--media-line); }

.chip.in-venta { color: #8a4b00; background: #fdf4e8; border-color: #f0d9b6; }
.chip.in-antojo { color: #1a4fbf; background: #eef3fd; border-color: #cddcf6; }

.chip.nec {
  color: #4f6100; background: #f6faea; border-color: #dbe8ac;
  text-transform: none; letter-spacing: 0.01em; font-weight: 650;
}

/* Chip de canal (WhatsApp, Instagram, …) — icono + texto, nunca solo color */
.chip.ch { gap: 5px; padding-left: 6px; text-transform: none; letter-spacing: 0.01em; font-weight: 650; }
.ch-ic { line-height: 0; display: inline-flex; }
.ch-ic svg { width: 12px; height: 12px; }
.seg button .ch-ic { margin-right: 5px; }
.seg button .ch-ic svg { width: 13px; height: 13px; vertical-align: -2px; }
.seg button { display: inline-flex; align-items: center; justify-content: center; }

/* Lista compacta dentro de tarjetas */
.mini { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 13.5px; }
.mini-row + .mini-row { border-top: 1px solid var(--line); }
.mini-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .v { font-weight: 750; font-variant-numeric: tabular-nums; }
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.card-h .t { font-size: 14px; font-weight: 750; letter-spacing: -0.015em; }
.card-h a { font-size: 12px; font-weight: 650; color: var(--muted); }
.card-h a:hover { color: var(--text); }
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ---------- Chats (estilo messenger) ---------- */
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 14px; overflow-x: auto;
}
.seg button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  letter-spacing: 0.02em; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-s); }

.convlist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-s); }
.conv {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 12px; border-radius: 12px; cursor: pointer;
  transition: background .12s;
}
.conv:hover { background: var(--surface-2); }
.conv + .conv { position: relative; }
.conv + .conv::before {
  content: ""; position: absolute; top: 0; left: 72px; right: 12px; height: 1px; background: var(--line);
}
.conv-mid { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.conv-name { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; }
.conv-preview {
  color: var(--muted); font-size: 13px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv.unread .conv-preview { color: var(--text); font-weight: 550; }
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.conv-time { color: var(--muted-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.conv.unread .conv-time { color: var(--text); font-weight: 700; }
.conv-badge {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--text); color: #fff;
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}

/* Cabecera del hilo */
.thread-head {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 2px 14px; margin-bottom: 4px;
}

/* Hilo */
.thread {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; max-height: 56vh; overflow-y: auto; margin-bottom: 10px;
}
.thread-day { text-align: center; margin: 12px 0 10px; }
.thread-day span {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px;
}
.bubble-row { display: flex; margin-bottom: 7px; }
.bubble-row.mine { justify-content: flex-end; }
.bubble {
  max-width: 78%; padding: 9px 12px; border-radius: 16px 16px 16px 5px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-s);
  font-size: 14px; line-height: 1.45; position: relative;
}
.bubble.mine {
  background: var(--text); color: #fff; border-color: var(--text);
  border-radius: 16px 16px 5px 16px; font-weight: 450;
}
.bubble-time {
  display: inline-block; margin-left: 8px; font-size: 10px; opacity: .5;
  font-variant-numeric: tabular-nums; transform: translateY(1px);
}

/* Composer */
.composer { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); }
.composer-row {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 8px; box-shadow: var(--shadow);
}
.composer-row textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--text); padding: 9px 10px; min-height: 40px; max-height: 120px;
  font-size: 14.5px; line-height: 1.45;
}
.composer-row textarea::placeholder { color: var(--muted-2); }
.send-btn {
  width: 40px; height: 40px; border-radius: 12px; border: none; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; transition: background .15s, transform .1s;
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:hover { background: #c2ea00; }
.send-btn:active { transform: translateY(1px); }
.send-btn:disabled { opacity: .4; }
.composer-foot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 9px; text-align: center;
}

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 56px 20px; line-height: 1.7; }
.empty .big { font-size: 34px; margin-bottom: 12px; opacity: .35; }
.muted { color: var(--muted); }
.linklist a {
  display: flex; align-items: center; gap: 10px; padding: 13px 4px;
  border-bottom: 1px solid var(--line); color: var(--text); font-weight: 550; font-size: 14px;
  transition: color .12s;
}
.linklist a:hover { color: var(--muted); }
.linklist a:last-child { border-bottom: none; }
.linklist a .arrow { margin-left: auto; color: var(--muted-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
  background: var(--text); border: 1px solid var(--text); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); max-width: 88vw;
  animation: slideUp .2s cubic-bezier(.3, .9, .3, 1);
}
.toast.err { background: var(--alta); border-color: var(--alta); }

/* ---------- Setup / lock ---------- */
.setup { max-width: 400px; margin: 12vh auto; padding: 28px 24px; }
.setup .logo {
  font-weight: 900; letter-spacing: 0.22em; text-transform: uppercase; text-align: center;
  font-size: 17px; margin-bottom: 8px;
}
.setup .logo span { color: var(--muted-2); }
.setup p { color: var(--muted); text-align: center; font-size: 13px; margin: 0 0 28px; line-height: 1.6; }

/* ---------- Layout lateral ---------- */
/* Tablet: riel de iconos al costado */
@media (min-width: 620px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .sidebar { display: flex; width: var(--rail-w); padding-left: 10px; padding-right: 10px; align-items: stretch; }
  .sidebar .lbl, .sidebar .side-sec, .sidebar .side-brand .txt { display: none; }
  .sidebar .side-brand { justify-content: center; padding: 4px 0 18px; }
  .side-nav a { justify-content: center; padding: 11px 0; position: relative; }
  .side-nav a .ic svg { width: 20px; height: 20px; }
  .side-nav a .count {
    position: absolute; top: 3px; right: 6px; min-width: 16px; padding: 0 4px;
    font-size: 9.5px; line-height: 16px; border: 2px solid #fff;
  }
  body { padding-left: var(--rail-w); }
  .toast { left: calc(50% + var(--rail-w) / 2); }
}
/* Escritorio: menú lateral completo con etiquetas */
@media (min-width: 1000px) {
  .sidebar {
    width: var(--side-w); padding-left: 12px; padding-right: 12px;
  }
  .sidebar .lbl, .sidebar .side-sec, .sidebar .side-brand .txt { display: block; }
  .sidebar .side-brand { justify-content: flex-start; padding: 4px 10px 20px; }
  .side-nav a { justify-content: flex-start; padding: 9px 10px; }
  .side-nav a .count { position: static; border: none; line-height: normal; font-size: 11px; padding: 1px 6px; min-width: 20px; }
  body { padding-left: var(--side-w); }
  .toast { left: calc(50% + var(--side-w) / 2); }
  .topbar .brand { display: none; }   /* ya está en la barra lateral */
}
@media (min-width: 820px) {
  .desknav { display: none; }
  .tiles { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .wrap { padding-top: 30px; }
  .modal-back { align-items: center; }
  .modal { border-radius: 18px; border-bottom: 1px solid var(--line); }
  .card { padding: 18px; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid .full { grid-column: 1 / -1; }
}

/* ---------- Hilo de conversación (modo cliente) ---------- */
.hilo {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; height: 58vh; min-height: 290px; max-height: 520px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 9px;
}
.hilo .glob {
  max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
/* El interesado a la izquierda, lo que sale de su número a la derecha: igual que
   en WhatsApp, para no obligar a aprender otra convención. */
.hilo .glob.el { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.hilo .glob.yo { align-self: flex-end; background: #e5ffd4; border-bottom-right-radius: 5px; }
.hilo .glob .h { display: block; font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }
.escribir { display: flex; gap: 8px; margin-top: 12px; }
.escribir input {
  flex: 1; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px;
  font: inherit; background: var(--surface); color: var(--text);
}
.escribir input:focus { outline: 0; border-color: var(--text); }

/* Casilla con su texto al lado: sin esto el cuadrito se estira al ancho del
   formulario, que es lo que hacen los inputs de este panel. */
.check {
  display: flex; align-items: center; gap: 9px; margin: 0 0 8px;
  font-size: 14px; font-weight: 500; color: var(--text); text-transform: none; letter-spacing: 0;
  cursor: pointer;
}
.check input { width: auto; margin: 0; flex: none; }
