/* ==========================================================================
   BULLDER · sistema de diseño (núcleo). Los módulos NO redefinen estas clases:
   las usan y agregan las suyas con prefijo propio en css/features/<modulo>.css
   ========================================================================== */
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0100-02AF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Outfit"; src: url("../fonts/outfit-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  /* marca */
  --navy: #272954;            /* azul del logotipo */
  --silver: #878696;          /* gris del logotipo */
  --accent: #b9f53c;          /* verde energía: acciones principales */
  --accent-press: #a5e023;
  --on-accent: #10131f;       /* texto sobre el verde */
  --accent-soft: rgba(185, 245, 60, .14);

  /* superficies (tema oscuro por omisión) */
  --bg: #0a0c1b;
  --bg-elev: #0f1226;
  --surface: #151833;
  --surface-2: #1c2042;
  --surface-3: #262b55;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f3f5ff;
  --text-2: #b4b8d6;
  --text-3: #7d82a8;
  --media-bg: #ffffff;        /* los videos de ejercicios tienen fondo blanco */

  /* semánticos */
  --ok: #3ddc97;
  --warn: #ffb648;
  --danger: #ff5d6c;
  --info: #6aa8ff;
  --pr: #ffcf40;              /* récords personales */
  --danger-soft: rgba(255, 93, 108, .14);
  --ok-soft: rgba(61, 220, 151, .14);
  --warn-soft: rgba(255, 182, 72, .14);
  --info-soft: rgba(106, 168, 255, .14);

  /* tipos de serie */
  --set-warmup: #ffb648;
  --set-drop: #b48cff;
  --set-failure: #ff5d6c;

  /* serie de gráficas (validada sobre ambas superficies) */
  --c1: #7c9cff; --c2: #3ddc97; --c3: #ffb648; --c4: #ff7eb6; --c5: #5fd4e6; --c6: #b48cff; --c7: #ff8a5c; --c8: #a3b0c9;

  /* medida */
  --r-xs: 8px; --r-sm: 12px; --r: 16px; --r-lg: 22px; --r-full: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Outfit", "Inter", system-ui, sans-serif;
  --topbar-h: 56px;
  --tabbar-h: 62px;
  --sidebar-w: 248px;
  --content-max: 760px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .25);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --accent: #6fbf00; --accent-press: #63ab00; --on-accent: #0b1400; --accent-soft: rgba(111, 191, 0, .14);
  --bg: #f3f4fa; --bg-elev: #ffffff; --surface: #ffffff; --surface-2: #eef0f8; --surface-3: #e1e4f1;
  --line: rgba(23, 26, 60, .09); --line-strong: rgba(23, 26, 60, .18);
  --text: #171a3c; --text-2: #4c5078; --text-3: #7f83a6;
  --ok: #109e63; --warn: #c97800; --danger: #d92c40; --info: #2f6fe0; --pr: #c79200;
  --c1: #3f63e0; --c2: #109e63; --c3: #c97800; --c4: #d6408a; --c5: #1794ab; --c6: #7b4fe0; --c7: #d85a26; --c8: #6b7896;
  --shadow: 0 10px 30px rgba(23, 26, 60, .12); --shadow-sm: 0 2px 10px rgba(23, 26, 60, .08);
  color-scheme: light;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 18px; } h4 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, video, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--on-accent); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); } .dim { color: var(--text-3); }
