/* Gestión personal — estilos. Tema claro/oscuro con variables; en celular la navegación va abajo, en pantallas grandes a la izquierda. */
:root {
  --bg: #f4f7f2; --surf: #ffffff; --surf2: #ecf2ea; --txt: #17231b; --mut: #617066; --line: #dde6d9;
  --pri: #2f7d5b; --pri-ink: #ffffff; --pri-soft: #e0f0e6; --pri-fuerte: #1f5a40;
  --ok: #15803d; --ok-soft: #dcf5e4; --mal: #c62828; --mal-soft: #fde4e4; --aviso: #b45309; --aviso-soft: #fdefd3;
  --sombra: 0 1px 2px rgba(16, 32, 40, .06), 0 4px 14px rgba(16, 32, 40, .05);
  --r: 14px; --nav-h: 62px; --nav-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #0d1410; --surf: #151e18; --surf2: #1d2920; --txt: #e5efe8; --mut: #92a698; --line: #293829;
    --pri: #7fd1a0; --pri-ink: #0b2819; --pri-soft: #17301f; --pri-fuerte: #a7e3c0;
    --ok: #4ade80; --ok-soft: #12301d; --mal: #f87171; --mal-soft: #3a1b1b; --aviso: #fbbf24; --aviso-soft: #35290f;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-tema="oscuro"] {
  --bg: #0d1410; --surf: #151e18; --surf2: #1d2920; --txt: #e5efe8; --mut: #92a698; --line: #293829;
  --pri: #7fd1a0; --pri-ink: #0b2819; --pri-soft: #17301f; --pri-fuerte: #a7e3c0;
  --ok: #4ade80; --ok-soft: #12301d; --mal: #f87171; --mal-soft: #3a1b1b; --aviso: #fbbf24; --aviso-soft: #35290f;
  --sombra: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--txt); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--pri); }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.mini { width: 13px; height: 13px; stroke-width: 2.2; }
@keyframes gira { to { transform: rotate(360deg); } }
.girando { animation: gira 1s linear infinite; }
.oculto { display: none !important; }
.mut { color: var(--mut); }
.peq { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.der { text-align: right; }
.ok { color: var(--ok); } .mal { color: var(--mal); }

/* ---------- Estructura ---------- */
#app { min-height: 100vh; display: flex; flex-direction: column; }
#col { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
#top h1 { flex: 1; font-size: 20px; letter-spacing: -.01em; }
#top .marca { display: none; }
#main { width: 100%; max-width: 980px; margin: 0 auto; padding: 16px 16px 96px; outline: none; }

#nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--surf); border-top: 1px solid var(--line); }
#nav .marca { display: none; }
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; font-weight: 500; color: var(--mut); text-decoration: none; min-width: 0; }
#nav a.act { color: var(--pri); }
#nav a.act svg { stroke-width: 2.2; }
#nav .pie { display: none; }

/* Tablet (700–1023 px): riel lateral compacto de íconos con su nombre debajo */
@media (min-width: 700px) {
  #app { flex-direction: row; }
  #nav { position: sticky; top: 0; height: 100vh; width: 84px; flex: none; flex-direction: column; padding: 16px 8px; gap: 6px; border-top: 0; border-right: 1px solid var(--line); }
  #nav .marca { display: flex; justify-content: center; padding: 2px 0 12px; }
  #nav .marca .logo { width: 38px; height: 38px; flex: none; }
  #nav .marca-t { display: none; }
  #nav a { flex: none; padding: 10px 2px; font-size: 11px; border-radius: 14px; }
  #nav a:hover { background: var(--surf2); }
  #nav a.act { background: var(--pri-soft); color: var(--pri-fuerte); }
  #col { padding-bottom: 0; }
  #top { padding-top: 14px; }
  #main { padding: 22px 26px 60px; }
}
/* Pantalla grande (≥1024 px): barra lateral completa */
@media (min-width: 1024px) {
  #nav { width: var(--nav-w); padding: 18px 12px; gap: 4px; }
  #nav .marca { display: flex; justify-content: flex-start; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
  #nav .marca .logo { width: 30px; height: 30px; }
  #nav .marca-t { display: inline; }
  #nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; font-size: 15px; border-radius: 10px; }
  #nav .pie { display: block; margin-top: auto; padding: 10px; font-size: 12px; color: var(--mut); }
  #main { padding: 22px 28px 60px; }
}

