/* Consola KOSTU.
 *
 * Criterio: una consola que pueda usar cualquier persona del equipo sin explicación. Colores del logo
 * «Burbuja K» (whatsapp-crm/brand): crema de fondo, blanco hueso en las tarjetas, granate para el texto,
 * la barra lateral y las acciones principales, y el rojo KOSTU como único acento, que se usa poco: la
 * marca, la sección activa y el foco. Las acciones
 * principales van en tinta oscura para que "Guardar" nunca se confunda con "Eliminar" (rojo).
 *
 * Radios: 14px tarjetas y modales, 9px botones y campos, píldora para etiquetas de estado.
 * Tema: claro u oscuro según el sistema, con los mismos tokens.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4efe8;
  --surface: #fffdfa;
  --surface-2: #f7f1e9;
  --surface-3: #eee5d9;
  --line: #e8ddce;
  --line-strong: #d8c9b6;
  --ink: #22120f;
  --ink-2: #5f524a;
  --ink-3: #74665c;
  --brand: #a52a2a;
  --brand-soft: #f6e4df;
  --primary: #22120f;
  --primary-hover: #3a201c;
  --on-primary: #fffdfa;
  --danger: #b4261f;
  --danger-soft: #fbe9e7;
  --success: #1d7a4f;
  --success-soft: #e2f2ea;
  --warn: #93600f;
  --warn-soft: #faefd9;
  --info: #28589c;
  --info-soft: #e5edf8;
  --neutral-soft: #efe7dc;
  --focus: 0 0 0 3px rgba(165, 42, 42, .22);
  --shadow-sm: 0 1px 2px rgba(34, 18, 15, .05);
  --shadow: 0 12px 32px -16px rgba(34, 18, 15, .3);
  --scrim: rgba(34, 18, 15, .45);
  /* barra lateral: granate, como la del CRM */
  --side-bg: #22120f;
  --side-line: rgba(255, 235, 220, .09);
  --side-ink: #f4efe8;
  --side-ink-2: #d8bfb6;
  --side-ink-3: #a98478;
  --side-hover: rgba(255, 235, 220, .07);
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-lg: 14px;
  --r: 9px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #170d0b;
    --surface: #211512;
    --surface-2: #2b1c18;
    --surface-3: #37251f;
    --line: #3a2823;
    --line-strong: #4b352e;
    --ink: #f4efe8;
    --ink-2: #cdbfb4;
    --ink-3: #a99a8e;
    --brand: #e3725f;
    --brand-soft: #3d1d18;
    --primary: #f4efe8;
    --primary-hover: #e2d9cd;
    --on-primary: #22120f;
    --danger: #f07a70;
    --danger-soft: #3a1d1b;
    --success: #5cc493;
    --success-soft: #16301f;
    --warn: #e0ab55;
    --warn-soft: #33270f;
    --info: #86b1ee;
    --info-soft: #172538;
    --neutral-soft: #2e1f1b;
    --focus: 0 0 0 3px rgba(227, 114, 95, .32);
    --side-bg: #110807;
    --side-line: rgba(255, 235, 220, .07);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 16px 40px -18px rgba(0, 0, 0, .7);
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