.small { font-size: 13px; } .tiny { font-size: 12px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* iconos (sprite Lucide) */
.ic { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; } .ic-lg { width: 28px; height: 28px; } .ic-xl { width: 40px; height: 40px; }
.ic-fill { fill: currentColor; }

/* ------------------------------------------------------------------ estructura */
.app { min-height: 100dvh; display: flex; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#view { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--safe-b) + 28px); }
.app[data-chrome="stack"] #view { padding-bottom: calc(var(--safe-b) + 32px); }
.app[data-chrome="none"] #view { padding: 0; max-width: none; }
.app[data-dock="1"] #view { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 92px); }
.app[data-chrome="stack"][data-dock="1"] #view { padding-bottom: calc(var(--safe-b) + 96px); }
#view.view-wide { max-width: 1120px; }

/* barra superior */
#topbar {
  position: sticky; top: 0; z-index: 30; height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) var(--sp-2) 0;
  display: flex; align-items: center; gap: var(--sp-1);
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
#topbar.is-scrolled { border-bottom-color: var(--line); }
.app[data-chrome="none"] #topbar, .app[data-chrome="none"] #tabbar, .app[data-chrome="none"] #sidebar, .app[data-chrome="none"] #dock { display: none; }
.topbar-title { flex: 1; min-width: 0; padding: 0 var(--sp-2); font: 700 18px/1.2 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title.is-brand { display: flex; align-items: center; gap: 10px; }
.topbar-title.is-brand img { height: 30px; width: auto; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.topbar-sub { display: block; font: 500 12px/1.2 var(--font); color: var(--text-3); }

/* barra inferior (teléfono) */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: stretch;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
}
.app[data-chrome="stack"] #tabbar { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font: 600 10.5px/1 var(--font); position: relative; transition: color .15s; }
.tab .ic { width: 24px; height: 24px; transition: transform .2s var(--ease); }
.tab.is-active { color: var(--accent); }
.tab.is-active .ic { transform: translateY(-1px) scale(1.06); }
.tab:active .ic { transform: scale(.9); }
.tab-badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font: 700 10px/16px var(--font); text-align: center; }

/* acoplado sobre la barra inferior (entrenamiento en curso) */
#dock { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 39; padding: 0 var(--sp-3) var(--sp-2); pointer-events: none; }
#dock > * { pointer-events: auto; max-width: var(--content-max); margin: 0 auto; }
.app[data-chrome="stack"] #dock { bottom: var(--safe-b); }
#dock:empty { display: none; }

/* barra lateral (escritorio) */
#sidebar { display: none; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; }
.side-brand img { height: 40px; width: auto; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; transition: background .15s, color .15s; position: relative; }
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link.is-active { background: var(--accent-soft); color: var(--accent); }
.side-sep { height: 1px; background: var(--line); margin: 10px 12px; }
.side-foot { margin-top: auto; padding: 12px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-sm); }
.side-user:hover { background: var(--surface); }

@media (min-width: 960px) {
  #sidebar { display: flex; flex-direction: column; width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100dvh; background: var(--bg-elev); border-right: 1px solid var(--line); overflow-y: auto; }
  #tabbar { display: none; }
  #view, .app[data-chrome="stack"] #view { padding: var(--sp-6) var(--sp-8) 64px; }
  .app[data-dock="1"] #view, .app[data-chrome="stack"][data-dock="1"] #view { padding-bottom: 120px; }
  #dock, .app[data-chrome="stack"] #dock { left: var(--sidebar-w); bottom: 12px; }
  #topbar { padding-left: var(--sp-6); padding-right: var(--sp-6); }
  .topbar-title.is-brand img { display: none; }
  h1 { font-size: 32px; }
}

