/* =====================================================================
   ESTILOS
   Diseño: fondo neutro (negro puro en oscuro, blanco en claro) y un solo
   color de acento por cliente.
   · Acento: data-palette="rosa-pastel | rosa | lila | azul | turquesa"
     (se elige en js/config.js → PALETTE)
   · Tema: data-theme="light" | "dark" (sin atributo = el del sistema)
   · Verde = positivo, rojo = negativo, en todos los temas.
   ===================================================================== */

/* ---------- Neutros y semánticos: claro ---------- */
:root {
  --bg: #ffffff;
  --sidebar-bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f6f6f6;
  --border: #e8e8e8;
  --border-strong: #d6d6d6;
  --text: #121212;
  --muted: #6b6b6b;
  --faint: #a3a3a3;

  /* Acento (rosa pastel por defecto) */
  --accent: #f4a7c7;          /* fondos: botón principal, elemento activo */
  --accent-ink: #2a1220;      /* texto sobre el acento */
  --accent-strong: #c2457e;   /* texto y líneas en color acento sobre el fondo */
  --accent-soft: #fdebf3;     /* fondos suaves */

  --pos: #3f8f12;  --pos-fill: #7cc93a;  --pos-soft: #ebf7df;
  --neg: #d92c3c;  --neg-fill: #ef4655;  --neg-soft: #fde6e8;
  --warn: #b7791f; --warn-fill: #f2b632; --warn-bg: #fff4dc; --warn-ink: #7a5410; --warn-border: #f5dfb5;
  --neg-border: #f8c9cc;
  --transfer: #7c5cc4;
  --income: var(--pos);  --expense: var(--neg);
  --backdrop: rgba(0, 0, 0, .45);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);

  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 236px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  color-scheme: light;
}