html, body { min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
/* Títulos con la letra del logo: Manrope 800 y el interletrado cerrado del nombre «kostu». */
h1, h2 { font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
h3 { font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
pre { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
:focus-visible { outline: none; box-shadow: var(--focus); }

.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -4px; }
.ic-sm { width: 15px; height: 15px; vertical-align: -3px; }
.ic-lg { width: 22px; height: 22px; }

/* ---------- acceso ---------- */
#auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 34px 30px 28px; box-shadow: var(--shadow);
}
/* Logo «Burbuja K» (whatsapp-crm/brand) en una sola pieza, con las proporciones del original; el nombre
   toma el color del texto, así sirve en el modo claro y en el oscuro. */
.logo { display: inline-flex; color: var(--ink); }
.logo-full { height: 40px; width: 126px; display: block; }
.auth-card h1 { margin: 22px 0 6px; font-size: 22px; }
.auth-card p.sub { color: var(--ink-2); margin-bottom: 22px; }
.auth-foot { margin-top: 16px; text-align: center; }
.auth-safe { display: flex; gap: 8px; align-items: flex-start; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; }
.qr-wrap { display: flex; justify-content: center; margin: 8px 0 12px; }
.qr-wrap img, .qr-wrap canvas { border-radius: 10px; padding: 10px; background: #fff; border: 1px solid var(--line); }
.secret { text-align: center; margin: 4px 0 18px; word-break: break-all; }
.otp-input { text-align: center; font-size: 24px !important; letter-spacing: .45em; font-family: var(--mono) !important; }

/* ---------- formularios ---------- */
label.field { display: block; margin-bottom: 16px; }
label.field > span:first-child, .field-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 550; color: var(--ink); margin-bottom: 6px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 9px 12px; min-height: 40px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: .85; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); }
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
input[type=file] { font: inherit; font-size: 13px; color: var(--ink-2); }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; line-height: 1.4; }
.check input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--brand); flex: none; }
.hint { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.45; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .row, .row-3 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 550; font-size: 13.5px;
  min-height: 38px; padding: 8px 14px; border-radius: var(--r); border: 1px solid transparent; cursor: pointer;
  background: var(--primary); color: var(--on-primary); text-decoration: none;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn-green { background: var(--success); color: #fff; }
.btn-green:hover { background: color-mix(in srgb, var(--success) 85%, #000); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-link { background: none; border: 0; color: var(--ink-2); font: inherit; cursor: pointer; padding: 0; font-weight: 550; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.btn-link:hover { color: var(--ink); text-decoration-color: currentColor; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.note { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r); padding: 11px 13px; margin-bottom: 14px; font-size: 13.5px; line-height: 1.45; border: 1px solid transparent; }
.note .ic { margin-top: 1px; }
.error-box { display: block; background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); border-radius: var(--r); padding: 10px 12px; margin-bottom: 14px; font-size: 13.5px; }
.ok-box { background: var(--success-soft); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); border-radius: var(--r); padding: 10px 12px; margin-bottom: 14px; font-size: 13.5px; }
.warn-box { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); border-radius: var(--r); padding: 10px 12px; margin-bottom: 14px; font-size: 13.5px; }
.warn-box.cancel-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--neutral-soft); color: var(--ink); border-color: var(--line); }
.warn-box.cancel-box span { flex: 1 1 260px; }

/* ---------- estructura ---------- */
#app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100dvh; }
#sidebar {
  background: var(--side-bg); color: var(--side-ink-2); border-right: 1px solid var(--side-line); padding: 18px 12px 14px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}
#sidebar .logo { padding: 2px 6px 18px; color: var(--side-ink); }
/* «Mi CRM»: la organización propia de KOSTU, a un clic. Va arriba del menú y, en el celular, en la barra. */
.my-crm {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 16px; padding: 9px 11px 9px 12px;
  border: 1px solid rgba(255, 235, 220, .16); border-radius: var(--r); background: rgba(255, 235, 220, .06);
  color: var(--side-ink); font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.my-crm span { flex: 1; min-width: 0; }
.my-crm .ic { color: var(--side-ink-3); transition: color .15s; }
.my-crm:hover { background: rgba(255, 235, 220, .11); border-color: rgba(255, 235, 220, .28); }
.my-crm:hover .ic { color: var(--side-ink); }
.my-crm:active { transform: translateY(1px); }
.my-crm:focus-visible { outline: none; box-shadow: var(--focus); }
.my-crm:disabled { opacity: .6; cursor: default; transform: none; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.nav-title { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--side-ink-3); padding: 0 10px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r);
  color: var(--side-ink-2); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--side-hover); color: var(--side-ink); }