/* transición entre pantallas */
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes view-push { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes view-pop { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
#view.anim-in { animation: view-in .22s var(--ease); }
#view.anim-push { animation: view-push .24s var(--ease); }
#view.anim-pop { animation: view-pop .24s var(--ease); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* pantalla de arranque */
#splash { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--bg); transition: opacity .3s; }
#splash img { width: 132px; animation: splash-pulse 1.4s ease-in-out infinite; }
#splash.is-hidden { opacity: 0; pointer-events: none; }
@keyframes splash-pulse { 50% { transform: scale(1.06); opacity: .8; } }

/* ------------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text); font: 650 15px/1 var(--font); white-space: nowrap; user-select: none;
  transition: transform .12s var(--ease), background .15s, opacity .15s, box-shadow .15s; border: 1px solid transparent;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-press); }
.btn-outline { background: transparent; border-color: var(--line-strong); }
.btn-outline:hover { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 93, 108, .24); }
.btn-accent-soft { background: var(--accent-soft); color: var(--accent); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-lg { min-height: 54px; font-size: 16.5px; border-radius: var(--r); }
.btn-block { display: flex; width: 100%; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--text-2); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn-primary.is-loading::after { border-color: var(--on-accent); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--text); transition: background .15s, transform .12s; flex: none; }
.icon-btn:hover { background: var(--surface); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.is-accent { color: var(--accent); }
.link { color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); z-index: 35; width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); transition: transform .15s var(--ease); }
.fab:active { transform: scale(.92); }
@media (min-width: 960px) { .fab { bottom: 28px; right: 32px; } }

/* ------------------------------------------------------------------ tarjetas y listas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-4); }
.card-flush { padding: 0; overflow: hidden; }
.card-tap { transition: transform .12s var(--ease), border-color .15s; cursor: pointer; }
.card-tap:hover { border-color: var(--line-strong); }
.card-tap:active { transform: scale(.985); }
.card-title { font: 700 16px/1.2 var(--font-display); }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-wrap { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-3); }
.section-head:first-child { margin-top: 0; }
.section-head h2, .section-head h3 { font-size: 18px; }
.overline { font: 700 11.5px/1 var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: 12px var(--sp-4); min-height: 58px; position: relative; width: 100%; text-align: left; }
.list-item + .list-item::before { content: ""; position: absolute; top: 0; left: var(--sp-4); right: 0; height: 1px; background: var(--line); }
button.list-item:hover, a.list-item:hover { background: var(--surface-2); }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.list-item .li-end { margin-left: auto; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex: none; }
.li-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.li-icon.is-accent { background: var(--accent-soft); color: var(--accent); }

/* miniatura de ejercicio (los videos son de fondo blanco) */
.ex-thumb { width: 56px; height: 56px; border-radius: 12px; background: var(--media-bg); object-fit: cover; flex: none; overflow: hidden; }
.ex-thumb-lg { width: 76px; height: 76px; border-radius: 14px; }
.ex-thumb-sm { width: 42px; height: 42px; border-radius: 10px; }

/* avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex: none; display: inline-grid; place-items: center; font: 700 15px/1 var(--font-display); color: var(--text); text-transform: uppercase; overflow: hidden; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; } .avatar-lg { width: 64px; height: 64px; font-size: 24px; } .avatar-xl { width: 96px; height: 96px; font-size: 36px; }

/* etiquetas */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px; background: var(--surface-2); color: var(--text-2); font: 650 11.5px/1 var(--font); white-space: nowrap; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); } .badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); } .badge-info { background: var(--info-soft); color: var(--info); }
.badge-pr { background: rgba(255, 207, 64, .16); color: var(--pr); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font: 600 13.5px/1 var(--font); white-space: nowrap; transition: all .15s; flex: none; }
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chips { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--sp-4) * -1); padding: 2px var(--sp-4); }
.chips::-webkit-scrollbar { display: none; }

/* cifras */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px var(--sp-4); min-width: 0; }
.stat-label { font: 600 12px/1.2 var(--font); color: var(--text-3); }
.stat-value { font: 700 24px/1.15 var(--font-display); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font: 600 13px/1 var(--font); color: var(--text-2); margin-left: 2px; }
.stat-delta { font: 650 12px/1 var(--font); margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; }
.stat-delta.up { color: var(--ok); } .stat-delta.down { color: var(--danger); } .stat-delta.flat { color: var(--text-3); }
.stats-inline { display: flex; gap: var(--sp-5); }
.stats-inline > div > b { display: block; font: 700 17px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.stats-inline > div > span { font-size: 12px; color: var(--text-3); }

.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .5s var(--ease); }

