/* =========================================================
   Cuidarte — estilos
   Base de la plantilla Polilingo: celular primero (barra superior
   y pestañas abajo), barra lateral desde 768 px y panel derecho
   desde 1160 px. Capas fijas: #focus, #modal, #alertbar y #toast.
   ========================================================= */
:root {
  --bg: #ffffff;
  --bg-soft: #f1f7f6;
  --surface: #ffffff;
  --line: #dde8e6;
  --line-strong: #c8d8d5;
  --ink: #1d2b29;
  --ink-soft: #586b68;
  --brand: #0c8a7a;
  --brand-deep: #076356;
  --brand-tint: #daf3ee;
  --meds: #6a4fd6;
  --care: #d6457a;
  --report: #c96f00;
  --guide: #3f8f0b;
  --sos: #d9363e;
  --sos-deep: #a3242a;
  --sun: #ffb400;
  --sky: #1b84d1;
  --sky-deep: #12609b;
  --sky-tint: #ddf0ff;
  --ok: #16834a;
  --ok-bg: #dcf6e6;
  --warn: #8a5a00;
  --warn-bg: #fff2cf;
  --warn-line: #fab219;
  --crit: #c22f2f;
  --crit-bg: #ffe3e1;
  --lock: #e2e9e7;
  --lock-deep: #bfcdca;
  --lock-ink: #84948f;
  /* Gráficos (paleta validada: series 1 y 2, rejilla y ejes) */
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-muted: #6f6d68;
  --shadow: 0 10px 30px rgba(20, 40, 36, .14);
  --font-display: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-viz: system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
  font-size: 100%;
}
:root[data-size="grande"] { font-size: 118.75%; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1716;
    --bg-soft: #13201e;
    --surface: #172624;
    --line: #253a37;
    --line-strong: #314b47;
    --ink: #e8f2f0;
    --ink-soft: #9db4b0;
    --brand: #14a08e;
    --brand-deep: #0b6b5f;
    --brand-tint: #123a34;
    --meds: #9085e9;
    --care: #ec6d98;
    --report: #e58e1a;
    --guide: #63b52a;
    --sky: #4aa6ec;
    --sky-deep: #2a78b5;
    --sky-tint: #10304a;
    --ok: #4cd18a;
    --ok-bg: #133a26;
    --warn: #ffd166;
    --warn-bg: #3a2f10;
    --crit: #ff7a7a;
    --crit-bg: #421c1c;
    --lock: #22332f;
    --lock-deep: #18241f;
    --lock-ink: #6f8580;
    --viz-1: #3987e5;
    --viz-2: #d95926;
    --viz-grid: #2c3a38;
    --viz-axis: #3c4d4a;
    --viz-muted: #98a7a3;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1716;
  --bg-soft: #13201e;
  --surface: #172624;
  --line: #253a37;
  --line-strong: #314b47;
  --ink: #e8f2f0;
  --ink-soft: #9db4b0;
  --brand: #14a08e;
  --brand-deep: #0b6b5f;
  --brand-tint: #123a34;
  --meds: #9085e9;
  --care: #ec6d98;
  --report: #e58e1a;
  --guide: #63b52a;
  --sky: #4aa6ec;
  --sky-deep: #2a78b5;
  --sky-tint: #10304a;
  --ok: #4cd18a;
  --ok-bg: #133a26;
  --warn: #ffd166;
  --warn-bg: #3a2f10;
  --crit: #ff7a7a;
  --crit-bg: #421c1c;
  --lock: #22332f;
  --lock-deep: #18241f;
  --lock-ink: #6f8580;
  --viz-1: #3987e5;
  --viz-2: #d95926;
  --viz-grid: #2c3a38;
  --viz-axis: #3c4d4a;
  --viz-muted: #98a7a3;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; }
a { color: var(--sky); }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Botones 3D ---------- */
.btn {
  --b: var(--surface);
  --bd: var(--line-strong);
  --c: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--bd);
  border-bottom-width: 5px;
  border-radius: 14px;
  background: var(--b);
  color: var(--c);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .03em;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform .06s, filter .15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; margin-top: 3px; }