/* ---------- Tarjetas y listas ---------- */
.card { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--sombra); }
.card + .card, .card + .grid, .grid + .card, .seccion + .card { margin-top: 14px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.card .cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card .cab h3 { margin: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr; } .g3 { grid-template-columns: 1fr 1fr; } .g4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 700px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }
.titulo-sec { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 8px; }
.titulo-sec h2 { font-size: 17px; }
.titulo-sec:first-child { margin-top: 4px; }

.lista { list-style: none; margin: 0; padding: 0; }
.fila { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.fila:last-child { border-bottom: 0; }
.fila.tocable { cursor: pointer; }
.fila .cuerpo { flex: 1; min-width: 0; }
.fila .t { font-weight: 500; overflow-wrap: anywhere; }
.fila .s { font-size: 13px; color: var(--mut); overflow-wrap: anywhere; }
.fila .m { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.punto { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; flex: none; background: var(--surf2); }
.dia-cab { margin: 16px 2px 2px; font-size: 13px; font-weight: 600; color: var(--mut); display: flex; justify-content: space-between; }

/* KPIs */
.kpi { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--sombra); min-width: 0; }
.kpi .e { font-size: 12.5px; color: var(--mut); }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .p { font-size: 12.5px; margin-top: 2px; color: var(--mut); }
.kpi.grande { grid-column: 1 / -1; background: var(--pri); color: var(--pri-ink); border: 0; }
.kpi.grande .e, .kpi.grande .p { color: color-mix(in srgb, var(--pri-ink) 78%, transparent); }
.kpi.grande .v { font-size: 28px; }

/* Barras de progreso */
.barra { height: 8px; background: var(--surf2); border-radius: 99px; overflow: hidden; }
.barra > i { display: block; height: 100%; border-radius: 99px; background: var(--pri); min-width: 0; transition: width .25s; }
.barra.mal > i { background: var(--mal); } .barra.aviso > i { background: var(--aviso); } .barra.ok > i { background: var(--ok); }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surf); color: var(--txt); padding: 10px 16px; border-radius: 12px; font-weight: 600; min-height: 44px; text-decoration: none; }
.btn:hover { background: var(--surf2); }
.btn.pri { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.mal { color: var(--mal); }
.btn.sec { background: var(--pri-soft); color: var(--pri-fuerte); border-color: transparent; }
.btn.peq { min-height: 34px; padding: 5px 12px; font-size: 14px; border-radius: 10px; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icono-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; color: var(--mut); padding: 0; text-decoration: none; }
.icono-btn:hover { background: var(--surf2); color: var(--txt); }
.fab { position: fixed; z-index: 25; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--pri); color: var(--pri-ink); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.2; }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--surf2); border-radius: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--mut); white-space: nowrap; }
.seg button.act { background: var(--surf); color: var(--txt); box-shadow: var(--sombra); }
.subtabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--surf); border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--mut); text-decoration: none; }
.subtabs a.act { background: var(--pri); border-color: var(--pri); color: var(--pri-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: var(--surf2); font-size: 12.5px; font-weight: 500; color: var(--mut); white-space: nowrap; border: 0; }
button.chip.act { background: var(--pri-soft); color: var(--pri-fuerte); }
.chip.mal { background: var(--mal-soft); color: var(--mal); } .chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.aviso { background: var(--aviso-soft); color: var(--aviso); } .chip.pri { background: var(--pri-soft); color: var(--pri-fuerte); }

.selector-periodo { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.selector-periodo .nom { font-weight: 700; font-size: 18px; text-align: center; flex: 1; }
.selector-periodo .sub { display: block; font-size: 12px; font-weight: 400; color: var(--mut); }

/* Casillas redondas (pendientes, hábitos, fijos) */
.chk { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: grid; place-items: center; flex: none; padding: 0; color: transparent; transition: .12s; }
.chk svg { width: 16px; height: 16px; stroke-width: 3; }
.chk:hover { border-color: var(--pri); }
.chk.hecho { background: var(--pri); border-color: var(--pri); color: var(--pri-ink); }
.chk.grande { width: 42px; height: 42px; } .chk.grande svg { width: 22px; height: 22px; }
.chk.cuenta { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chk.cuenta:not(.hecho) { color: var(--mut); }
.chk.cuenta.parcial:not(.hecho) { border-color: var(--c); color: var(--c); }
.hab-menos { width: 32px; height: 32px; flex: none; }
.tachado { text-decoration: line-through; color: var(--mut); }

/* Formularios */
.campo { display: block; margin-bottom: 14px; }
.campo > span, .campo > .et { display: block; font-size: 13px; font-weight: 600; color: var(--mut); margin-bottom: 5px; }
.campo input, .campo select, .campo textarea, .buscador input, .inline-in { width: 100%; padding: 11px 12px; border: 1px solid var(--line); background: var(--surf); border-radius: 11px; min-height: 44px; outline: none; }
.campo textarea { min-height: 80px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .buscador input:focus, .inline-in:focus { border-color: var(--pri); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pri) 25%, transparent); }
.campo .ayuda { font-size: 12.5px; color: var(--mut); margin-top: 4px; }
.fila-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.campo.monto input { font-size: 24px; font-weight: 700; }
.buscador { position: relative; margin-bottom: 12px; }
.buscador input { padding-left: 38px; }
.buscador svg { position: absolute; left: 11px; top: 11px; width: 20px; height: 20px; color: var(--mut); }
.colores { display: flex; flex-wrap: wrap; gap: 8px; }
.colores label { cursor: pointer; }
.colores input { position: absolute; opacity: 0; pointer-events: none; }
.colores span { display: block; width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; outline: 2px solid transparent; }
.colores input:checked + span { border-color: var(--surf); outline-color: var(--txt); }
.dias-sem { display: flex; gap: 6px; }
.dias-sem label { flex: 1; cursor: pointer; }
.dias-sem input { position: absolute; opacity: 0; pointer-events: none; }
.dias-sem span { display: grid; place-items: center; height: 40px; border-radius: 10px; background: var(--surf2); font-weight: 600; font-size: 14px; color: var(--mut); }
.dias-sem input:checked + span { background: var(--pri); color: var(--pri-ink); }
.inline-in { min-height: 38px; padding: 7px 10px; text-align: right; max-width: 150px; }

/* Hoja (formularios y diálogos) */
dialog.hoja { border: 0; padding: 0; background: var(--surf); color: var(--txt); width: 100%; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, .3); overflow: hidden; }
dialog.hoja::backdrop { background: rgba(10, 18, 22, .5); }
dialog.hoja[open] { display: flex; flex-direction: column; animation: sube .18s ease-out; }
@keyframes sube { from { transform: translateY(40px); opacity: .4; } }
.hoja-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 6px 20px; }
.hoja-cab h2 { font-size: 18px; }
.hoja-cuerpo { padding: 8px 20px 20px; overflow-y: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.hoja-pie { display: flex; gap: 10px; margin-top: 8px; }
.hoja-pie .btn { flex: 1; }

#toast { position: fixed; z-index: 100; left: 50%; bottom: calc(var(--nav-h) + 90px); transform: translate(-50%, 20px); background: #1f2933; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14.5px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); display: flex; gap: 14px; align-items: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
#toast.ver { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: #5eead4; font-weight: 700; padding: 0; }
@media (min-width: 900px) { #toast { bottom: 30px; } }

/* Vacío y avisos */
.vacio { text-align: center; padding: 34px 18px; color: var(--mut); }
.vacio .g { font-size: 38px; margin-bottom: 8px; }
.vacio b { display: block; color: var(--txt); font-size: 16px; margin-bottom: 4px; }
.vacio .btn { margin-top: 14px; }
.aviso-caja { padding: 12px 14px; border-radius: 12px; background: var(--aviso-soft); color: var(--aviso); font-size: 14px; margin-bottom: 14px; }
.aviso-caja.mal { background: var(--mal-soft); color: var(--mal); }
.aviso-caja.ok { background: var(--ok-soft); color: var(--ok); }
.aviso-caja.pri { background: var(--pri-soft); color: var(--pri-fuerte); }

/* Gráficos */
.donut-caja { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut-caja svg { width: 170px; height: 170px; flex: none; }
.leyenda { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.leyenda div { display: flex; align-items: center; gap: 8px; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.leyenda b { margin-left: auto; font-variant-numeric: tabular-nums; }
.barras-svg { width: 100%; height: auto; display: block; }
.barras-svg text { fill: var(--mut); font-size: 11px; }
.calor { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.calor i { aspect-ratio: 1; min-width: 10px; border-radius: 3px; background: var(--surf2); display: block; }
.calor i.on { background: var(--pri); } .calor i.no { opacity: .35; } .calor i.nada { background: transparent; }
.semana-pts { display: flex; gap: 4px; }
.semana-pts i { width: 18px; height: 18px; border-radius: 6px; background: var(--surf2); display: grid; place-items: center; font-size: 10px; font-style: normal; color: var(--mut); }
.semana-pts i.on { background: var(--pri); color: var(--pri-ink); }
.semana-pts i.libre { opacity: .45; }
.semana-pts i.hoy { outline: 2px solid var(--txt); outline-offset: 1px; }
/* en pantallas angostas la tira de la semana va bajo el nombre para no apretarlo */
@media (max-width: 520px) {
  .fila:has(> .semana-pts) { flex-wrap: wrap; row-gap: 8px; }
  .fila > .semana-pts { order: 9; flex: 1 0 100%; padding-left: 56px; }
}
.racha { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 13px; color: var(--aviso); }

.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; font-size: 12.5px; color: var(--mut); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tabla td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.tabla .der { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; margin: 0 -4px; }
.separador { height: 1px; background: var(--line); margin: 14px 0; }
.pegado { position: sticky; top: 56px; z-index: 5; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { #nav, #top, .fab, #toast { display: none !important; } #col { padding: 0; } body { background: #fff; } }

/* Pantallas medianas y grandes: los formularios son una ventana centrada, no una hoja a todo el ancho.
   Va al final a propósito: las reglas base de .fab y dialog.hoja están más arriba y esta debe ganarles. */
@media (min-width: 700px) {
  dialog.hoja { margin: auto; width: min(540px, calc(100vw - 32px)); max-width: 540px; max-height: 88vh; border-radius: 20px; box-shadow: 0 24px 70px rgba(0, 0, 0, .4); }
  dialog.hoja[open] { animation: aparece .16s ease-out; }
  .hoja-cuerpo { padding-bottom: 22px; }
}
@media (min-width: 700px) { .fab { right: 28px; bottom: 26px; } #toast { bottom: 28px; } }
@keyframes aparece { from { transform: scale(.97); opacity: .4; } }

/* Selector de paletas (Ajustes) */
.paletas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.paleta { text-align: left; border: 2px solid var(--line); background: var(--surf); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.paleta:hover { border-color: var(--mut); }
.paleta.act { border-color: var(--pri); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pri) 25%, transparent); }
.paleta .muestra { display: flex; height: 44px; border-radius: 9px; overflow: hidden; border: 1px solid rgba(128, 128, 128, .25); }
.paleta .muestra i { flex: 1; display: block; }
.paleta .muestra i:last-child { flex: .8; }
.paleta b { font-size: 14px; }
.paleta small { display: block; font-size: 12px; color: var(--mut); line-height: 1.3; }

.color-propio { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 0; }
.color-propio > span { margin: 0; }
.color-propio input[type=color] { width: 64px; height: 44px; padding: 3px; border-radius: 10px; cursor: pointer; }

/* ===== Móvil y tablet: lo táctil primero ===== */
html { touch-action: manipulation; overscroll-behavior-y: none; }
button, a, .chip, .fila.tocable { -webkit-user-select: none; user-select: none; }
@media (pointer: coarse) {
  .chk { width: 32px; height: 32px; } .chk svg { width: 18px; height: 18px; }
  .chk.grande { width: 44px; height: 44px; } .chk.grande svg { width: 24px; height: 24px; }
  .icono-btn { width: 44px; height: 44px; }
  .btn.peq { min-height: 40px; padding: 6px 14px; }
  .subtabs a { padding: 10px 16px; }
  .fila { padding: 13px 0; }
  .seg button { padding: 11px 10px; }
  input, select, textarea { font-size: 16px; } /* evita el zoom automático de iOS al enfocar un campo */
  .inline-in { font-size: 16px; min-height: 42px; }
  .dias-sem span { height: 44px; }
}

/* Hoja de formularios: en celular sube desde abajo con un asa para arrastrarla hacia abajo */
dialog.hoja { max-height: calc(var(--vv, 100dvh) * .94); }
.hoja-cuerpo { overscroll-behavior: contain; }
@media (max-width: 699px) {
  .hoja-cab { position: relative; padding-top: 24px; touch-action: none; }
  .hoja-cab::before { content: ''; position: absolute; top: 9px; left: 50%; width: 42px; height: 5px; margin-left: -21px; border-radius: 99px; background: var(--line); }
}

/* En tablet y escritorio las tarjetas se reparten en dos columnas */
.cols > .card { margin-bottom: 14px; }
@media (min-width: 700px) {
  .cols { column-count: 2; column-gap: 14px; }
  .cols > .card, .cols > .aviso-caja, .cols > .titulo-sec, .cols > div { break-inside: avoid; margin-top: 0 !important; margin-bottom: 14px; }
}

/* Menú de agregar rápido (botón + de Hoy) */
.rapido { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rapido button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 8px; border-radius: 16px; border: 1px solid var(--line); background: var(--surf2); font-weight: 600; font-size: 15px; }
.rapido button:active { background: var(--pri-soft); }
.rapido .g { font-size: 28px; line-height: 1; }
@media (min-width: 700px) { .rapido { grid-template-columns: repeat(3, 1fr); } }
.rapido button:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 700px) { .rapido button:last-child:nth-child(odd) { grid-column: auto; } }

/* Estadísticas: interruptor y mapa de constancia */
.interruptor { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.interruptor input { -webkit-appearance: none; appearance: none; width: 48px; height: 28px; min-height: 0; border-radius: 99px; background: var(--surf2); border: 1px solid var(--line); position: relative; flex: none; padding: 0; transition: background .15s; cursor: pointer; }
.interruptor input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--mut); transition: left .15s, background .15s; }
.interruptor input:checked { background: var(--pri); border-color: var(--pri); }
.interruptor input:checked::after { left: 22px; background: var(--pri-ink); }
.calor { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); grid-auto-columns: 1fr; gap: 4px; max-width: 460px; }
.calor i { aspect-ratio: 1; border-radius: 4px; background: color-mix(in srgb, var(--pri) calc(var(--p) * 100%), var(--surf2)); }
.calor i.vacia { background: transparent; outline: 1px dashed var(--line); outline-offset: -1px; }
.seg { overflow: hidden; touch-action: pan-y; }
.seg button { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: normal; line-height: 1.2; }

/* ===== Sensación de app: sin zoom con los dedos, sin rebote ni «tirar para recargar», sin selección de texto en la interfaz ===== */
html, body { touch-action: pan-x pan-y; overscroll-behavior: none; }
input[type=range] { touch-action: none; }
main.texto { -webkit-user-select: text; user-select: text; }
@media (pointer: coarse) {
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea, select, code, .sel { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  .btn, .icono-btn, .chk, .chip, .fila.tocable, .seg button, .subtabs a, .fab, #nav a, .paleta, .rapido button { transition: transform .08s ease, opacity .08s ease; }
  .btn:active, .icono-btn:active, .chk:active, .chip:active, .fila.tocable:active, .seg button:active, .subtabs a:active, .fab:active, #nav a:active, .paleta:active, .rapido button:active { transform: scale(.96); opacity: .85; }
}

/* ===== Celular: nada se sale de la pantalla, la hoja sube por encima del teclado y los campos no provocan zoom ===== */
html, body { max-width: 100%; overflow-x: clip; }
.fila-campos > * { min-width: 0; }
.campo input, .campo select, .campo textarea { min-width: 0; max-width: 100%; }
input[type=date], input[type=month], input[type=time] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; text-align: left; min-height: 46px; }
input[type=date]::-webkit-date-and-time-value, input[type=month]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.3em; }
dialog.hoja, .hoja-cuerpo { overflow-x: hidden; }
@media (max-width: 699px) {
  dialog.hoja { margin-bottom: var(--vvb, 0px); max-height: calc(var(--vv, 100dvh) * .96); }
  dialog.hoja .hoja-cuerpo { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@media (pointer: coarse) {
  input, select, textarea, .campo input, .campo select, .campo textarea, .buscador input, .inline-in { font-size: 16px !important; }
  .campo.monto input { font-size: 24px !important; }
}

/* Sin barras de desplazamiento visibles (se sigue pudiendo desplazar con el dedo, la rueda o el teclado) */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* Cabecera fija de cada pantalla: título, pestañas y selector de mes/día se quedan arriba; solo lo de abajo se desplaza */
#main { --pad-main: 16px; }
@media (min-width: 700px) { #main { --pad-main: 26px; } }
@media (min-width: 1024px) { #main { --pad-main: 28px; } }
/* el espacio sobre las pestañas es parte de la franja (no del margen de la página), así no se encoge al desplazarse */
#main { --pad-top: 16px; }
@media (min-width: 700px) { #main { --pad-top: 22px; } }
.cab-fija { position: sticky; top: var(--alto-top, 0px); z-index: 12; display: flow-root; background: var(--bg); margin: calc(-1 * var(--pad-top)) calc(-1 * var(--pad-main)) 4px; padding: var(--pad-top) var(--pad-main) 0; }
.cab-fija .subtabs { margin: 0 calc(-1 * var(--pad-main)); padding-left: var(--pad-main); padding-right: var(--pad-main); }
.aviso-caja ~ .cab-fija { margin-top: 0; padding-top: 12px; }
.cab-fija .selector-periodo { margin-bottom: 8px; }
.cab-fija > .seg { margin-bottom: 10px !important; }
/* Una sola franja: lo que cabe no se mueve de lado; las pestañas que no caben se deslizan sin arrastrar la página */
.cab-fija .subtabs { overscroll-behavior-x: contain; }
.cab-fija .subtabs.quieto { overflow-x: hidden; touch-action: pan-y; }
.cab-fija .selector-periodo { touch-action: pan-y; }

/* Separación entre el bloque de cifras y las tarjetas que le siguen */
.grid + .cols, .grid + .chips + .cols, .seg + .cols, .selector-periodo + .cols { margin-top: 14px; }