/* La sección activa en el rojo del logo, igual que en el CRM. */
.nav a.active { background: #a52a2a; color: #fffdfa; font-weight: 600; }
.nav .badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #a52a2a; color: #fffdfa; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
/* Tasa de cobro en bolívares: la más alta entre el paralelo y el euro del BCV, solo para el equipo. */
.rates { margin-top: auto; margin-bottom: 10px; padding: 11px 12px 10px; border: 1px solid var(--side-line); border-radius: var(--r); background: rgba(255, 235, 220, .04); color: var(--side-ink-2); }
.rates + .me { margin-top: 0; }
.rates-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--side-ink-3); }
.rates-refresh { display: grid; place-items: center; width: 24px; height: 24px; margin: -4px -6px -4px 0; border: 0; border-radius: 6px; background: none; color: var(--side-ink-3); cursor: pointer; }
.rates-refresh:hover { background: var(--side-hover); color: var(--side-ink); }
.rates-refresh:focus-visible { outline: none; box-shadow: var(--focus); }
.rates-refresh.spin .ic { animation: rates-spin .8s linear infinite; }
@keyframes rates-spin { to { transform: rotate(360deg); } }
.rate-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 12.5px; }
.rate-val { font-family: var(--mono); font-size: 12.5px; color: var(--side-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate-row.in-use .rate-name { color: var(--side-ink); font-weight: 600; }
.rate-row.in-use .rate-name::after { content: 'en uso'; margin-left: 7px; padding: 1px 6px; border-radius: 999px; background: #a52a2a; color: #fffdfa; font-size: 10px; font-weight: 700; letter-spacing: .02em; vertical-align: 1px; }
.rate-row.in-use .rate-val { color: var(--side-ink); font-weight: 500; }
.rates-foot { margin-top: 5px; font-size: 11px; color: var(--side-ink-3); }
.rates-foot.stale { color: #e0ab55; }
.topbar-rate { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--side-ink-2); white-space: nowrap; }
.topbar-rate.stale { color: #e0ab55; }
@media (min-width: 961px) { .topbar-rate { display: none; } }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--side-line); color: var(--side-ink); }
.nav a.active .badge { background: #fffdfa; color: #a52a2a; }
.me-info { min-width: 0; flex: 1; }
.me-info strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info span { display: block; font-size: 12px; color: var(--side-ink-3); }
.me .avatar { background: rgba(255, 235, 220, .1); color: var(--side-ink); }
.me .btn-quiet { color: var(--side-ink-2); }
.me .btn-quiet:hover { background: var(--side-hover); color: var(--side-ink); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 13.5px; flex: none; background: var(--surface-3); color: var(--ink); }

#topbar { display: none; }
#scrim { display: none; }

main { padding: 32px clamp(18px, 3.4vw, 44px) 72px; min-width: 0; max-width: 1280px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 64ch; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; text-decoration: none; margin-bottom: 14px; }
.back:hover { color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .view-in { animation: view-in .35s var(--ease) both; }
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 960px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--side-bg); border-bottom: 1px solid var(--side-line); color: var(--side-ink);
  }
  #topbar .logo { color: var(--side-ink); }
  #topbar .logo-full { height: 34px; width: 107px; }
  #topbar .btn-ghost { background: transparent; color: var(--side-ink); border-color: rgba(255, 235, 220, .22); }
  #topbar .btn-ghost:hover { background: var(--side-hover); }
  .topbar-crm { margin-left: auto; }
  .topbar-rate:not([hidden]) + .topbar-crm { margin-left: 0; }
  #sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; height: 100dvh;
    transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow);
  }
  #app.nav-open #sidebar { transform: none; }
  #app.nav-open #scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 30; }
  main { padding: 22px 16px 64px; }
  .page-head h1 { font-size: 23px; }
}
/* En el teléfono la barra lleva logo, tasa, «Mi CRM» y Menú: «Mi CRM» queda solo con el ícono. */
@media (max-width: 520px) {
  .topbar-crm { flex: none; width: 34px; padding: 0; }
  .topbar-crm span { display: none; }
}
/* Teléfonos angostos (menos de 390 px): «Menú» también queda solo con el ícono para que entre la tasa. */
@media (max-width: 389px) {
  #menu-toggle { flex: none; width: 34px; padding: 0; font-size: 0; gap: 0; }
}

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.card h2, .card > h3 { margin-bottom: 14px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 18px 20px 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.split > div > .card:last-child { margin-bottom: 0; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2, .grid-3, .split { grid-template-columns: minmax(0, 1fr); } .split > div > .card:last-child { margin-bottom: 18px; } }

/* Inicio: las dos columnas terminan a la misma altura. «Actividad reciente» va a la izquierda y
   «Próximos avisos» estira la derecha hasta el final; las dos listas se deslizan por dentro con la
   cabecera fija, y mientras quede algo más abajo el final se desvanece. */
.split-home { align-items: stretch; }
.split-side { display: flex; flex-direction: column; }
.feed-card { display: flex; flex-direction: column; }
.feed-card .card-head { padding-bottom: 12px; margin-bottom: 0; border-bottom: 1px solid var(--line); }
.feed {
  list-style: none; max-height: 336px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.feed:focus-visible { outline: none; box-shadow: inset var(--focus); }
.feed.more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 52px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 52px), transparent); }
.feed-fill { flex: 1 1 auto; min-height: 0; }
.feed-fill .feed { flex: 1 1 0; min-height: 300px; max-height: none; }
.feed li { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed li:has(> a) { padding: 0; }
.feed li > a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 20px; color: inherit; text-decoration: none; }
.feed li > a:hover { background: var(--surface-2); }
.feed li > a:focus-visible { outline: none; box-shadow: inset var(--focus); }
.feed-main { flex: 1; min-width: 0; }
.feed-title { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-when { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 12.5px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.feed-when span:first-child { color: var(--ink-2); font-weight: 600; }
.feed-when span:last-child { color: var(--ink-3); }
@media (max-width: 860px) {
  .feed-fill .feed { flex: none; min-height: 0; max-height: 336px; }
}
.stack-gap > * + * { margin-top: 18px; }

/* Tablero: lo que hay que hacer hoy */
.todo { list-style: none; display: flex; flex-direction: column; }
.todo li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; padding-top: 2px; }
.todo-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.todo-ic.warn { background: var(--warn-soft); color: var(--warn); }
.todo-ic.danger { background: var(--danger-soft); color: var(--danger); }
.todo-ic.info { background: var(--info-soft); color: var(--info); }
.todo-text { flex: 1; min-width: 0; }
.todo-text strong { display: block; font-weight: 600; }
.todo-text span { display: block; color: var(--ink-3); font-size: 13px; }
@media (max-width: 560px) {
  .todo li { flex-wrap: wrap; align-items: flex-start; }
  .todo-text { flex-basis: calc(100% - 52px); }
  .todo li .btn { margin-left: 52px; }
}
.all-clear { display: flex; align-items: center; gap: 14px; padding: 6px 0 2px; }
.all-clear .todo-ic { background: var(--success-soft); color: var(--success); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.stat { padding: 18px 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .l { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.health { display: flex; flex-wrap: wrap; gap: 8px; }
.health span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.health span.on .ic { color: var(--success); }
.health span.off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
.card-scroll { max-height: 360px; overflow-y: auto; }
.card-scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
.card:not(.card-flush) th:first-child, .card:not(.card-flush) td:first-child { padding-left: 4px; }
.card:not(.card-flush) th:last-child, .card:not(.card-flush) td:last-child { padding-right: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td .sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
td strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.who { display: flex; align-items: center; gap: 12px; }
.who .avatar { width: 32px; height: 32px; font-size: 13px; }

/* En el teléfono las tablas marcadas como .responsive pasan a tarjetas. */
@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  table.responsive tbody tr:last-child { border-bottom: 0; }
  table.responsive td { border: 0; padding: 0 !important; min-width: 0; }
  table.responsive td.cell-main, table.responsive td.num { grid-column: 1 / -1; }
  table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-bottom: 1px; }
  table.responsive td.num { text-align: left; }
  table.responsive td.num .actions { justify-content: flex-start !important; }
  table.responsive td.num:empty, table.responsive td.num:has(.actions:empty) { display: none; }
}

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.chip-trial { background: var(--info-soft); color: var(--info); }
.chip-active, .chip-approved, .chip-sent, .chip-ok { background: var(--success-soft); color: var(--success); }
.chip-expiring, .chip-pending { background: var(--warn-soft); color: var(--warn); }
.chip-grace { background: var(--warn-soft); color: var(--warn); }
.chip-blocked, .chip-suspended, .chip-rejected, .chip-failed { background: var(--danger-soft); color: var(--danger); }
.chip-cancelled, .chip-none, .chip-neutral { background: var(--neutral-soft); color: var(--ink-2); }
/* Canceló su suscripción con tarjeta y todavía tiene acceso: va al lado del estado. */
.chip-cancel { background: var(--neutral-soft); color: var(--ink); border: 1px dashed color-mix(in srgb, var(--ink-2) 45%, transparent); margin-left: 6px; }
td .chip-cancel { margin: 4px 0 0; }

.empty { color: var(--ink-3); padding: 28px 12px; text-align: center; font-size: 13.5px; }
.empty .ic { display: block; margin: 0 auto 10px; width: 26px; height: 26px; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; font-size: 14px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

/* Filtros tipo píldora con conteo */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; scrollbar-width: none; }
.filters button { font: inherit; font-size: 13px; font-weight: 550; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.filters button:hover { border-color: var(--line-strong); color: var(--ink); }
.filters button.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.filters .n { font-variant-numeric: tabular-nums; opacity: .7; }
.searchbox { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.searchbox .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.searchbox input { padding-left: 36px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

/* Pestañas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs button { font: inherit; font-weight: 550; color: var(--ink-2); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 9px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .n { font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--ink-2); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.tabs .n.alert { background: var(--brand); color: #fff; }

/* Lista de definiciones */
.dl { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 10px 20px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { word-break: break-word; }
.dl dd .sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
@media (max-width: 520px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 10px; } }
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* Ficha del cliente */
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; margin-bottom: 22px; }
.detail-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.detail-title .avatar { width: 48px; height: 48px; font-size: 19px; border-radius: 12px; }
.detail-title h1 { font-size: 24px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; color: var(--ink-2); font-size: 13.5px; }
.period { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.period .big { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 28%, var(--line)); }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.danger-row:first-of-type { border-top: 0; padding-top: 0; }
.danger-row div { flex: 1; min-width: 220px; }
.danger-row strong { display: block; font-weight: 600; }
.danger-row span { color: var(--ink-3); font-size: 13px; }
.limits { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.limit { background: var(--surface-2); border-radius: var(--r); padding: 12px 14px; }
.limit .l { font-size: 12.5px; color: var(--ink-3); }
.limit .v { font-size: 20px; font-weight: 600; margin-top: 2px; }
.limit .v .sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-3); }
@media (max-width: 640px) { .limits { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.aic-skel { display: inline-block; width: 70%; height: .9em; border-radius: 6px; background: linear-gradient(90deg, var(--line), var(--surface), var(--line)); background-size: 200% 100%; animation: aic-shimmer 1.2s ease-in-out infinite; }
@keyframes aic-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .aic-skel { animation: none; } }

/* Menú desplegable */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 6px; z-index: 15; }
.menu.open-right { right: auto; left: 0; }
.menu button { display: flex; gap: 11px; align-items: flex-start; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-radius: var(--r); padding: 9px 10px; cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--surface-2); }
.menu button .ic { margin-top: 1px; color: var(--ink-2); }
.menu button span { display: block; }
.menu button small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 1px; }
@media (prefers-reduced-motion: no-preference) { .menu { animation: view-in .18s var(--ease) both; } }

/* Planes */
.plan-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.plan-card.off { opacity: .65; }
.plan-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.plan-price { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 10px; }
.plan-price small { font-size: 13px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.plan-card ul { list-style: none; margin: 14px 0 18px; font-size: 13.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.plan-card li { display: flex; gap: 8px; }
.plan-card li .ic { color: var(--success); margin-top: 1px; }
.plan-card .plan-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12.5px; }

/* Plantillas */
.tpl-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .tpl-layout { grid-template-columns: minmax(0, 1fr); } }
.tpl-list { display: flex; flex-direction: column; gap: 2px; }
.tpl-list button { text-align: left; font: inherit; background: none; border: 0; border-radius: var(--r); padding: 8px 10px; cursor: pointer; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.tpl-list button:hover { background: var(--surface-2); color: var(--ink); }
.tpl-list button.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.tpl-list .mod { font-size: 11.5px; color: var(--warn); font-weight: 650; }
.list-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin: 4px 10px 6px; }
.list-title + .tpl-list { margin-bottom: 14px; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.vars code { cursor: pointer; }
.vars code:hover { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.preview { background: var(--surface-2); border-radius: var(--r); padding: 14px 16px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; min-height: 60px; }
.secret-box { display: flex; gap: 8px; align-items: center; }
.secret-box code { flex: 1; font-size: 13.5px; padding: 8px 10px; word-break: break-all; }

/* Ajustes: una sección a la vez */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav button { display: flex; gap: 10px; align-items: center; text-align: left; font: inherit; font-weight: 500; background: none; border: 0; border-radius: var(--r); padding: 8px 10px; cursor: pointer; color: var(--ink-2); }
.settings-nav button:hover { background: var(--surface-2); color: var(--ink); }
.settings-nav button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.settings-nav button .ok { margin-left: auto; color: var(--success); }
.settings-nav button .ko { margin-left: auto; color: var(--danger); }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (max-width: 860px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .settings-nav button { white-space: nowrap; }
}

details.more { margin-top: 6px; }
details.more > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 550; padding: 6px 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary:hover { color: var(--ink); }
details.more[open] > summary .ic { transform: rotate(90deg); }

/* ---------- modal / avisos ---------- */
.modal-back { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 20px 16px; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; width: 100%; max-width: 540px; max-height: 92dvh; overflow: auto; box-shadow: var(--shadow); }
.modal.wide { max-width: 780px; }
.modal h2 { margin-bottom: 8px; font-size: 19px; }
.modal .modal-lead { color: var(--ink-2); margin-bottom: 18px; font-size: 13.5px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
@media (prefers-reduced-motion: no-preference) {
  .modal-back { animation: fade .18s ease both; }
  .modal { animation: view-in .28s var(--ease) both; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 560px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 94dvh; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
  .modal .modal-actions .btn { flex: 1; }
}
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--primary); color: var(--on-primary); padding: 11px 14px; border-radius: var(--r); font-size: 13.5px; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--success); color: #fff; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: view-in .22s var(--ease) both; } }

/* Carga con la forma del contenido, no un círculo girando en el medio. */
.skeleton { display: flex; flex-direction: column; gap: 14px; }
.sk { border-radius: var(--r); background: var(--surface-3); height: 14px; }
.sk-title { height: 26px; width: 240px; }
.sk-block { height: 120px; border-radius: var(--r-lg); }
@media (prefers-reduced-motion: no-preference) { .sk { animation: pulse 1.4s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .55; } }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; }
@media (prefers-reduced-motion: no-preference) { .spinner { animation: spin .7s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 28px; text-align: center; color: var(--ink-3); }
.preview.preview-email { padding: 0; background: transparent; white-space: normal; }
.preview-email .preview-subject { padding: 0 2px 10px; }
.preview-email iframe { display: block; width: 100%; min-height: 520px; border: 1px solid var(--line); border-radius: var(--r-lg); background: #f4efe8; }
.paylink { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pm-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 10px; }
.pm-item { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px 8px; background: var(--surface-2); }
.pm-item .field { margin-bottom: 8px; }

/* ---------- métricas y finanzas ---------- */
/* Colores de los gráficos: azul = ingresos/MRR, naranja = gastos (paleta validada para daltonismo). */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --pos: #1d7a4f; --neg: #b4261f; }
@media (prefers-color-scheme: dark) { :root { --viz-1: #3987e5; --viz-2: #d95926; --pos: #5cc493; --neg: #f07a70; } }

.ic-xs { width: 13px; height: 13px; vertical-align: -2px; }
.pos { color: var(--pos); font-weight: 600; font-variant-numeric: tabular-nums; }
.neg { color: var(--neg); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v.neg { color: var(--neg); }
.warn-t { color: var(--warn); font-size: 12.5px; font-weight: 550; white-space: nowrap; }
tr.dim td { opacity: .55; }
.check span { display: grid; gap: 2px; }
.check small { color: var(--ink-3); font-size: 12.5px; }

.kpi-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; box-shadow: var(--shadow-sm); overflow: hidden; }
.kpi-main { padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; }
.kpi-l { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.kpi-v { font-size: clamp(34px, 5vw, 46px); font-weight: 650; letter-spacing: -.035em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-s { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.kpi-side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-left: 1px solid var(--line); background: var(--surface-2); }
.kpi-side > div { padding: 22px 20px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.kpi-side > div:first-child { border-left: 0; }
.kpi-side dt { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.kpi-side dd { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi-side span { font-size: 12px; color: var(--ink-3); line-height: 1.35; }
@media (max-width: 900px) {
  .kpi-hero { grid-template-columns: minmax(0, 1fr); }
  .kpi-side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .kpi-side { grid-template-columns: minmax(0, 1fr); }
  .kpi-side > div { border-left: 0; border-top: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 14px 20px; }
  .kpi-side > div:first-child { border-top: 0; }
  .kpi-side dd { margin: 0 0 0 auto; font-size: 20px; order: 2; }
  .kpi-side span { flex-basis: 100%; order: 3; }
}

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.delta.good { background: var(--success-soft); color: var(--success); }
.delta.bad { background: var(--danger-soft); color: var(--danger); }
.delta.flat { background: var(--neutral-soft); color: var(--ink-2); }
.stat .s .delta { margin-left: 4px; padding: 0 6px; font-size: 11.5px; }

.cg { position: relative; }
.cg-plot { position: relative; }
.cg svg { display: block; overflow: visible; }
.cg-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cg-grid.base { stroke: var(--line-strong); }
.cg-tick { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.cg-tick.now { fill: var(--ink); font-weight: 600; }
.cg-bar { transition: opacity .15s; }
.cg-bar.partial { opacity: .55; }
.cg-hit { fill: transparent; cursor: pointer; }
.cg-hit.on { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.cg-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin: -4px 0 10px; }
.cg-legend span, .cg-tip span { display: inline-flex; align-items: center; gap: 6px; }
.cg-legend i, .cg-tip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cg-tip { position: absolute; z-index: 3; pointer-events: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow); padding: 9px 12px; font-size: 12.5px; display: grid; gap: 3px; min-width: 170px; color: var(--ink-2); }
.cg-tip strong { color: var(--ink); margin-bottom: 2px; }
.cg-tip b { color: var(--ink); font-weight: 600; margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.cg-tip span { display: flex; }
.cg-tip[hidden] { display: none; }

.hb { list-style: none; display: grid; gap: 14px; }
.hb-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 6px; }
.hb-top strong { font-variant-numeric: tabular-nums; }
.hb-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: 999px; }
.hb-sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.facts { display: grid; gap: 14px; }
.facts > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; }
.facts dt { font-size: 13.5px; font-weight: 550; }
.facts dd { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.facts span { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.facts-row { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.facts-row > div { grid-template-columns: minmax(0, 1fr); }
.facts-row dd { text-align: left; font-size: 18px; }
@media (max-width: 640px) { .facts-row { grid-template-columns: minmax(0, 1fr); } }

.note.warn { background: var(--warn-soft); color: var(--warn); margin: 14px 0 0; }
.card .note:not(.warn) { background: var(--surface-2); color: var(--ink-2); margin: 14px 0 0; }

table.mv td, table.mv th { white-space: nowrap; }
table.mv td .sub { font-weight: 400; }

.defs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; margin-top: 12px; font-size: 13.5px; line-height: 1.5; }
.defs dt { font-weight: 600; }
.defs dd { color: var(--ink-2); }
@media (max-width: 640px) { .defs { grid-template-columns: minmax(0, 1fr); gap: 2px; } .defs dd { margin-bottom: 10px; } }

.month-nav { display: flex; align-items: center; gap: 10px; margin: -6px 0 16px; }
.month-nav strong { font-size: 16px; min-width: 150px; text-align: center; }
.month-nav .btn-link { margin-left: 6px; font-size: 13px; }

.banner { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 18px; font-size: 13.5px; line-height: 1.45; }
.banner > div { display: grid; gap: 2px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.banner.warn span { color: var(--ink-2); }
/* Fondo de IA (Finanzas): el aviso con acciones y la pestaña. */
.banner.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.banner.danger span { color: var(--ink-2); }
.banner.fund > div:not(.banner-actions) { flex: 1; min-width: 0; }
.banner-actions { display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px; align-self: center; }
.banner-actions .btn-link { font-size: 13px; }
.fund-sec { padding-bottom: 18px; }
.fund-sec + .fund-sec { border-top: 1px solid var(--line); }
.fund-sec > .table-wrap, .fund-sec > .empty { margin-top: 2px; }
.fund-pad { padding: 0 20px; }
.fund-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 20px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.fund-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fund-grid > div { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); min-width: 0; }
.fund-grid > div:first-child { border-left: 0; }
.fund-grid dt { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.fund-grid dd { margin: 4px 0 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fund-grid span { font-size: 12px; color: var(--ink-3); line-height: 1.35; }
.fund-grid .is-due { background: var(--warn-soft); }
.fund-grid .is-due dd { color: var(--warn); }
.fund-grid .is-bad { background: var(--danger-soft); }
.fund-grid .is-bad dd { color: var(--danger); }
.fund-grid .is-ok dd { color: var(--success); }
@media (max-width: 960px) {
  .fund-grid, .fund-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fund-grid > div:nth-child(odd) { border-left: 0; }
  .fund-grid > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .fund-grid-3 > div:last-child { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .banner.fund { flex-wrap: wrap; }
  .banner-actions { width: 100%; }
  .fund-grid { margin: 0 14px; }
  .fund-pad { padding: 0 14px; }
  .fund-grid dd { font-size: 19px; }
}
#nav a[hidden] { display: none; }
.split + .card, .split + details { margin-top: 18px; }

/* ---------- período sin pago registrado ---------- */
.pay-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pay-cell a.chip { text-decoration: none; }
.pay-pending-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pay-pending-box > span { flex: 1; min-width: 200px; }
fieldset.choice { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
fieldset.choice > span { display: block; font-size: 13px; font-weight: 550; color: var(--ink); margin-bottom: 8px; }
fieldset.choice .check { margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); }
fieldset.choice .check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
fieldset.choice .check strong { font-weight: 650; color: var(--ink); }

/* Lectura del comprobante con IA */
.ai-link { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.ai-link:hover { text-decoration: underline; }
.ai-link:focus-visible { outline: 2px solid var(--ink-3); outline-offset: 2px; border-radius: 4px; }
.ai-link.good { color: var(--success); }
.ai-link.warn { color: var(--warn); }
.ai-link.bad { color: var(--danger); }
.ai-modal { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 20px; align-items: start; }
.ai-shot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--neutral-soft); min-height: 120px; color: var(--ink-2); font-size: 13px; }
.ai-shot img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: #fff; }
.ai-checks { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ai-checks li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r); font-size: 13.5px; }
.ai-checks li .ic { flex-shrink: 0; margin-top: 2px; }
.ai-checks li.error { background: var(--danger-soft); color: var(--danger); }
.ai-checks li.warn { background: var(--warn-soft); color: var(--warn); }
@media (max-width: 640px) { .ai-modal { grid-template-columns: 1fr; } .ai-shot img { max-height: 320px; } }

/* Cambiar fecha de vencimiento: atajos y vista previa de los avisos */
.setend-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: -8px 0 16px; }
.setend-preview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.setend-list { list-style: none; margin: 0; padding: 0; }
.setend-list li { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; font-size: 13px; }
.setend-list li + li { border-top: 1px solid var(--line); }
.setend-list .when { font-weight: 550; }
.setend-list .sub { display: block; font-size: 12px; color: var(--ink-2); }
.setend-list .tag { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.setend-list li.is-past { opacity: .5; }
.setend-preview > p { padding: 10px 12px; margin: 0; }

/* Tarjeta Módulos del perfil: filas con interruptor */
.mods { display: grid; gap: 18px; }
.mod-gh { font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.mod-note { margin: 0 0 4px; }
.mod-row.by-plan { cursor: default; }
.mod-row.by-plan .switch input { cursor: not-allowed; }
.mod-row.by-plan .switch input:checked + .switch-ui { opacity: .55; }
.mod-plan { font-size: 11px; padding: 1px 8px; margin-left: 6px; vertical-align: 1px; }
.plan-mods { display: grid; gap: 6px; margin: 4px 0 12px; }
.plan-mods > div { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-mod-pick { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 6px; margin: 0 0 14px; min-width: 0; }
.plan-mod-pick legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.plan-mod-pick .hint { margin: 0 0 8px; }
.pm-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 8px 0; border-top: 1px solid var(--line); }
.pm-group:first-of-type { border-top: 0; }
.pm-gh { flex-basis: 100%; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.mod-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.mod-group .mod-row:first-of-type { border-top: 0; }
.mod-txt { display: grid; gap: 2px; min-width: 0; }
.mod-txt strong { font-weight: 600; }
.mod-txt span { color: var(--ink-3); font-size: 13px; line-height: 1.4; }
.switch { position: relative; flex: none; width: 40px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-ui { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .switch-ui { opacity: .6; }
.select-inline { width: auto; max-width: 100%; }