.btn[disabled] { --b: var(--lock); --bd: var(--lock-deep); --c: var(--lock-ink); cursor: not-allowed; filter: none; }
.btn[disabled]:active { transform: none; border-bottom-width: 5px; margin-top: 0; }
.btn-primary { --b: var(--brand); --bd: var(--brand-deep); --c: #fff; }
.btn-lv { --b: var(--lv, var(--brand)); --bd: color-mix(in srgb, var(--lv, var(--brand)) 68%, #000); --c: #fff; }
.btn-sky { --b: var(--sky); --bd: var(--sky-deep); --c: #fff; }
.btn-danger { --b: var(--sos); --bd: var(--sos-deep); --c: #fff; }
.btn-ghost { --b: transparent; --bd: var(--line-strong); --c: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; border-bottom-width: 4px; border-radius: 12px; }
.btn-xs { min-height: 34px; padding: 4px 10px; font-size: .82rem; border-bottom-width: 3px; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 150px; }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--sky); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 12px; border: 2px solid transparent;
  background: transparent; cursor: pointer; font-size: 1.3rem; line-height: 1;
}
.icon-btn:hover { background: var(--bg-soft); }

/* ---------- Estructura general ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar, .rail { display: none; }
.main {
  min-width: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom, 0px));
}
.view { --lv: var(--brand); max-width: 600px; margin: 0 auto; display: grid; gap: 16px; }
.view-meds { --lv: var(--meds); }
.view-care { --lv: var(--care); }
.view-report { --lv: var(--report); }
.view-guide { --lv: var(--guide); }
.view-sos { --lv: var(--sos); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-bottom: 8px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.top-brand { display: flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; color: inherit; }
.top-brand svg { width: 36px; height: 36px; flex: none; }
.top-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--brand); line-height: 1.1; }
.top-sub { display: block; font-size: .75rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.sos-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 14px;
  border: 0; border-radius: 99px; background: var(--sos); color: #fff; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; letter-spacing: .06em; box-shadow: 0 3px 0 var(--sos-deep);
}
.sos-pill:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--sos-deep); }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--bg);
  border-top: 2px solid var(--line);
}
.tab-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); border: 0; background: transparent; cursor: pointer;
  font-size: .7rem; font-weight: 500; color: var(--ink-soft); letter-spacing: .01em;
}
.tab-btn .nav-ico { font-size: 1.45rem; line-height: 1; filter: grayscale(.6); opacity: .75; }
.tab-btn.is-active { color: var(--brand); font-weight: 600; }
.tab-btn.is-active .nav-ico { filter: none; opacity: 1; }
.tab-btn.is-active::before { content: ""; position: absolute; top: 0; left: 26%; right: 26%; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand); }
.nav-dot { position: absolute; top: 8px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--sos); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }

.brand { display: flex; align-items: center; gap: 10px; padding: 8px 12px 22px; text-decoration: none; color: var(--brand); }
.brand svg { width: 46px; height: 46px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; letter-spacing: -.01em; }
.brand-sub { display: block; font-family: var(--font-body); font-size: .7rem; font-weight: 500; color: var(--ink-soft); letter-spacing: .05em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-sep { height: 2px; background: var(--line); margin: 8px 6px; }
.nav-btn {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border: 2px solid transparent; border-radius: 14px;
  background: transparent; cursor: pointer; text-align: left;
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; letter-spacing: .03em; color: var(--ink-soft);
}
.nav-btn:hover { background: var(--bg-soft); }
.nav-btn .nav-ico { font-size: 1.6rem; line-height: 1; width: 34px; text-align: center; }
.nav-btn.is-active { color: var(--brand-deep); background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
:root[data-theme="dark"] .nav-btn.is-active { color: #7fe0d2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav-btn.is-active { color: #7fe0d2; } }
.nav-btn.is-sos { color: var(--sos); }
.nav-btn.is-sos.is-active { background: var(--crit-bg); border-color: color-mix(in srgb, var(--sos) 40%, transparent); color: var(--sos); }
.nav-btn .nav-dot { top: 4px; right: auto; left: 38px; }

@media (min-width: 768px) {
  .app { grid-template-columns: 92px minmax(0, 1fr); }
  .tabbar, .topbar { display: none; }
  .sidebar {
    display: block; position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 20px 12px; border-right: 2px solid var(--line); overflow-y: auto;
  }
  .sidebar .brand-text, .sidebar .nav-label { display: none; }
  .sidebar .brand { justify-content: center; padding-inline: 0; }
  .sidebar .nav-btn { justify-content: center; padding-inline: 0; }
  .main { padding-block: 28px 64px; }
}
@media (min-width: 1160px) {
  .app { grid-template-columns: 250px minmax(0, 1fr) 360px; }
  .sidebar .nav-label { display: inline; }
  .sidebar .brand-text { display: block; }
  .sidebar .brand { justify-content: flex-start; padding-inline: 12px; }
  .sidebar .nav-btn { justify-content: flex-start; padding-inline: 14px; }
  .rail {
    display: flex; flex-direction: column; gap: 16px;
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
    padding: 28px 24px 24px 8px;
  }
}

/* ---------- Encabezados de vista ---------- */
.view-head { display: flex; align-items: center; gap: 14px; }
.view-head svg.mascot { width: 72px; flex: none; }
.view-head-text { display: grid; gap: 4px; min-width: 0; }
.view-title { font-size: 1.65rem; }
.view-sub { color: var(--ink-soft); }
.eyebrow { font-family: var(--font-display); font-weight: 600; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--lv, var(--brand)); }

.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav .view-head-text { flex: 1; }
.round-btn {
  width: 48px; height: 48px; flex: none; border-radius: 50%;
  border: 2px solid var(--line-strong); border-bottom-width: 4px; background: var(--surface);
  cursor: pointer; font-size: 1.2rem; display: grid; place-items: center;
}
.round-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.round-btn[disabled] { opacity: .35; cursor: default; }

/* ---------- Tarjetas ---------- */
.card { border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.card-head > .btn { flex: none; white-space: nowrap; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1.12rem; min-width: 0; }
.card-title .ico { font-size: 1.35rem; line-height: 1; }
.card-sub { color: var(--ink-soft); font-size: .88rem; }
.card-note { color: var(--ink-soft); font-size: .82rem; }
.card.is-accent { border-color: color-mix(in srgb, var(--lv) 45%, var(--line)); background: color-mix(in srgb, var(--lv) 7%, var(--surface)); }
.live { display: contents; }
.section-title { font-size: 1.1rem; margin: 6px 0 -4px; display: flex; align-items: center; gap: 10px; }
.section-title .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lv, var(--brand)); flex: none; }
.muted { color: var(--ink-soft); }
.small { font-size: .86rem; }
.empty { padding: 16px 8px; text-align: center; color: var(--ink-soft); display: grid; gap: 10px; justify-items: center; }
.empty svg { width: 96px; }

/* ---------- Chips y contadores ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 6px 14px;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px;
  background: var(--surface); cursor: pointer; font-weight: 500; line-height: 1.2;
}
.chip:hover { background: var(--bg-soft); }
.chip:active { transform: translateY(2px); border-bottom-width: 2px; }
.chip[aria-pressed="true"] {
  border-color: var(--lv, var(--brand));
  background: color-mix(in srgb, var(--lv, var(--brand)) 15%, var(--surface));
  font-weight: 600;
}
.chip small { font-size: .72rem; color: var(--ink-soft); font-weight: 400; }
.chips.is-emoji .chip { font-size: 1.65rem; min-width: 54px; padding: 4px; flex: 1 1 0; }
.chips.is-fill .chip { flex: 1 1 0; }
.chip-x { margin-left: 2px; color: var(--ink-soft); font-size: .9rem; }

.counter { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.counter-btn {
  width: 52px; height: 52px; flex: none; border-radius: 16px;
  border: 2px solid var(--line-strong); border-bottom-width: 5px; background: var(--surface);
  cursor: pointer; font-size: 1.5rem; font-weight: 600; display: grid; place-items: center;
}
.counter-btn.is-plus { background: var(--lv, var(--brand)); border-color: color-mix(in srgb, var(--lv, var(--brand)) 68%, #000); color: #fff; }
.counter-btn:active { transform: translateY(3px); border-bottom-width: 2px; }
.counter-val { text-align: center; display: grid; line-height: 1.1; }
.counter-val b { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.counter-val span { font-size: .8rem; color: var(--ink-soft); }

/* ---------- Registro rápido ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick-grid > .card, .quick-grid > .live > .card { padding: 14px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 340px) { .quick-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) {
  .quick-grid .counter-btn { width: 44px; height: 46px; border-radius: 14px; }
  .quick-grid .counter-val b { font-size: 1.7rem; }
}
.chip.is-stack { flex-direction: column; gap: 0; padding: 6px 8px; }
.chip.is-stack small { white-space: nowrap; }
.meal-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 8px; }
.meal-row + .meal-row { padding-top: 8px; border-top: 1px solid var(--line); }
.meal-name { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.meal-row .chip { min-height: 40px; padding: 4px 8px; font-size: .9rem; flex: 1 1 0; }
@media (max-width: 440px) { .meal-row { grid-template-columns: minmax(0, 1fr); } }
.check-chip[aria-pressed="true"]::before { content: "✓"; font-weight: 700; color: var(--lv, var(--brand)); }

/* ---------- Medicinas ---------- */
.doses { display: grid; gap: 8px; }
.dose {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); min-width: 0;
}
.dose-time { flex: none; min-width: 58px; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.dose-body { flex: 1; min-width: 0; }
.dose-name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.25; }
.dose-meta { font-size: .84rem; color: var(--ink-soft); }
.dose-actions { display: flex; gap: 6px; flex: none; }
.dose.is-done { background: var(--ok-bg); border-color: transparent; }
.dose.is-done .dose-time { color: var(--ok); }
.dose.is-skip { background: var(--bg-soft); border-color: transparent; }
.dose.is-skip .dose-name { text-decoration: line-through; color: var(--ink-soft); }
.dose.is-late { border-color: var(--crit); background: var(--crit-bg); }
.dose.is-late .dose-time { color: var(--crit); }
.state-tag { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 10px; border: 0; cursor: pointer; font-weight: 600; font-size: .85rem; background: transparent; }
.dose.is-done .state-tag { color: var(--ok); }
.dose.is-skip .state-tag { color: var(--ink-soft); }
.next-dose { display: flex; align-items: center; gap: 12px; }
.next-dose .btn { flex: none; white-space: nowrap; }
.next-dose-ico { font-size: 2rem; }
.med-list { display: grid; gap: 8px; }
.med {
  display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left; cursor: pointer; width: 100%;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; background: var(--surface);
}
.med:hover { background: var(--bg-soft); }
.med.is-paused { opacity: .6; }
.med-ico { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.5rem; background: color-mix(in srgb, var(--meds) 14%, var(--surface)); }
.med-body { min-width: 0; flex: 1; }
.med-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.med-meta { font-size: .84rem; color: var(--ink-soft); }
.time-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.time-item { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 8px; border: 2px solid var(--line); border-radius: 12px; }
.time-item input { border: 0; background: transparent; min-height: 36px; font-weight: 600; width: 7.2em; }
.time-item button { border: 0; background: var(--bg-soft); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }

/* ---------- Señales (estado clínico) ---------- */
.flag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.flag-atencion { background: var(--warn-bg); color: var(--warn); }
.flag-alerta { background: var(--crit-bg); color: var(--crit); }
.readings { display: grid; }
.reading { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.reading:first-child { border-top: 0; padding-top: 0; }
.reading-time { font-family: var(--font-display); font-weight: 700; min-width: 50px; font-variant-numeric: tabular-nums; }
.vchip { display: inline-flex; align-items: baseline; gap: 4px; padding: 4px 10px; border-radius: 10px; background: var(--bg-soft); font-size: .9rem; }
.vchip b { font-family: var(--font-display); font-size: 1.02rem; }
.vchip small { color: var(--ink-soft); font-size: .72rem; }
.vchip.is-atencion { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn-line); }
.vchip.is-alerta { background: var(--crit-bg); color: var(--crit); box-shadow: inset 0 0 0 2px var(--crit); }
.vchip.is-atencion small, .vchip.is-alerta small { color: inherit; }
.x-btn { margin-left: auto; border: 0; background: transparent; color: var(--ink-soft); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1rem; }
.x-btn:hover { background: var(--bg-soft); color: var(--crit); }

.banner { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg-soft); }
.banner-ico { font-size: 1.5rem; line-height: 1.1; flex: none; }
.banner-body { display: grid; gap: 4px; min-width: 0; flex: 1; }
.banner-body b { font-family: var(--font-display); font-size: 1.05rem; }
.banner-alerta { background: var(--crit-bg); border-color: var(--crit); }
.banner-alerta b { color: var(--crit); }
.banner-atencion { background: var(--warn-bg); border-color: var(--warn-line); }
.banner-info { background: var(--sky-tint); border-color: color-mix(in srgb, var(--sky) 40%, transparent); }