/* ------------------------------------------------------------------ formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font: 600 13px/1.2 var(--font); color: var(--text-2); }
.field-hint { font-size: 12.5px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-sm); background: var(--surface); border: 1.5px solid var(--line);
  color: var(--text); font-size: 16px; transition: border-color .15s, background .15s; appearance: none; -webkit-appearance: none;
}
.textarea { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.input.is-invalid { border-color: var(--danger); }
.select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237d82a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input-group { position: relative; }
.input-group .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-group .input { padding-left: 44px; }
.input-group .input-suffix { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.search { border-radius: var(--r-full); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: var(--surface-3); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); gap: 2px; }
.segmented button { min-height: 36px; border-radius: 9px; color: var(--text-2); font: 650 13.5px/1 var(--font); transition: all .15s; padding: 0 8px; }
.segmented button.is-active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

.tabs { display: flex; gap: var(--sp-5); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 12px 0; color: var(--text-3); font: 650 14.5px/1 var(--font); border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s; }
.tabs button.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* opciones grandes (asistentes) */
.option { display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left; padding: 14px var(--sp-4); border-radius: var(--r); background: var(--surface); border: 1.5px solid var(--line); transition: all .15s; }
.option:hover { border-color: var(--line-strong); }
.option.is-active { border-color: var(--accent); background: var(--accent-soft); }
.option .opt-title { font-weight: 650; } .option .opt-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ------------------------------------------------------------------ hojas, diálogos y avisos */
#overlays { position: relative; z-index: 100; }
.overlay { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 14, .62); opacity: 0; transition: opacity .25s; }
.overlay.is-open .overlay-backdrop { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - 40px - var(--safe-t)); display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow);
  transform: translateY(100%); transition: transform .32s var(--ease); padding-bottom: var(--safe-b);
}
.overlay.is-open .sheet { transform: none; }
.sheet-full { height: calc(100dvh - 24px - var(--safe-t)); }
.sheet-grip { width: 40px; height: 4.5px; border-radius: 3px; background: var(--line-strong); margin: 9px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: var(--sp-2); padding: 8px var(--sp-2) 8px var(--sp-4); flex: none; min-height: 52px; }
.sheet-head h3 { flex: 1; min-width: 0; font-size: 18px; }
.sheet-body { padding: var(--sp-2) var(--sp-4) var(--sp-4); overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.sheet-foot { padding: var(--sp-3) var(--sp-4) var(--sp-4); border-top: 1px solid var(--line); display: flex; gap: var(--sp-3); flex: none; }
.sheet-foot .btn { flex: 1; }
.dialog { position: relative; width: calc(100% - 40px); max-width: 380px; margin: auto; align-self: center; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-6) var(--sp-5) var(--sp-4); box-shadow: var(--shadow); transform: scale(.94); opacity: 0; transition: all .22s var(--ease); }
.overlay.is-open .dialog { transform: none; opacity: 1; }
.dialog h3 { font-size: 19px; margin-bottom: 8px; }
.dialog-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.dialog-actions .btn { flex: 1; }
.action-list { display: flex; flex-direction: column; padding: 4px 0 8px; }
.action-item { display: flex; align-items: center; gap: 14px; padding: 14px var(--sp-2); border-radius: var(--r-sm); font-weight: 600; text-align: left; width: 100%; }
.action-item:hover { background: var(--surface); }
.action-item.is-danger { color: var(--danger); }
.action-item .ic { color: var(--text-2); } .action-item.is-danger .ic { color: var(--danger); }
@media (min-width: 720px) {
  .overlay { align-items: center; }
  .sheet { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); max-height: min(760px, calc(100dvh - 64px)); transform: translateY(24px) scale(.98); opacity: 0; transition: all .24s var(--ease); }
  .overlay.is-open .sheet { opacity: 1; }
  .sheet-full { height: min(820px, calc(100dvh - 64px)); max-width: 640px; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 14px; }
}

#toasts { position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 12px); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 440px; padding: 12px 16px; border-radius: 14px; background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 14px; box-shadow: var(--shadow); border: 1px solid var(--line-strong); animation: toast-in .28s var(--ease); }
.toast.is-ok .ic { color: var(--ok); } .toast.is-error .ic { color: var(--danger); } .toast.is-info .ic { color: var(--info); }
.toast.is-out { opacity: 0; transform: translateY(-8px); transition: all .25s; }
.toast button { color: var(--accent); font-weight: 700; margin-left: 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } }

/* estados */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 44px 20px; color: var(--text-2); }
.empty .empty-icon { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; background: var(--surface); color: var(--text-3); margin-bottom: 6px; }
.empty h3 { color: var(--text); font-size: 18px; }
.empty p { max-width: 320px; }
.empty .btn { margin-top: 10px; }
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; min-height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 14px; margin: 8px 0; } .sk-card { height: 96px; border-radius: var(--r); margin-bottom: 12px; } .sk-title { height: 26px; width: 55%; margin-bottom: 16px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .7s linear infinite; margin: 32px auto; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); background: var(--info-soft); color: var(--text); font-size: 14px; }
.banner.is-warn { background: var(--warn-soft); } .banner.is-danger { background: var(--danger-soft); } .banner.is-ok { background: var(--ok-soft); } .banner.is-accent { background: var(--accent-soft); }
.banner .ic { flex: none; margin-top: 1px; }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 250; padding: calc(var(--safe-t) + 5px) 12px 5px; background: var(--warn); color: #1c1300; font: 650 12.5px/1.2 var(--font); text-align: center; }

/* gráficas (core/charts.js) */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-3); font: 500 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-tip { position: absolute; pointer-events: none; padding: 7px 10px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line-strong); font-size: 12.5px; font-weight: 600; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: var(--shadow-sm); z-index: 3; }
.chart-tip small { display: block; font-weight: 500; color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

/* utilidades de espacio */
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.pad-0 { padding: 0; }
.hide-mobile { display: none; }
@media (min-width: 960px) { .hide-mobile { display: initial; } .hide-desktop { display: none !important; } }

/* logotipo según el tema (ui.js logo()) */
:root[data-theme="light"] .only-dark { display: none !important; }
:root:not([data-theme="light"]) .only-light { display: none !important; }
