*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ── Estructura: celular = contenido + barra inferior; computadora = menú lateral ── */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.main { max-width: 480px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) var(--gutter) 128px; }

.bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 456px; margin: 0 auto; height: 72px;
  background: var(--nav); border: 1px solid rgba(226, 184, 87, 0.18); border-radius: 24px;
  display: flex; align-items: center; justify-content: space-around; padding: 0 8px; z-index: 20;
}
.bottom-nav a {
  width: 60px; height: 54px; border-radius: 14px; color: var(--nav-idle);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; font-weight: 700;
}
.bottom-nav a[aria-current="page"] { background: var(--nav-on); color: var(--gold); }
.bottom-nav .plus { width: 52px; height: 52px; border-radius: 18px; background: var(--gold); color: var(--on-gold); }
.bottom-nav .plus svg.ico { width: 24px; height: 24px; stroke-width: 2.4; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh;
    background: #0F172A; color: #F8FAFC; padding: 24px 16px; border-right: 1px solid #1E293B;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: var(--font-title); font-weight: 700; font-size: var(--fs-17); }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--gold); color: var(--on-gold); display: flex; align-items: center; justify-content: center; }
  .side-menu { display: flex; flex-direction: column; gap: 4px; }
  .side-menu a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: #94A3B8; font-weight: 600; }
  .side-menu a[aria-current="page"] { background: rgba(226, 184, 87, 0.12); color: var(--gold); }
  .side-menu a.soon { opacity: 0.55; }
  .side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid #1E293B; }
  .side-user small { display: block; color: #94A3B8; font-size: var(--fs-12); }
  .main { max-width: 1160px; padding: 32px 40px 48px; }
  .bottom-nav { display: none; }
  .fab-desktop { display: inline-flex !important; }
}

/* ── Encabezado ── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.top .kicker { font-size: var(--fs-13); color: var(--muted); }
.top h1 { margin: 2px 0 0; font-family: var(--font-title); font-size: var(--fs-20); font-weight: 700; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); position: relative;
}
.fab-desktop { display: none; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 14px; border: none; background: var(--gold); color: var(--on-gold); font-weight: 700; }

/* ── Bloques ── */
.stack { display: flex; flex-direction: column; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card h2 { margin: 0; font-size: var(--fs-16); font-weight: 700; }
.label { font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.6px; color: var(--muted); text-transform: uppercase; }
.amount { font-size: var(--fs-20); font-weight: 700; }
.sub { font-size: var(--fs-12); color: var(--muted); line-height: 1.45; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.hero {
  position: relative; overflow: hidden; background: var(--hero); border: 1px solid var(--hero-border);
  border-radius: var(--radius-lg); padding: 22px; color: #FFFFFF; display: flex; flex-direction: column; gap: 14px;
}
.hero::before {
  content: ""; position: absolute; right: -60px; top: -70px; width: 220px; height: 220px;
  border-radius: 50%; border: 36px solid var(--ring); pointer-events: none;
}
.hero > * { position: relative; }
.hero .hero-label { font-size: var(--fs-13); color: var(--hero-muted); font-weight: 500; }
.hero .big { display: flex; align-items: baseline; gap: 6px; }
.hero .big span:first-child { font-size: var(--fs-20); font-weight: 600; color: var(--hero-muted); }
.hero .big strong { font-size: var(--fs-40); font-weight: 700; letter-spacing: -1px; }
.bar { height: 8px; border-radius: 4px; background: var(--hero-inner); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--gold); }
.hero .tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hero .tile { background: var(--hero-inner); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.hero .tile span { font-size: var(--fs-12); color: var(--hero-muted); }
.hero .tile strong { font-size: var(--fs-17); font-weight: 600; }
.hero .tile strong.inc { color: #6EE7B7; }

.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.actions a { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: var(--fs-12); font-weight: 600; text-align: center; }
.actions a span.sq { width: 56px; height: 56px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }

.badge { align-self: flex-start; font-size: var(--fs-11); font-weight: 700; color: var(--warn-fg); background: var(--warn-bg); padding: 3px 9px; border-radius: 999px; }

.director { display: flex; align-items: center; gap: 12px; background: var(--hero); border: 1px solid var(--hero-border); border-radius: var(--radius); padding: 14px; color: #FFFFFF; }
.director .spark { width: 40px; height: 40px; border-radius: 13px; background: var(--gold); color: var(--on-gold); display: flex; align-items: center; justify-content: center; }
.director small { display: block; color: var(--hero-muted); font-size: var(--fs-12); }

/* Personas */
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--m, var(--m-hogar)); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-13); font-weight: 700; flex-shrink: 0; }
.persona { display: flex; align-items: center; gap: 12px; }
.persona .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.track { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 3px; background: var(--m, var(--m-hogar)); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: var(--fs-13); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--pill-on); border-color: var(--pill-on); color: var(--pill-on-ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--m, transparent); }

/* Movimientos */
.tx-list { padding: 4px 16px; }
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: none; }
.tx .ic { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.tx .who { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--m, var(--m-hogar)); color: var(--ink); font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.tx .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx .txt b { font-size: var(--fs-14); }
.tx .amt { font-weight: 600; white-space: nowrap; }
.tx .amt.in { color: var(--pos); }
.day { display: flex; justify-content: space-between; padding: 0 4px; font-size: var(--fs-13); font-weight: 700; color: var(--muted); }

.t-in   { background: #D1FAE5; color: #047857; }
.t-cart { background: #FFF1DF; color: #9A5B12; }
.t-bolt { background: #ECEAFE; color: #4B3FC4; }
.t-food { background: #FDE7E1; color: #A5402A; }
.t-edu  { background: #E3F2FC; color: #1D5F8A; }
:root[data-theme="dark"] .t-in   { background: #0B3B2E; color: #6EE7B7; }
:root[data-theme="dark"] .t-cart { background: #3A2A12; color: #F6C27E; }
:root[data-theme="dark"] .t-bolt { background: #26214D; color: #B3A8FF; }
:root[data-theme="dark"] .t-food { background: #3D1F17; color: #F59B7C; }
:root[data-theme="dark"] .t-edu  { background: #12304A; color: #8FD3FF; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .t-in   { background: #0B3B2E; color: #6EE7B7; }
  :root:not([data-theme="light"]) .t-cart { background: #3A2A12; color: #F6C27E; }
  :root:not([data-theme="light"]) .t-bolt { background: #26214D; color: #B3A8FF; }
  :root:not([data-theme="light"]) .t-food { background: #3D1F17; color: #F59B7C; }
  :root:not([data-theme="light"]) .t-edu  { background: #12304A; color: #8FD3FF; }
}

/* Gráfico de barras */
.bars { display: flex; align-items: flex-end; justify-content: space-between; height: 150px; border-bottom: 1px dashed var(--line); padding: 0 4px; }
.bars .g { flex: 1; display: flex; justify-content: center; align-items: flex-end; gap: 3px; height: 140px; }
.bars .g i { width: 18px; border-radius: 6px 6px 2px 2px; }
.bars .g i.inc { background: var(--inc); }
.bars .g i.exp { background: var(--exp); }
.bar-labels { display: flex; justify-content: space-between; padding: 6px 4px 0; font-size: var(--fs-11); color: var(--muted); font-weight: 600; }
.bar-labels span { flex: 1; text-align: center; }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: var(--fs-16); margin-bottom: 6px; }

.demo-note { font-size: var(--fs-12); color: var(--muted); text-align: center; margin-top: 8px; }

@media (min-width: 960px) {
  .inicio-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: start; }
}

@media (prefers-reduced-motion: no-preference) {
  .main { animation: entrar 0.18s ease-out; }
  @keyframes entrar { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* Campos de formulario */
.campo { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); font: inherit; font-size: var(--fs-16); }
.campo:focus { border-color: var(--gold); outline: none; }