.list { display: grid; gap: 6px; }
.list-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg-soft); }
.list-item .li-ico { font-size: 1.3rem; line-height: 1.2; flex: none; }
.list-item .li-body { min-width: 0; flex: 1; }
.list-item .li-title { font-weight: 600; }
.list-item .li-text { font-size: .88rem; color: var(--ink-soft); }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: .95rem; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.field-label small { font-weight: 400; color: var(--ink-soft); font-size: .8rem; }
.field-hint { font-size: .8rem; color: var(--ink-soft); }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg-soft); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--sky); background: var(--surface); }
.input.is-invalid { border-color: var(--crit); background: var(--crit-bg); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input-num { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 380px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.pa-row { display: flex; align-items: center; gap: 8px; }
.pa-row .input { flex: 1; }
.pa-sep { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--ink-soft); }
.with-unit { position: relative; }
.with-unit .input { padding-right: 58px; }
.with-unit .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: .8rem; color: var(--ink-soft); pointer-events: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; position: sticky; bottom: -24px; padding: 12px 0 4px; background: var(--bg); }
.form-actions .btn { flex: 1 1 140px; }

.settings { display: grid; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-top: 2px solid var(--line); }
.set-row:first-child { border-top: 0; }
.set-label { display: grid; min-width: 0; }
.set-label b { font-weight: 600; }
.set-label span { font-size: .84rem; color: var(--ink-soft); }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 30px; border-radius: 99px; background: color-mix(in srgb, var(--ink-soft) 55%, var(--surface)); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch:checked { background: var(--lv, var(--brand)); }
.switch:checked::after { transform: translateX(22px); }
.select { flex: none; min-height: 44px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); max-width: 52%; }