/* ---------- Neutros y semánticos: oscuro ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --sidebar-bg: #0c0c0c; --surface: #111111; --surface-2: #1a1a1a;
    --border: #262626; --border-strong: #333333;
    --text: #f5f5f5; --muted: #a3a3a3; --faint: #6b6b6b;
    --pos: #8ee05a;  --pos-fill: #7ed348;  --pos-soft: #16240e;
    --neg: #ff4d5e;  --neg-fill: #ff3b4e;  --neg-soft: #2a1013;
    --warn: #f5c542; --warn-fill: #f5c542; --warn-bg: #2b230f; --warn-ink: #f5d58a; --warn-border: #4a3b14;
    --neg-border: #4a1a20;
    --transfer: #b69cf2;
    --backdrop: rgba(0, 0, 0, .7);
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --sidebar-bg: #0c0c0c; --surface: #111111; --surface-2: #1a1a1a;
  --border: #262626; --border-strong: #333333;
  --text: #f5f5f5; --muted: #a3a3a3; --faint: #6b6b6b;
  --pos: #8ee05a;  --pos-fill: #7ed348;  --pos-soft: #16240e;
  --neg: #ff4d5e;  --neg-fill: #ff3b4e;  --neg-soft: #2a1013;
  --warn: #f5c542; --warn-fill: #f5c542; --warn-bg: #2b230f; --warn-ink: #f5d58a; --warn-border: #4a3b14;
  --neg-border: #4a1a20;
  --transfer: #b69cf2;
  --backdrop: rgba(0, 0, 0, .7);
  --shadow: none;
  color-scheme: dark;
}

/* ---------- Acentos por cliente (claro) ---------- */
:root[data-palette="rosa-pastel"] { --accent: #f4a7c7; --accent-ink: #2a1220; --accent-strong: #c2457e; --accent-soft: #fdebf3; }
:root[data-palette="rosa"]        { --accent: #d6407f; --accent-ink: #ffffff; --accent-strong: #b8306a; --accent-soft: #fbe2ed; }
:root[data-palette="lila"]        { --accent: #c9b3f5; --accent-ink: #1e1236; --accent-strong: #6b45c9; --accent-soft: #f1ebfd; }
:root[data-palette="azul"]        { --accent: #a9c8f7; --accent-ink: #0f1d33; --accent-strong: #2a62c4; --accent-soft: #e8f0fd; }
:root[data-palette="turquesa"]    { --accent: #9fe0d8; --accent-ink: #0c2a26; --accent-strong: #0f7d73; --accent-soft: #e2f6f3; }

/* ---------- Acentos por cliente (oscuro) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]), :root:not([data-theme="light"])[data-palette="rosa-pastel"] { --accent: #f7b3cf; --accent-ink: #1f0c16; --accent-strong: #f7b3cf; --accent-soft: #2a1820; }
  :root:not([data-theme="light"])[data-palette="rosa"]     { --accent: #e0559a; --accent-ink: #ffffff; --accent-strong: #ff8cc0; --accent-soft: #3d2131; }
  :root:not([data-theme="light"])[data-palette="lila"]     { --accent: #cdb8fa; --accent-ink: #1a1030; --accent-strong: #cdb8fa; --accent-soft: #221a33; }
  :root:not([data-theme="light"])[data-palette="azul"]     { --accent: #aecbf8; --accent-ink: #0d1a2e; --accent-strong: #aecbf8; --accent-soft: #16202f; }
  :root:not([data-theme="light"])[data-palette="turquesa"] { --accent: #a3e6dd; --accent-ink: #0b2622; --accent-strong: #a3e6dd; --accent-soft: #132826; }
}
:root[data-theme="dark"], :root[data-theme="dark"][data-palette="rosa-pastel"] { --accent: #f7b3cf; --accent-ink: #1f0c16; --accent-strong: #f7b3cf; --accent-soft: #2a1820; }
:root[data-theme="dark"][data-palette="rosa"]     { --accent: #e0559a; --accent-ink: #ffffff; --accent-strong: #ff8cc0; --accent-soft: #3d2131; }
:root[data-theme="dark"][data-palette="lila"]     { --accent: #cdb8fa; --accent-ink: #1a1030; --accent-strong: #cdb8fa; --accent-soft: #221a33; }
:root[data-theme="dark"][data-palette="azul"]     { --accent: #aecbf8; --accent-ink: #0d1a2e; --accent-strong: #aecbf8; --accent-soft: #16202f; }
:root[data-theme="dark"][data-palette="turquesa"] { --accent: #a3e6dd; --accent-ink: #0b2622; --accent-strong: #a3e6dd; --accent-soft: #132826; }

/* =====================================================================
   BASE
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; text-wrap: balance; }
h3 { font-size: 14.5px; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .amount, td.num { font-variant-numeric: tabular-nums; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.muted { color: var(--muted); }
.pos, .up { color: var(--pos); }
.neg, .down { color: var(--neg); }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 6px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent); position: relative; flex: none;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; left: 7px; height: 3px; border-radius: 2px; background: var(--accent-ink);
}
.brand-mark::before { top: 11px; right: 7px; }
.brand-mark::after { top: 17px; right: 12px; }
.brand-lg { font-size: 20px; padding: 0; }
.brand-lg .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.brand-lg .brand-mark::before { top: 13px; left: 9px; right: 9px; }
.brand-lg .brand-mark::after { top: 20px; left: 9px; right: 15px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 8px 13px; font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: background .15s, border-color .15s, filter .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.05); }
.btn-light { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-light:hover { background: var(--text); filter: brightness(.92); }
.btn-danger { color: var(--neg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; padding: 11px; }
.btn svg { width: 16px; height: 16px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.link-btn { background: none; border: 0; color: var(--accent-strong); font-weight: 600; cursor: pointer; padding: 4px 0; font-size: 13px; }
.theme-btn { border: 1px solid var(--border-strong); background: var(--surface); width: 40px; height: 40px; border-radius: 11px; }
.theme-btn svg { width: 18px; height: 18px; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input:disabled { color: var(--muted); background: var(--surface-2); }
.field input[type="color"] { padding: 4px; height: 40px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-msg { margin: 0; font-size: 13px; color: var(--neg); }
.form-msg.ok { color: var(--pos); }
.form-msg:empty { display: none; }
.form-hint { margin: 0; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.form-hint:empty { display: none; }
.amount-input { font-size: 22px !important; font-weight: 700; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px;
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: block; text-align: center; padding: 7px 8px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent-strong); }
.segmented input[value="ingreso"]:checked + span { color: var(--pos); }
.segmented input[value="gasto"]:checked + span { color: var(--neg); }
.segmented input[value="transferencia"]:checked + span { color: var(--transfer); }

/* =====================================================================
   ACCESO
   ===================================================================== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  position: relative; width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 30px 26px; display: grid; gap: 18px;
}
.auth-theme { position: absolute; top: 16px; right: 16px; }
.auth-lead { margin: -6px 0 0; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.tab { background: none; border: 0; padding: 10px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.is-active { color: var(--text); border-color: var(--text); }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 11px 13px; border-radius: 10px; font-size: 13px; }

/* =====================================================================
   ESTRUCTURA
   ===================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px 16px; border-right: 1px solid var(--border); background: var(--sidebar-bg);
}
.sidebar .brand { margin-bottom: 18px; }
.nav-label { margin: 14px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; width: 100%;
  color: var(--muted); font-weight: 500; font-size: 14.5px; background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.nav-pill { margin-left: auto; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border-strong); color: var(--text); }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.user-meta { display: grid; min-width: 0; line-height: 1.3; }
.user-meta strong, .user-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--muted); font-size: 12px; }

.main { min-width: 0; padding: 26px 28px 48px; overflow-x: clip; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar-title { display: grid; gap: 2px; min-width: 0; }
.eyebrow { margin: 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .theme-btn { display: none; }
.pill { display: inline-flex; align-items: center; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.pill-demo { background: var(--warn-bg); color: var(--warn-ink); }
.view { display: grid; gap: 16px; }
.bottomnav { display: none; }
.only-sm { display: none; }

/* =====================================================================
   COMPONENTES
   ===================================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head small, .card-sub { color: var(--muted); font-size: 12.5px; }
.card-title { display: grid; gap: 3px; }
.grid { display: grid; gap: 16px; }
.grid-main { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title h3 { font-size: 15px; }
.span-all { grid-column: 1 / -1; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

/* Barra de dinero disponible */
.money-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 22px 22px; }
.money-label { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.money-label .dot { background: var(--pos-fill); width: 10px; height: 10px; }
.money-right { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.money-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.money-sub { color: var(--muted); font-size: 12.5px; }

/* Tarjetas de cifras */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-value { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.is-hero { border-color: var(--accent); }
.kpi.is-hero .kpi-label { color: var(--accent-strong); font-weight: 600; }

/* Pestañas subrayadas */
.subtabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.subtab { border: 0; background: none; padding: 11px 16px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtab:hover { color: var(--text); }
.subtab.is-active { color: var(--text); border-color: var(--text); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .spacer { flex: 1; }
.month-nav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px; padding: 3px; }
.month-nav strong { min-width: 140px; text-align: center; font-size: 14px; font-weight: 600; }
.toolbar .input { width: auto; padding: 8px 10px; }
.toolbar .search { min-width: 180px; flex: 1; max-width: 260px; }

/* Gráficas */
.chart-box { position: relative; height: 170px; }
.chart-box.sm { height: 150px; }
.big-figure { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: -4px 0 6px; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.donut-wrap { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 22px; align-items: center; }
.donut { position: relative; width: 128px; height: 128px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center small { color: var(--muted); font-size: 11px; }
.donut-center b { font-size: 13px; font-variant-numeric: tabular-nums; }
.donut-legend { display: grid; gap: 11px; font-size: 13px; }
.donut-legend > div { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Barras horizontales */
.bars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) auto; align-items: center; gap: 12px; font-size: 13px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-row { display: grid; gap: 5px; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.bar-top > span:first-child { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }

/* Estados en píldora */
.st-ok    { background: var(--pos-soft); color: var(--pos); }
.st-warn  { background: var(--warn-bg); color: var(--warn-ink); }
.st-bad   { background: var(--neg-soft); color: var(--neg); }
.st-acc   { background: var(--accent-soft); color: var(--accent-strong); }
.st-line  { border: 1px solid currentColor; background: transparent; }

/* Listas de movimientos (celular) */
.tx-list { display: grid; }
.tx {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); background: none; width: 100%; color: inherit; text-align: left; cursor: pointer;
}
.tx:last-child { border-bottom: 0; }
.tx-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.tx-icon svg { width: 15px; height: 15px; }
.tx-icon.ingreso { background: var(--pos-soft); color: var(--pos); }
.tx-icon.gasto { background: var(--neg-soft); color: var(--neg); }
.tx-icon.transferencia { background: var(--accent-soft); color: var(--accent-strong); }
.tx-main { min-width: 0; }
.tx-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tx-main small { color: var(--muted); }
.amount { font-weight: 600; white-space: nowrap; }
.amount.ingreso { color: var(--pos); }
.amount.gasto { color: var(--neg); }
.amount.transferencia { color: var(--text); }

/* Tabla */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
td.desc { white-space: normal; min-width: 170px; }
td small { color: var(--muted); display: block; font-size: 12px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; width: 100%; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* Cuentas y metas */
.acct, .goal { display: grid; gap: 12px; align-content: start; }
.acct-top, .goal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.acct-type { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 6px; }
.acct-balance, .goal-amount { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.acct-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12.5px; color: var(--muted); }
.acct-stats b { display: block; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; transition: width .4s; }
.goal-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.goal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.goal-mini { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.goal-mini:last-child { border-bottom: 0; }

.list-plain { display: grid; }
.list-plain .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); background: none; color: inherit; width: 100%; text-align: left; }
.list-plain .item:last-child { border-bottom: 0; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.soon { display: grid; justify-items: center; gap: 6px; padding: 56px 20px; }
.soon-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 6px; }
.soon-icon svg { width: 24px; height: 24px; }

/* Plan de pago */
.plan-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; font-size: 13.5px; border: 1px solid transparent; }
.plan-banner.info { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--border); }
.plan-banner.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-border); }
.plan-banner.bad  { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-border); }
.plan-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.plan-facts > div { display: grid; gap: 2px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.plan-facts span { font-size: 12px; color: var(--muted); }
.plan-facts b { font-size: 16px; font-variant-numeric: tabular-nums; }
.pay-box { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; }
.pay-box p { margin: 6px 0 0; }
.contact-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Ayuda plegable */
.help { color: var(--muted); font-size: 13px; }
.help summary { cursor: pointer; width: fit-content; }
.help p { margin: 8px 0 0; max-width: 70ch; }

/* ---------- Modal ---------- */
.modal { border: 1px solid var(--border); border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
.modal::backdrop { background: var(--backdrop); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 16px 20px 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-actions .spacer { flex: 1; }

/* ---------- Toast y carga ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--neg-fill); color: #fff; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 40; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
  .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .topbar .theme-btn { display: inline-grid; }
  h1 { font-size: 21px; }
  #quick-add span { display: none; }
  #quick-add { position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 20; width: 52px; height: 52px; border-radius: 16px; padding: 0; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
  #quick-add svg { width: 22px; height: 22px; }
  .kpis, .view .kpis[style] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 18px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  .money-bar { padding: 18px 16px; }
  .money-value { font-size: 24px; }
  .table-wrap { margin: 0 -16px; }
  th:first-child, td:first-child { padding-left: 16px; }
  .hide-sm { display: none !important; }
  .only-sm { display: block; }
  .toolbar .search { max-width: none; min-width: 0; flex-basis: 100%; }
  .toolbar .input { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .toolbar .month-nav { flex: 1 1 100%; justify-content: space-between; }
  .month-nav strong { min-width: 120px; }
  .form-row { grid-template-columns: 1fr; }
  .plan-facts { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: 112px minmax(0, 1fr); gap: 16px; }
  .donut { width: 112px; height: 112px; }
  .wallet-actions { width: 100%; }
  .wallet-actions .btn { flex: 1 1 auto; }
  .wallet-actions [data-act="tx"] { display: none; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--sidebar-bg); border-top: 1px solid var(--border);
    padding: 6px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
  }
  .bottomnav .nav-item { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 2px; justify-content: center; align-items: center; text-align: center; border-radius: 10px; }
  .bottomnav .nav-item.is-active { background: none; color: var(--accent-strong); }
}
