/* Brújula — app de finanzas. Diseño: libreta contable moderna, verde billete + dorado de ahorro.
   Layout: barra lateral fija (escritorio) / cajón + botón flotante (móvil); contenido en rejilla de tarjetas. */
:root {
  --bg: #F2F5F3;
  --surface: #FFFFFF;
  --surface-2: #E9EFEC;
  --line: #D6E0DB;
  --fg: #13201C;
  --muted: #5A6B64;
  --accent: #0B6E5B;
  --accent-ink: #FFFFFF;
  --accent-soft: #D5EDE5;
  --gold: #A86A12;
  --gold-soft: #F5E8D0;
  --good: #1D7F47;
  --good-soft: #DCF1E3;
  --bad: #B93A26;
  --bad-soft: #F7DFD9;
  --info: #2A63A8;
  --info-soft: #DCE8F6;
  --shadow: 0 1px 2px rgba(15, 40, 32, .06), 0 6px 20px rgba(15, 40, 32, .06);
  --overlay: rgba(10, 22, 18, .45);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 14px;
  --r-s: 9px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1412; --surface: #141D1A; --surface-2: #1B2623; --line: #273530;
    --fg: #E6EEEA; --muted: #93A49D; --accent: #3BB797; --accent-ink: #04130E; --accent-soft: #15342B;
    --gold: #E2AA4C; --gold-soft: #382A12; --good: #4FC383; --good-soft: #143322; --bad: #F07A63; --bad-soft: #3B1C16;
    --info: #74A9EA; --info-soft: #172A40; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --overlay: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1412; --surface: #141D1A; --surface-2: #1B2623; --line: #273530;
  --fg: #E6EEEA; --muted: #93A49D; --accent: #3BB797; --accent-ink: #04130E; --accent-soft: #15342B;
  --gold: #E2AA4C; --gold-soft: #382A12; --good: #4FC383; --good-soft: #143322; --bad: #F07A63; --bad-soft: #3B1C16;
  --info: #74A9EA; --info-soft: #172A40; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --overlay: rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.15; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.tiny { font-size: .74rem; }
.eyebrow { font-family: var(--f-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .gold { color: var(--gold); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex-shrink: 0; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100%; }
.side {
  position: sticky; top: env(safe-area-inset-top, 0px); height: calc(100vh - env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 18px; padding: 22px 14px 16px max(14px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand b { font-family: var(--f-display); font-size: 1.25rem; letter-spacing: -.02em; display: block; line-height: 1; }
.brand span { font-size: .72rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sec { padding: 12px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-s);
  color: var(--fg); text-decoration: none; font-weight: 500; font-size: .94rem;
}
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .cnt { margin-left: auto; font-size: .72rem; background: var(--surface-2); color: var(--muted); padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.perfil-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-s); background: var(--surface-2); border: 0; text-align: left; cursor: pointer; width: 100%; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: var(--gold-soft); color: var(--gold); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-block: 14px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.top h1 { margin-right: auto; }
.menu-btn { display: none; }
.content { padding-block: 8px 110px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; max-width: 1280px; width: 100%; }
.view-in { animation: viewIn .28s ease both; }
@keyframes viewIn { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Componentes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: .9rem; white-space: nowrap; transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.pri:hover { filter: brightness(1.08); }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: .82rem; border-radius: 8px; }
.btn.icon { padding: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h2 { margin-right: auto; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { margin-left: auto; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .v { font-family: var(--f-display); font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.1; }
.kpi .s { font-size: .8rem; color: var(--muted); }
.kpi.hero { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.kpi.hero .eyebrow, .kpi.hero .s { color: color-mix(in srgb, var(--accent-ink) 78%, transparent); }
.kpi.hero.neg { background: var(--bad); border-color: var(--bad); color: #fff; }
.kpi.hero.neg .eyebrow, .kpi.hero.neg .s { color: rgba(255,255,255,.82); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.periodo { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.periodo .lbl { padding: 0 8px; font-weight: 600; font-size: .86rem; min-width: 120px; text-align: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); width: 0; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.bar.gold > i { background: var(--gold); } .bar.bad > i { background: var(--bad); } .bar.warn > i { background: var(--gold); }
.bar.lg { height: 12px; }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li.click { cursor: pointer; border-radius: 8px; padding-inline: 8px; }
.li.click:hover { background: var(--surface-2); }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty svg { color: var(--accent); opacity: .7; }

/* Insights */
.tip { display: flex; gap: 12px; padding: 12px 14px; border-radius: 11px; background: var(--surface-2); align-items: flex-start; }
.tip .ti { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.tip.alerta .ti { background: var(--bad-soft); color: var(--bad); }
.tip.aviso .ti { background: var(--gold-soft); color: var(--gold); }
.tip.bien .ti { background: var(--good-soft); color: var(--good); }
.tip.idea .ti { background: var(--info-soft); color: var(--info); }
.tip b { display: block; font-size: .92rem; }
.tip p { font-size: .85rem; color: var(--muted); }

/* Gráficos */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 190px; position: relative; padding-left: 52px; padding-bottom: 24px; }
.bars .grid-l { position: absolute; left: 52px; right: 0; border-top: 1px dashed var(--line); }
.bars .grid-l span { position: absolute; left: -52px; top: -9px; width: 46px; text-align: right; font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; position: relative; z-index: 1; cursor: default; }
.bars .col i { width: min(22px, 38%); border-radius: 6px 6px 2px 2px; background: var(--accent); height: 0; transition: height .8s cubic-bezier(.2,.8,.2,1); }
.bars .col i.g { background: var(--gold); }
.bars .col i.cur { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px currentColor; }
.bars .col .x { position: absolute; bottom: -22px; font-size: .72rem; color: var(--muted); }
.bars .col.on .x { color: var(--fg); font-weight: 700; }
.bars .col:hover .tt { opacity: 1; transform: translate(-50%, -4px); }
.tt { position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, 0); background: var(--fg); color: var(--bg); padding: 6px 9px; border-radius: 8px; font-size: .74rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: .15s; z-index: 5; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { position: relative; width: 168px; height: 168px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { transition: stroke-dasharray .9s cubic-bezier(.2,.8,.2,1); }
.donut .c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut .c b { font-family: var(--f-display); font-size: 1.15rem; }
.donut-leg { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 7px; }
.donut-leg .r { display: flex; align-items: center; gap: 8px; font-size: .86rem; }
.donut-leg .r .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gauge { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge .c b { font-family: var(--f-display); font-size: 2.3rem; line-height: 1; }

/* Metas */
.meta-card { gap: 12px; }
.meta-top { display: flex; gap: 12px; align-items: center; }
.ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: .82rem; }

/* Kanban / notas */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.kcol h3 { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: transform .12s, box-shadow .15s; }
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.notas { columns: 3 260px; column-gap: 14px; }
.nota { break-inside: avoid; margin-bottom: 14px; border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); transition: transform .12s, box-shadow .15s; }
.nota:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.nota p { white-space: pre-wrap; font-size: .9rem; overflow-wrap: anywhere; }
.nota.c-gold { background: var(--gold-soft); border-color: transparent; }
.nota.c-acc { background: var(--accent-soft); border-color: transparent; }
.nota.c-info { background: var(--info-soft); border-color: transparent; }
.nota.c-bad { background: var(--bad-soft); border-color: transparent; }

/* Movimientos */
.day-h { display: flex; justify-content: space-between; padding: 14px 4px 4px; font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; flex: 1; min-width: 180px; }
.search input { border: 0; background: none; padding: 9px 0; outline: none; width: 100%; }

/* Formularios */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.f input, .f select, .f textarea, .inp {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.f input:focus, .f select:focus, .f textarea:focus, .inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f textarea { min-height: 90px; resize: vertical; }
.f .hint { font-size: .74rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.amount-in { font-family: var(--f-display); font-size: 2rem !important; font-weight: 700; padding: 10px 14px !important; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 11px; border-radius: 99px; cursor: pointer; font-size: .84rem; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tipo-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tipo-seg button { border: 0; padding: 9px; border-radius: 9px; background: transparent; font-weight: 700; cursor: pointer; color: var(--muted); }
.tipo-seg button.on.gasto { background: var(--bad); color: #fff; }
.tipo-seg button.on.ingreso { background: var(--good); color: #fff; }
.tipo-seg button.on.transferencia { background: var(--info); color: #fff; }

/* Modal */
#capa { position: fixed; inset: 0; z-index: 100; display: none; }
#capa.on { display: block; }
.ov { position: absolute; inset: 0; background: var(--overlay); animation: fade .2s ease; }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 40px); overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column; animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { width: min(760px, calc(100% - 24px)); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-h h2 { margin-right: auto; font-size: 1.2rem; }
.modal-b { padding: 12px 20px 8px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 18px; flex-wrap: wrap; }
.modal-f .left { margin-right: auto; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; z-index: 120; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--fg); color: var(--bg); padding: 11px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); animation: up .25s ease; font-size: .9rem; width: 100%; }
.toast button { margin-left: auto; background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; filter: brightness(1.4); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } }

.fab {
  position: fixed; z-index: 30; right: calc(24px + env(safe-area-inset-right, 0px)); bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 20px; border-radius: 99px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .15s;
}
.fab:hover { transform: translateY(-2px); }
.fab kbd { font-family: var(--f-mono); font-size: .7rem; opacity: .7; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; }

.banner { background: var(--gold-soft); color: var(--fg); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-size: .88rem; flex-wrap: wrap; }

/* Onboarding */
.onb { min-height: 100%; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.onb-card { width: min(720px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 30px; display: flex; flex-direction: column; gap: 22px; box-shadow: var(--shadow); }
.onb-card h1 { font-size: 2rem; }
.steps { display: flex; gap: 6px; }
.steps i { height: 4px; flex: 1; border-radius: 99px; background: var(--surface-2); }
.steps i.on { background: var(--accent); }
.modos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modo { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; background: var(--surface); text-align: left; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .12s; }
.modo:hover { transform: translateY(-2px); }
.modo.on { border-color: var(--accent); background: var(--accent-soft); }
.modo b { font-family: var(--f-display); font-size: 1.05rem; }
.modo span { font-size: .84rem; color: var(--muted); }
.modo svg { color: var(--accent); }

/* Aprende */
.lec { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.lec-h { display: flex; gap: 14px; align-items: center; padding: 14px 16px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
.lec-n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--f-mono); font-size: .8rem; background: var(--surface-2); flex-shrink: 0; }
.lec.done .lec-n { background: var(--good); color: #fff; }
.lec-b { padding: 0 16px 18px 64px; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.lec-b p, .lec-b li { font-size: .93rem; line-height: 1.6; }
.lec-b ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.reto { background: var(--gold-soft); border-radius: 11px; padding: 12px 14px; font-size: .9rem; }
.calc-out { background: var(--surface-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.calc-out .big { font-family: var(--f-display); font-size: 1.6rem; font-weight: 700; }
.area-chart { width: 100%; height: 160px; display: block; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.t td.r, table.t th.r { text-align: right; }

.split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.split > div { background: var(--surface-2); border-radius: 11px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }

/* Calendario */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-h { text-align: center; font-family: var(--f-mono); font-size: .7rem; color: var(--muted); padding-bottom: 2px; }
.cal-c { min-height: 84px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 7px 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; cursor: pointer; text-align: left; min-width: 0; transition: border-color .15s, transform .12s; }
.cal-c:hover { border-color: var(--accent); }
.cal-c.fuera { border: 0; background: none; cursor: default; }
.cal-c.futuro { background: var(--surface-2); border-color: transparent; }
.cal-c.vacio { border-style: dashed; border-color: var(--gold); }
.cal-c.hoy .cal-n { background: var(--accent); color: var(--accent-ink); }
.cal-c.sel { border: 2px solid var(--accent); padding: 6px 7px; background: var(--accent-soft); }
.cal-n { font-weight: 700; font-size: .85rem; min-width: 24px; height: 24px; border-radius: 99px; display: grid; place-items: center; margin: -2px 0 2px -4px; }
.cal-v { font-size: .7rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-dots { display: flex; gap: 3px; margin-top: auto; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; }

/* Bienvenida */
.hola { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 22px; background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.hola-izq { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.hola-t { font-size: 1.5rem; }
.hola-reloj { font-family: var(--f-display); font-size: 2.6rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; color: var(--accent); }
.hola-der { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.rec { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 9px; }
.rec .t { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec.hecho .t { text-decoration: line-through; color: var(--muted); }
.rec-chk { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; color: #fff; padding: 0; }
.rec.hecho .rec-chk { background: var(--good); border-color: var(--good); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3, .hola { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 90; left: 0; top: 0; bottom: 0; height: auto; width: 280px; transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow); padding-top: calc(22px + env(safe-area-inset-top, 0px)); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 85; background: var(--overlay); }
  .menu-btn { display: inline-flex; }
  .top, .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .fab kbd { display: none; }
  .fab { right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .kpi .v { font-size: 1.25rem; }
  .kpi { padding: 13px 14px; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .modos { grid-template-columns: minmax(0, 1fr); }
  .onb-card { padding: 20px; }
  .lec-b { padding-left: 16px; }
  .periodo .lbl { min-width: 0; font-size: .8rem; flex: 1; }
  .top > [data-act="tema-rapido"] { order: 2; }
  .top .seg { order: 3; width: 100%; } .top .seg button { flex: 1; padding-inline: 4px; }
  .top .periodo { order: 4; width: 100%; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .cal { gap: 3px; } .cal-c { min-height: 52px; padding: 5px; border-radius: 8px; } .cal-c.sel { padding: 4px; } .cal-v { display: none; } .cal-n { margin: 0; font-size: .8rem; }
  .hola-reloj { font-size: 2.1rem; }
  .modal { top: auto; bottom: 0; transform: translateX(-50%); width: 100%; border-radius: 18px 18px 0 0; max-height: 92%; animation: sheet .25s ease; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bars { padding-left: 44px; } .bars .grid-l { left: 44px; } .bars .grid-l span { left: -44px; width: 40px; }
  .card { padding: 15px; }
}
@keyframes sheet { from { transform: translate(-50%, 30px); opacity: 0; } }
.quieto *, .quieto { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