/* ---------- Panel derecho ---------- */
.panel { border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; background: var(--surface); }
.panel-title { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.panel-text { color: var(--ink-soft); font-size: .9rem; }
.mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini-stat { padding: 10px; border-radius: 12px; background: var(--bg-soft); display: grid; gap: 2px; }
.mini-stat b { font-family: var(--font-display); font-size: 1.2rem; }
.mini-stat span { font-size: .78rem; color: var(--ink-soft); }
.tip { font-size: .95rem; }

/* ---------- Mosaicos de acción ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  --t: var(--lv, var(--brand));
  display: grid; gap: 6px; align-content: start; text-align: left; min-height: 124px; padding: 14px;
  border: 2px solid color-mix(in srgb, var(--t) 35%, var(--line)); border-bottom-width: 5px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--t) 8%, var(--surface)); cursor: pointer;
}
.tile:hover { background: color-mix(in srgb, var(--t) 14%, var(--surface)); }
.tile:active { transform: translateY(3px); border-bottom-width: 2px; }
.tile-ico { font-size: 2rem; line-height: 1; }
.tile-title { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; line-height: 1.2; }
.tile-text { font-size: .82rem; color: var(--ink-soft); line-height: 1.3; }

/* ---------- Guía ---------- */
.search {
  width: 100%; min-height: 50px; padding: 10px 16px 10px 44px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--bg-soft) no-repeat 14px 50% / 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23889' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  color: var(--ink);
}
.search:focus { outline: none; border-color: var(--sky); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; }
.topic {
  --t: var(--guide);
  display: grid; gap: 6px; align-content: start; text-align: left; min-height: 120px; padding: 14px; cursor: pointer;
  border: 2px solid var(--line); border-bottom-width: 5px; border-radius: var(--radius); background: var(--surface);
}
.topic:hover { border-color: color-mix(in srgb, var(--t) 55%, var(--line)); }
.topic:active { transform: translateY(3px); border-bottom-width: 2px; }
.topic-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.6rem; background: color-mix(in srgb, var(--t) 14%, var(--surface)); }
.topic-name { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; line-height: 1.2; }
.guide-sec { display: grid; gap: 8px; }
.guide-sec h3 { font-size: 1.08rem; color: var(--t, var(--brand)); display: flex; align-items: center; gap: 8px; }
.steps { display: grid; gap: 8px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--bg-soft); }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--t, var(--brand)); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .85rem; }
.bullets { display: grid; gap: 6px; padding-left: 0; list-style: none; }
.bullets li { display: flex; gap: 8px; align-items: flex-start; }
.bullets li::before { content: "•"; color: var(--t, var(--brand)); font-weight: 700; }
.bullets.is-bad li::before { content: "✕"; color: var(--crit); }
.bullets.is-alert li::before { content: "!"; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--crit); color: #fff; display: grid; place-items: center; font-size: .75rem; margin-top: 2px; }
.extra-box { padding: 12px 14px; border-radius: 12px; border: 2px dashed color-mix(in srgb, var(--t, var(--brand)) 45%, var(--line)); }
details.acc { border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
details.acc + details.acc { margin-top: 8px; }
details.acc summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 600; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: "▾"; margin-left: auto; color: var(--ink-soft); transition: transform .2s; }
details.acc[open] summary::after { transform: rotate(180deg); }
details.acc .acc-body { padding: 0 14px 14px; display: grid; gap: 8px; }
details.acc .acc-ico { font-size: 1.4rem; }

/* ---------- SOS ---------- */
.sos-call {
  display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 84px; padding: 14px 18px;
  border-radius: 20px; background: var(--sos); color: #fff; text-decoration: none;
  box-shadow: 0 6px 0 var(--sos-deep); font-family: var(--font-display); font-weight: 700; font-size: 1.4rem;
}
.sos-call:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--sos-deep); }
.sos-call small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .85rem; opacity: .92; }
.sos-call .big { font-size: 2.2rem; }
.contact { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; }
.contact-body { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; overflow-wrap: anywhere; }
.contact-meta { font-size: .84rem; color: var(--ink-soft); }
.call-btn { display: inline-grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 14px; text-decoration: none; font-size: 1.3rem; background: var(--ok-bg); border: 2px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.call-btn.is-wa { background: var(--brand-tint); }
.befast { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.befast div { padding: 10px 8px; border-radius: 12px; background: var(--crit-bg); text-align: center; display: grid; gap: 2px; }
.befast b { font-family: var(--font-display); font-size: 1.6rem; color: var(--crit); line-height: 1; }
.befast span { font-size: .78rem; }
.ficha { display: grid; gap: 14px; font-size: 1.1rem; }
.ficha-row { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 2px solid var(--line); }
.ficha-row span { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 600; }
.ficha-row b { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; overflow-wrap: anywhere; }
.ficha-row.is-alert b { color: var(--crit); }

/* ---------- Capa de enfoque (pantalla completa) ---------- */
.focus {
  --lv: var(--brand);
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
}
.focus-head {
  display: flex; align-items: center; gap: 14px;
  width: min(760px, 100%); margin: 0 auto;
  padding-block: 14px 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.focus-close { width: 44px; height: 44px; flex: none; border: 0; background: transparent; cursor: pointer; color: var(--lock-ink); font-size: 1.6rem; border-radius: 12px; }
.focus-close:hover { background: var(--bg-soft); }
.focus-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; flex: 1; min-width: 0; }
.focus-body {
  overflow-y: auto;
  padding-block: 8px calc(24px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.focus-inner { width: min(600px, 100%); margin: 0 auto; display: grid; gap: 18px; animation: ex-in .3s ease; }
@keyframes ex-in { from { opacity: 0; transform: translateX(18px); } }
.progress { flex: 1; height: 16px; border-radius: 99px; background: var(--lock); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: var(--lv); transition: width .35s ease; }

.center { text-align: center; justify-items: center; }
.big-title { font-size: clamp(1.5rem, 5.5vw, 2rem); }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px;
  border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 16px; background: var(--surface);
  cursor: pointer; text-align: left; font-size: 1.05rem;
}
.opt:hover { background: var(--bg-soft); }
.opt:active { transform: translateY(3px); border-bottom-width: 2px; }
.opt-key { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 9px; color: var(--ink-soft); font-size: .85rem; font-weight: 600; }
.opt.is-selected { border-color: var(--lv); background: color-mix(in srgb, var(--lv) 12%, var(--surface)); }
.opt.is-selected .opt-key { border-color: var(--lv); color: var(--lv); }
.opt-ico { font-size: 1.8rem; flex: none; }
.opt-body { display: grid; min-width: 0; }
.opt-body b { font-family: var(--font-display); font-weight: 600; }
.opt-body span { font-size: .85rem; color: var(--ink-soft); }
.q-text { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.25rem, 4.6vw, 1.6rem); line-height: 1.25; }
.q-count { color: var(--ink-soft); font-weight: 600; font-size: .9rem; }

/* Respiración */
.breath { display: grid; gap: 20px; justify-items: center; text-align: center; padding-top: 8px; }
.breath-stage { position: relative; width: min(78vw, 320px); aspect-ratio: 1; display: grid; place-items: center; }
.breath-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px dashed color-mix(in srgb, var(--lv) 40%, transparent); }
.breath-circle {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--lv) 30%, var(--surface)), color-mix(in srgb, var(--lv) 75%, var(--surface)));
  transform: scale(.5); transition-property: transform; transition-timing-function: ease-in-out;
}
.breath-label { position: relative; z-index: 1; display: grid; gap: 2px; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.breath-label b { font-family: var(--font-display); font-size: clamp(1.6rem, 7vw, 2.2rem); }
.breath-label span { font-family: var(--font-display); font-weight: 700; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.breath-left { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Temporizador circular */
.timer { position: relative; width: 168px; height: 168px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-track { fill: none; stroke: var(--lock); stroke-width: 12; }
.timer-bar { fill: none; stroke: var(--lv); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 2.2rem; font-variant-numeric: tabular-nums; }
.big-emoji { font-size: 4rem; line-height: 1; }

/* Semana */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }
.day { display: grid; gap: 4px; justify-items: center; font-size: .76rem; color: var(--ink-soft); font-weight: 600; }
.day i { width: 34px; height: 34px; border-radius: 50%; background: var(--lock); display: grid; place-items: center; font-style: normal; font-size: .85rem; color: var(--ink-soft); }
.day.is-on i { background: var(--lv); color: #fff; }
.day.is-half i { background: color-mix(in srgb, var(--lv) 40%, var(--lock)); color: var(--ink); }
.day.is-today { color: var(--ink); }
.day.is-today i { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--lv); }

.meter { height: 14px; border-radius: 99px; background: color-mix(in srgb, var(--lv) 18%, var(--lock)); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--lv); transition: width .5s ease; }
.score { font-family: var(--font-display); font-weight: 700; font-size: 3rem; line-height: 1; }

/* ---------- Reporte ---------- */
.range-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report { display: grid; gap: 16px; padding: 18px; border: 2px solid var(--line); border-radius: 20px; background: var(--surface); }
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 3px solid var(--report); }
.report-head h2 { font-size: 1.45rem; }
.report-head .muted { font-size: .88rem; }
.report-brand { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-weight: 700; color: var(--brand); flex: none; }
.report-brand svg { width: 34px; height: 34px; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat {
  display: grid; gap: 2px; align-content: start; padding: 12px; border-radius: 14px; background: var(--bg-soft); min-width: 0;
  font-family: var(--font-viz);
}
.stat-label { font-size: .8rem; color: var(--ink-soft); display: flex; gap: 6px; align-items: center; }
.stat-val { font-size: 1.45rem; font-weight: 600; line-height: 1.15; }
.stat-val small { font-size: .8rem; font-weight: 500; color: var(--ink-soft); }
.stat-sub { font-size: .76rem; color: var(--ink-soft); }
.stat .flag { justify-self: start; margin-top: 4px; }
.rsec { display: grid; gap: 10px; break-inside: avoid; }
.rsec h3 { font-size: 1.08rem; display: flex; align-items: center; gap: 8px; }
.rtable-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.rtable { width: 100%; border-collapse: collapse; font-size: .86rem; font-family: var(--font-viz); }
.rtable th, .rtable td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable th { background: var(--bg-soft); font-weight: 600; color: var(--ink-soft); font-size: .78rem; }
.rtable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rtable tr:last-child td { border-bottom: 0; }
.rtable td.is-alerta { color: var(--crit); font-weight: 600; }
.rtable td.is-atencion { color: var(--warn); font-weight: 600; }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.strip div { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; background: var(--bg-soft); font-size: .7rem; color: var(--ink-soft); }
.strip b { font-size: 1.25rem; line-height: 1.1; }
.report-foot { font-size: .78rem; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 10px; }
.q-list { display: grid; gap: 6px; }
.q-item { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--bg-soft); }
.q-item span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.add-row { display: flex; gap: 8px; }
.add-row .input { flex: 1; }

/* Gráficos */
.viz { position: relative; font-family: var(--font-viz); }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-title { font-family: var(--font-viz); font-size: .9rem; font-weight: 600; margin-bottom: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.viz-legend { display: inline-flex; gap: 12px; font-weight: 400; font-size: .8rem; color: var(--ink-soft); }
.viz-key { display: inline-flex; align-items: center; gap: 5px; }
.viz-key i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-ref { stroke: var(--viz-muted); stroke-width: 1; opacity: .7; }
.viz-tick { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-end { fill: var(--ink); font-size: 12px; font-weight: 600; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { stroke: var(--surface); stroke-width: 2; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 120px;
  padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  font-size: .8rem; line-height: 1.35;
}
.viz-tip b { display: block; font-weight: 600; margin-bottom: 2px; }
.viz-tip .row { display: flex; align-items: center; gap: 6px; }
.viz-tip .row i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(8, 18, 16, .55); }
.modal-card {
  --lv: var(--brand);
  width: min(600px, 100%); max-height: min(88vh, 900px); max-height: min(88dvh, 900px); overflow: auto;
  border-radius: 22px; background: var(--bg); box-shadow: var(--shadow); border: 2px solid var(--line);
  animation: pop-in .2s ease;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (max-width: 560px) {
  .modal { place-items: end stretch; padding: 0; }
  .modal-card { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
}
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; background: var(--bg); border-bottom: 2px solid var(--line); }
.modal-head h2 { font-size: 1.25rem; }
.modal-close { width: 42px; height: 42px; flex: none; border: 0; border-radius: 12px; background: var(--bg-soft); cursor: pointer; font-size: 1.2rem; color: var(--ink-soft); }
.modal-body { padding: 16px 18px 24px; display: grid; gap: 16px; }

/* ---------- Avisos y mensajes ---------- */
.alertbar {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);
  padding: 10px 16px; border: 0; border-radius: 99px; cursor: pointer;
  background: var(--meds); color: #fff; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
  animation: toast-in .25s ease;
}
.alertbar .pulse { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 80; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 500; box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (min-width: 768px) { .toast { bottom: 28px; } }

/* ---------- Mascota ---------- */
.mascot { display: block; }
.mascot .blink { animation: blink 4.5s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.mascot.is-bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* ---------- Carga ---------- */
.loading { min-height: 60vh; display: grid; place-items: center; align-content: center; text-align: center; gap: 12px; color: var(--ink-soft); padding: 24px; }
.loading svg { width: 110px; }
.error-box { max-width: 520px; padding: 18px; border: 2px solid var(--crit); border-radius: 16px; background: var(--crit-bg); color: var(--ink); text-align: left; display: grid; gap: 8px; }
.error-box code { font-size: .88rem; overflow-wrap: anywhere; }
.sources { display: grid; gap: 8px; font-size: .86rem; color: var(--ink-soft); }
.sources ul { padding-left: 20px; display: grid; gap: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Impresión (reporte en PDF) ---------- */
@media print {
  /* Mismos selectores que el modo oscuro para ganarle siempre: el PDF sale claro */
  :root, :root:not([data-theme="light"]), :root[data-theme] {
    --bg: #fff; --bg-soft: #f3f6f5; --surface: #fff; --line: #d9e2e0; --line-strong: #c8d3d1;
    --ink: #111; --ink-soft: #4a5553; --crit: #b0201f; --crit-bg: #fde4e2; --warn: #7a4f00; --warn-bg: #fff1c9;
    --brand: #0c8a7a; --brand-deep: #076356; --brand-tint: #daf3ee; --report: #c96f00; --sos: #d9363e;
    --sky: #1b84d1; --sky-tint: #ddf0ff; --ok: #16834a; --ok-bg: #dcf6e6; --lock: #e2e9e7;
    --viz-1: #2a78d6; --viz-2: #eb6834; --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; --viz-muted: #6f6d68;
    color-scheme: light;
  }
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .tabbar, .rail, .no-print, .toast, .modal, .focus, .alertbar { display: none !important; }
  .app { display: block; }
  .main { padding: 0 !important; }
  .view { max-width: none; gap: 0; }
  .report { border: 0; padding: 0; border-radius: 0; }
  .rsec, .stat, .viz { break-inside: avoid; }
  .rtable-wrap { overflow: visible; }
  .rtable th, .rtable td { white-space: normal; }
}
