/* ============================================================
   MySystemFit — Base, componentes y layout
   ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-weight: var(--fw-regular);
  color: var(--text-1);
  background: var(--bg-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ================= AURORA BACKGROUND =================
   Tres orbes de luz de marca (rojo / azul / azul profundo)
   desenfocados, derivando lento tras el contenido. */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}
body::before {
  width: 60vw; height: 60vw; max-width: 900px; max-height: 900px;
  top: -22vw; left: -14vw;
  background: radial-gradient(circle at 35% 35%, var(--aurora-blue), transparent 65%);
  animation: auroraA 34s ease-in-out infinite;
}
body::after {
  width: 52vw; height: 52vw; max-width: 780px; max-height: 780px;
  bottom: -20vw; right: -12vw;
  background: radial-gradient(circle at 60% 55%, var(--aurora-red), transparent 62%);
  animation: auroraB 42s ease-in-out infinite;
}
/* Tercer orbe (azul profundo, centro-derecha) */
.aurora-deep {
  position: fixed; pointer-events: none; z-index: 0; border-radius: 50%;
  width: 46vw; height: 46vw; max-width: 700px; max-height: 700px;
  top: 30%; right: 8%;
  background: radial-gradient(circle, var(--aurora-deep), transparent 60%);
  filter: blur(100px);
  animation: auroraC 50s ease-in-out infinite;
}
@keyframes auroraA {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(9vw, 7vh, 0) scale(1.15); }
}
@keyframes auroraB {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-8vw, -9vh, 0) scale(1.12); }
}
@keyframes auroraC {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.9; }
  50% { transform: translate3d(-12vw, 10vh, 0) scale(1.2); opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .aurora-deep { animation: none; }
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* Tipografía display (Space Grotesk) en headings y cifras hero */
.page-head h1, .topbar__title, .brand__name, .drawer__name,
.modal h3, .chart-total, .kpi__value, .ring-center__val, .a-h1,
.empty h3, .section-title {
  font-family: var(--font-display);
}
.page-head h1, .a-h1 { letter-spacing: -0.04em; }
.kpi__value, .chart-total, .ring-center__val { letter-spacing: -0.03em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4152; background-clip: padding-box; }

:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: var(--r-sm); }

/* ================= LAYOUT PRINCIPAL ================= */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--s-5) var(--s-3);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-6);
}
.brand__logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gradient-brand);
  box-shadow: 0 6px 20px -6px var(--indigo-glow), 0 2px 12px -4px var(--coral-glow);
  color: #fff; flex-shrink: 0;
}
.brand__name { font-weight: var(--fw-bold); font-size: 16px; letter-spacing: -0.02em; }
.brand__name span {
  background: var(--gradient-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); font-weight: var(--fw-semi);
  padding: var(--s-4) var(--s-3) var(--s-2);
}
.nav__item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px; font-weight: var(--fw-medium);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.nav__item svg { width: 18px; height: 18px; flex-shrink: 0; position: relative; z-index: 1; }
.nav__item:hover { background: var(--surface-3); color: var(--text-1); }
.nav__item.is-active { background: var(--indigo-soft); color: var(--text-1); }
.nav__item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 3px; background: var(--indigo);
  box-shadow: 0 0 12px var(--indigo-glow);
}
.nav__icon {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  flex-shrink: 0; transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.nav__item.is-active .nav__icon {
  background: var(--indigo);
  box-shadow: 0 0 16px -2px var(--indigo-glow);
  color: #fff;
}
.nav__badge {
  margin-left: auto; font-size: 11px; font-weight: var(--fw-bold);
  background: var(--coral); color: #fff; border-radius: var(--r-full);
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
}

.sidebar__foot { margin-top: auto; }
.coach-card {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}
.coach-card__meta { min-width: 0; }
.coach-card__name { font-size: 13px; font-weight: var(--fw-semi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coach-card__plan { font-size: 11px; color: var(--text-2); }

/* ---- Avatares ---- */
.avatar {
  border-radius: var(--r-full); flex-shrink: 0; object-fit: cover;
  display: grid; place-items: center;
  font-weight: var(--fw-semi); color: #fff; font-size: 13px;
  background: linear-gradient(135deg, #3a4152, #22262f);
  border: 1px solid var(--border);
}
.avatar--sm { width: 30px; height: 30px; font-size: 12px; }
.avatar--md { width: 38px; height: 38px; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.avatar--xl { width: 84px; height: 84px; font-size: 26px; }
.avatar--ring { box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--indigo); }

/* ---- Main column ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-8);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
}
.topbar__title { font-size: 18px; font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.topbar__title small { display: block; margin-top: 4px; font-size: 12px; font-weight: var(--fw-regular); color: var(--text-3); }
.topbar__spacer { flex: 1; }

.search {
  position: relative; width: 340px; max-width: 40vw;
}
.search input {
  width: 100%; height: 40px;
  padding: 0 var(--s-4) 0 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1);
  font-size: 14px; transition: border-color var(--dur), box-shadow var(--dur);
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid var(--border); background: var(--surface);
  transition: background var(--dur), color var(--dur), transform var(--dur) var(--ease);
  position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text-1); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn__dot {
  position: absolute; top: 8px; right: 9px; min-width: 15px; height: 15px;
  background: var(--coral); border: 2px solid var(--bg-base); border-radius: var(--r-full);
  font-size: 9px; font-weight: var(--fw-bold); color: #fff; padding: 0 3px;
  display: grid; place-items: center;
}

.content {
  padding: var(--s-8);
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
}

/* ================= VIEWS ================= */
.view { display: none; animation: viewIn var(--dur-slow) var(--ease); }
.view.is-active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: var(--fw-bold); letter-spacing: -0.03em; }
.page-head p { color: var(--text-2); font-size: 14px; margin-top: 2px; }

.section-title { font-size: 15px; font-weight: var(--fw-semi); margin-bottom: var(--s-4); display: flex; align-items: center; gap: var(--s-2); }
.section-title .muted { color: var(--text-3); font-weight: var(--fw-regular); }

/* ================= BOTONES ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-4);
  border-radius: var(--r-sm); font-size: 14px; font-weight: var(--fw-semi);
  border: 1px solid transparent; white-space: nowrap;
  position: relative; overflow: hidden;
  transition: background var(--dur), border-color var(--dur), transform var(--dur) var(--ease), box-shadow var(--dur);
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px) scale(0.97); }
/* Shine diagonal que recorre los botones sólidos al hover */
.btn--primary::after, .btn--lime::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.28) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 500ms var(--ease);
  pointer-events: none;
}
.btn--primary:hover::after, .btn--lime:hover::after { transform: translateX(120%); }
.btn--primary {
  background: linear-gradient(180deg, var(--indigo-hi), var(--indigo));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 8px 24px -8px var(--indigo-glow), 0 2px 6px -2px rgba(0,0,0,0.6);
}
.btn--primary:hover {
  background: linear-gradient(180deg, var(--indigo-hi), var(--indigo-hi));
  box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 12px 32px -8px var(--indigo-glow), 0 2px 6px -2px rgba(0,0,0,0.6);
  transform: translateY(-1px);
}
.btn--lime {
  background: linear-gradient(180deg, var(--lime-hi), var(--lime));
  color: #06131C;
  box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 8px 24px -8px var(--lime-glow);
}
.btn--lime:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255,255,255,0.35) inset, 0 12px 32px -8px var(--lime-glow); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text-1); }
.btn--ghost:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn--danger { background: transparent; border-color: var(--coral); color: var(--coral); }
.btn--danger:hover { background: var(--coral-soft); }
.btn--sm { height: 32px; padding: 0 var(--s-3); font-size: 13px; }
.btn--icon { width: 40px; padding: 0; }
.btn--block { width: 100%; }
.btn--lg { height: 48px; padding: 0 var(--s-6); font-size: 15px; }

/* ================= CARDS ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
  transition: transform var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur);
}
.card--hover:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card--pad-lg { padding: var(--s-6); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); margin-bottom: var(--s-6); }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s-5);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur);
}
.kpi:hover { transform: translateY(-2px); }
.kpi--indigo { box-shadow: var(--glow-indigo); }
.kpi--lime { box-shadow: var(--glow-lime); }
.kpi--amber { box-shadow: var(--glow-amber); }
.kpi--coral { box-shadow: var(--glow-coral); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.kpi__label { font-size: 13px; color: var(--text-2); font-weight: var(--fw-medium); }
.kpi__ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi__ico svg { width: 18px; height: 18px; }
.kpi--indigo .kpi__ico { background: var(--indigo-soft); color: var(--indigo-hi); }
.kpi--lime .kpi__ico { background: var(--lime-soft); color: var(--lime); }
.kpi--amber .kpi__ico { background: var(--amber-soft); color: var(--amber); }
.kpi--coral .kpi__ico { background: var(--coral-soft); color: var(--coral); }
.kpi__value { font-family: var(--font-mono); font-size: 30px; font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: 1.1; }
.kpi__foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s-3); gap: var(--s-3); }
.kpi__delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: var(--fw-semi); font-family: var(--font-mono); }
.kpi__delta svg { width: 13px; height: 13px; }
.kpi__delta.up { color: var(--lime); }
.kpi__delta.down { color: var(--coral); }
.kpi__spark { flex: 1; max-width: 100px; height: 30px; }

/* ================= BADGES ================= */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: var(--fw-semi); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--lime); background: var(--lime-soft); }
.badge--pend { color: var(--amber); background: var(--amber-soft); }
.badge--late { color: var(--coral); background: var(--coral-soft); }
.badge--indigo { color: var(--indigo-hi); background: var(--indigo-soft); }
.badge--plan { color: var(--text-1); background: var(--surface-3); border: 1px solid var(--border); }
.badge--plan::before { display: none; }
.badge--star::before { display: none; }
.badge--star { color: var(--amber); background: var(--amber-soft); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 var(--s-3); border-radius: var(--r-full);
  font-size: 13px; font-weight: var(--fw-medium);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.pill svg { width: 15px; height: 15px; }
.pill:hover { color: var(--text-1); border-color: var(--border-strong); }
.pill.is-active { background: var(--indigo-soft); color: var(--text-1); border-color: transparent; }

/* ================= TABLA ================= */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: var(--fw-semi); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-3);
  padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border);
}
.table td { padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); font-size: 14px; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-3); }
.table tbody tr:last-child td { border-bottom: none; }
.cell-user { display: flex; align-items: center; gap: var(--s-3); }
.cell-user__name { font-weight: var(--fw-medium); }
.cell-user__sub { font-size: 12px; color: var(--text-3); }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--s-4); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }

/* ================= CHART ================= */
.chart-card { padding: var(--s-6); }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-5); flex-wrap: wrap; gap: var(--s-3); }
.chart-head h3 { font-size: 16px; font-weight: var(--fw-semi); }
.chart-total { font-family: var(--font-mono); font-size: 26px; font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.seg { display: inline-flex; background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); font-weight: var(--fw-medium); transition: background var(--dur), color var(--dur); }
.seg button.is-active { background: var(--surface-3); color: var(--text-1); }
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: var(--s-4); margin-top: var(--s-4); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }

/* Colores de gráficos ligados a tokens (anulan los atributos de presentación del SVG) */
.chart-grid-line { stroke: var(--border); }
.stop-indigo { stop-color: var(--indigo); }
.stop-lime { stop-color: var(--lime); }
.chart-line-indigo { stroke: var(--indigo); }
.chart-line-lime { stroke: var(--lime); }
.chart-line-amber { stroke: var(--amber); }
.chart-line-coral { stroke: var(--coral); }
.chart-dot-indigo { fill: var(--bg-base); stroke: var(--indigo); }

/* Tooltip interactivo sobre gráficos */
.chart-wrap { position: relative; }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  transform: translate(-50%, -120%);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 6px 10px; box-shadow: var(--shadow-md);
  font-family: var(--font-mono); font-size: 12px; font-weight: var(--fw-semi);
  white-space: nowrap; opacity: 0; transition: opacity var(--dur-fast) var(--ease);
}
.chart-tooltip.show { opacity: 1; }
.chart-hover-dot {
  position: absolute; z-index: 4; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--indigo); box-shadow: 0 0 0 4px var(--indigo-soft);
  opacity: 0; transition: opacity var(--dur-fast) var(--ease); pointer-events: none;
}
.chart-hover-dot.show { opacity: 1; }

/* Cifras "hero" con degradado de marca (rojo → azul → cian) */
.text-gradient {
  background: var(--gradient-hero);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* Tilt 3D + glare: la card rota en perspectiva y un brillo radial
   sigue al cursor (posición vía --gx/--gy desde app.js) */
.tilt { transform-style: preserve-3d; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); will-change: transform; position: relative; }
.tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(420px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, 0.10), transparent 55%);
  opacity: 0; transition: opacity var(--dur) var(--ease);
  pointer-events: none; z-index: 3;
}
.tilt:hover::after { opacity: 1; }

/* Borde de gradiente cónico animado (cards premium) */
.border-conic { position: relative; border-color: transparent !important; }
.border-conic::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  padding: 1.5px; background: var(--gradient-conic);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spinConic 5s linear infinite;
  pointer-events: none; z-index: 2;
}
@keyframes spinConic { to { --conic-angle: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  .border-conic::before { animation: none; }
}

/* Entrada escalonada de cards al activar una vista */
.view.is-active .kpi,
.view.is-active .grid-2 > .card,
.view.is-active .grid-cards > .card {
  animation: cardIn 480ms var(--ease) backwards;
}
.view.is-active .kpi:nth-child(1) { animation-delay: 0ms; }
.view.is-active .kpi:nth-child(2) { animation-delay: 60ms; }
.view.is-active .kpi:nth-child(3) { animation-delay: 120ms; }
.view.is-active .kpi:nth-child(4) { animation-delay: 180ms; }
.view.is-active .grid-2 > .card:nth-child(1) { animation-delay: 120ms; }
.view.is-active .grid-2 > .card:nth-child(2) { animation-delay: 180ms; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .view.is-active .kpi, .view.is-active .grid-2 > .card, .view.is-active .grid-cards > .card { animation: none; }
}

/* Feedback de guardado en inputs */
.ex-input input.is-saved { border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-soft); }

/* Lista de alertas / seguimientos */
.alert-list { display: flex; flex-direction: column; gap: 2px; }
.alert-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-sm); transition: background var(--dur); }
.alert-item:hover { background: var(--surface-3); }
.check {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  flex-shrink: 0; display: grid; place-items: center; transition: background var(--dur), border-color var(--dur);
  cursor: pointer; color: transparent;
}
.check svg { width: 13px; height: 13px; }
.check.is-done { background: var(--lime); border-color: var(--lime); color: #0B0D12; }
.alert-item.is-done .alert-item__txt { text-decoration: line-through; color: var(--text-3); }
.alert-item__txt { font-size: 14px; }
.alert-item__sub { font-size: 12px; color: var(--text-3); }
.alert-item__time { margin-left: auto; font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }

/* Panel de mensajes */
.messages-panel { padding: 0; overflow: hidden; height: 600px; display: grid; grid-template-columns: 300px 1fr; }
.messages-list { border-right: 1px solid var(--border); overflow-y: auto; }
.messages-thread { display: flex; flex-direction: column; min-width: 0; }
.messages-thread__body { flex: 1; padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); overflow-y: auto; }

/* Fila de pago por vencer */
.due-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.due-row:last-child { border-bottom: none; }
.due-row__meta { flex: 1; min-width: 0; }
.due-row__name { font-size: 14px; font-weight: var(--fw-medium); }
.due-row__sub { font-size: 12px; color: var(--text-3); }
.due-row__days { font-size: 12px; font-family: var(--font-mono); font-weight: var(--fw-semi); color: var(--text-3); }
.due-row__days--late,
.due-row__days--soon {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border-radius: var(--r-full);
}
.due-row__days--late { color: var(--coral); background: var(--coral-soft); }
.due-row__days--soon { color: var(--amber); background: var(--amber-soft); }

/* ================= INPUTS / FORM ================= */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field label { font-size: 13px; font-weight: var(--fw-medium); color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 var(--s-3);
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-1); font-size: 14px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { height: auto; min-height: 90px; padding: var(--s-3); resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.toggle-view { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; }
.toggle-view button { width: 36px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); transition: background var(--dur), color var(--dur); }
.toggle-view button svg { width: 16px; height: 16px; }
.toggle-view button.is-active { background: var(--surface-3); color: var(--text-1); }

/* ================= STUDENT CARD (grid) ================= */
.student-card { position: relative; }
.student-card__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.student-card__name { font-weight: var(--fw-semi); font-size: 15px; }
.student-card__sub { font-size: 12px; color: var(--text-3); }
.student-card__rows { display: flex; flex-direction: column; gap: var(--s-2); margin: var(--s-4) 0; }
.kv { display: flex; justify-content: space-between; font-size: 13px; }
.kv span:first-child { color: var(--text-3); }
.kv span:last-child { font-weight: var(--fw-medium); }
.student-card__foot { display: flex; gap: var(--s-2); margin-top: var(--s-4); }

/* ================= DRAWER (ficha alumno) ================= */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(5, 7, 11, 0.55); backdrop-filter: blur(4px);
}
.drawer-overlay.is-open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 61; height: 100vh; width: 560px; max-width: 94vw;
  background: var(--surface-2); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease); overflow-y: auto;
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { padding: var(--s-6); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-2); z-index: 2; }
.drawer__close { position: absolute; top: var(--s-5); right: var(--s-5); }
.drawer__id { display: flex; gap: var(--s-4); align-items: center; }
.drawer__name { font-size: 20px; font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.drawer__tags { display: flex; gap: var(--s-2); margin-top: var(--s-2); flex-wrap: wrap; }
.drawer__body { padding: var(--s-6); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 var(--s-6); overflow-x: auto; }
.tab { padding: var(--s-3) var(--s-3); font-size: 13px; font-weight: var(--fw-medium); color: var(--text-2); white-space: nowrap; border-bottom: 2px solid transparent; transition: color var(--dur), border-color var(--dur); }
.tab:hover { color: var(--text-1); }
.tab.is-active { color: var(--text-1); border-color: var(--indigo); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: viewIn var(--dur) var(--ease); }

/* Nota privada */
.private-note {
  border: 1.5px dashed var(--indigo); background: var(--indigo-soft);
  border-radius: var(--r-md); padding: var(--s-4);
}
.private-note__tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: var(--fw-semi); color: var(--indigo-hi); margin-bottom: var(--s-2); }
.private-note__tag svg { width: 14px; height: 14px; }

/* Comparativa antes/después */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.compare__ph { aspect-ratio: 3/4; border-radius: var(--r-md); border: 1px solid var(--border); overflow: hidden; position: relative; display: grid; place-items: center; background: linear-gradient(135deg, #191d27, #12151c); }
.compare__ph span { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: var(--fw-semi); background: rgba(0,0,0,0.5); padding: 3px 8px; border-radius: 6px; color: var(--text-1); }
.compare__ph svg { width: 34px; height: 34px; color: var(--text-3); }

.mini-stat { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3); background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-sm); }
.mini-stat__label { font-size: 12px; color: var(--text-3); }
.mini-stat__val { font-family: var(--font-mono); font-size: 20px; font-weight: var(--fw-bold); }

/* ================= ROUTINE BUILDER ================= */
.builder { display: grid; grid-template-columns: 1fr 280px; gap: var(--s-4); }
.builder__board { display: grid; grid-auto-flow: column; grid-auto-columns: 260px; gap: var(--s-4); overflow-x: auto; padding-bottom: var(--s-4); }
.day-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-3); min-height: 320px; }
.day-col__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2); }
.day-col__title { font-weight: var(--fw-semi); font-size: 14px; }
.day-col__count { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.ex-card { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s-3); cursor: grab; transition: border-color var(--dur), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease); }
.ex-card:hover { border-color: var(--indigo); transform: translateY(-1px); }
.ex-card.is-dragging { opacity: 0.35; cursor: grabbing; }
.ex-card.is-lifted {
  transform: scale(1.03) rotate(1deg);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--indigo);
  cursor: grabbing;
}
.drop-placeholder {
  border: 1.5px dashed var(--indigo); border-radius: var(--r-sm);
  background: var(--indigo-soft); min-height: 46px;
  animation: viewIn var(--dur-fast) var(--ease);
}
.day-col.is-dragover { border-color: var(--indigo); box-shadow: 0 0 0 1px var(--indigo); }
.ex-card__name { font-size: 13px; font-weight: var(--fw-semi); margin-bottom: var(--s-2); display: flex; align-items: center; gap: 6px; }
.ex-card__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ex-input { text-align: center; }
.ex-input label { display: block; font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.ex-input input { width: 100%; height: 28px; text-align: center; padding: 0 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text-1); font-family: var(--font-mono); font-size: 13px; }
.day-add { border: 1px dashed var(--border-strong); border-radius: var(--r-sm); padding: var(--s-3); color: var(--text-3); font-size: 13px; text-align: center; transition: color var(--dur), border-color var(--dur); }
.day-add:hover { color: var(--indigo-hi); border-color: var(--indigo); }
.ex-library { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); align-self: start; position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }
.ex-lib-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-sm); cursor: grab; transition: background var(--dur); }
.ex-lib-item:hover { background: var(--surface-3); }
.ex-lib-ico { width: 34px; height: 34px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--indigo-hi); flex-shrink: 0; }
.ex-lib-ico svg { width: 18px; height: 18px; }
.ex-lib-item small { display: block; font-size: 11px; color: var(--text-3); }

/* ================= EMPTY STATE ================= */
.empty { text-align: center; padding: var(--s-16) var(--s-6); }
.empty__ico { width: 64px; height: 64px; margin: 0 auto var(--s-4); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3); }
.empty__ico svg { width: 30px; height: 30px; }
.empty h3 { font-size: 16px; font-weight: var(--fw-semi); margin-bottom: 6px; }
.empty p { color: var(--text-2); font-size: 14px; max-width: 340px; margin: 0 auto var(--s-5); }

/* ================= MODAL ================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: none; place-items: center; padding: var(--s-6);
  background: rgba(5, 7, 11, 0.6); backdrop-filter: blur(6px);
}
.modal-overlay.is-open { display: grid; animation: viewIn var(--dur) var(--ease); }
.modal {
  width: 100%; max-width: 440px;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: var(--s-6);
  animation: modalIn var(--dur-slow) var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: none; } }
.modal__ico { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; margin-bottom: var(--s-4); }
.modal__ico.danger { background: var(--coral-soft); color: var(--coral); }
.modal__ico svg { width: 24px; height: 24px; }
.modal h3 { font-size: 18px; font-weight: var(--fw-bold); margin-bottom: 6px; }
.modal p { color: var(--text-2); font-size: 14px; margin-bottom: var(--s-6); }
.modal__actions { display: flex; gap: var(--s-3); }
.modal__actions .btn { flex: 1; }

/* ================= TOAST ================= */
.toast-stack { position: fixed; bottom: var(--s-6); right: var(--s-6); z-index: 90; display: flex; flex-direction: column; gap: var(--s-3); }
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 280px; max-width: 380px; padding: var(--s-3) var(--s-4);
  background: var(--surface-2); border: 1px solid var(--border); border-left-width: 3px;
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  animation: toastIn var(--dur-slow) var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut var(--dur) var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast--ok { border-left-color: var(--lime); }
.toast--err { border-left-color: var(--coral); }
.toast--info { border-left-color: var(--indigo); }
.toast__ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.toast--ok .toast__ico { background: var(--lime-soft); color: var(--lime); }
.toast--err .toast__ico { background: var(--coral-soft); color: var(--coral); }
.toast--info .toast__ico { background: var(--indigo-soft); color: var(--indigo-hi); }
.toast__ico svg { width: 16px; height: 16px; }
.toast__txt { font-size: 14px; font-weight: var(--fw-medium); }
.toast__sub { font-size: 12px; color: var(--text-2); }

/* ================= SKELETON ================= */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--r-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ================= RINGS (Apple-watch style) ================= */
.ring-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.ring-wrap::before {
  content: ""; position: absolute; inset: -30px; border-radius: 50%;
  background: radial-gradient(circle, var(--lime-glow), transparent 65%); opacity: 0.5; z-index: 0;
}
.ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; z-index: 2; }
.ring-center__val { font-family: var(--font-mono); font-size: 40px; font-weight: var(--fw-bold); line-height: 1; }
.ring-center__label { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.ring-wrap.is-celebrating { animation: ringBreathe 900ms var(--ease) 2; }
@keyframes ringBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

/* ================= CONFETTI ================= */
.confetti-burst { position: fixed; inset: 0; z-index: 200; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; border-radius: 2px;
  opacity: 0; animation: confettiFly 900ms ease-out forwards;
}
@keyframes confettiFly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: var(--confetti-end) rotate(320deg) scale(0.6); }
}

/* ================= UTILIDADES ================= */
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); }
.mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mb-4 { margin-bottom: var(--s-4); } .mb-2 { margin-bottom: var(--s-2); }
.fw-600 { font-weight: var(--fw-semi); } .fw-700 { font-weight: var(--fw-bold); }
.fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; } .fs-15 { font-size: 15px; } .fs-18 { font-size: 18px; } .fs-22 { font-size: 22px; } .fs-24 { font-size: 24px; }
.flex-1 { flex: 1; }
.card--flat { background: var(--bg-base); }
.radius-0 { border-radius: 0; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-2); }
.t3 { color: var(--text-3); }
.hidden { display: none !important; }
.text-sm { font-size: 13px; }

/* ================= NOTIFICACIONES ================= */
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 80; width: 340px; max-width: 90vw;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
}
.notif-panel.is-open { opacity: 1; visibility: visible; transform: none; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); font-size: 14px; font-weight: var(--fw-semi); }
.notif-panel__body { max-height: 380px; overflow-y: auto; padding: var(--s-2); }
.notif-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left; padding: var(--s-3); border-radius: var(--r-sm); transition: background var(--dur); position: relative; }
.notif-item:hover { background: var(--surface-3); }
.notif-item.is-unread::after { content: ""; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 7px; height: 7px; border-radius: 50%; background: var(--indigo); }
.notif-item__ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.notif-item__ico svg { width: 17px; height: 17px; }
.notif-item__ico--coral { background: var(--coral-soft); color: var(--coral); }
.notif-item__ico--amber { background: var(--amber-soft); color: var(--amber); }
.notif-item__ico--indigo { background: var(--indigo-soft); color: var(--indigo-hi); }
.notif-item__body { display: flex; flex-direction: column; min-width: 0; }
.notif-item__txt { font-size: 13px; font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item__sub { font-size: 12px; color: var(--text-3); }

/* ================= FORM GRID (modal ancho) ================= */
.modal--wide { max-width: 620px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-4); }
.form-grid .field--full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ================= SWATCHES DE COLOR ================= */
.swatches { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); transition: transform var(--dur) var(--ease), box-shadow var(--dur); position: relative; }
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; border-color: transparent; }
.swatch.is-active::after { content: ""; position: absolute; inset: 0; margin: auto; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.swatch-custom { display: inline-flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--text-2); cursor: pointer; }
.swatch-custom input[type="color"] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.swatch-custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch-custom input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .builder { grid-template-columns: 1fr; }
  .ex-library { position: static; }
}

/* ---- iPad / tablet (821–1100px): sidebar colapsado a iconos ---- */
@media (min-width: 821px) and (max-width: 1100px) {
  .sidebar { width: 78px; padding: var(--s-5) var(--s-2); align-items: center; }
  .brand { padding: var(--s-2); margin-bottom: var(--s-5); justify-content: center; }
  .brand__name { display: none; }
  .nav { width: 100%; align-items: center; }
  .nav__label { display: none; }
  .nav__item { width: 46px; height: 46px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .nav__item .nav__badge, .nav__item svg[data-lock] { position: absolute; top: 4px; right: 4px; margin: 0; }
  .nav__item.is-active::before { left: -8px; }
  .coach-card { padding: var(--s-2); justify-content: center; }
  .coach-card__meta { display: none; }
  .search { max-width: 32vw; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease); }
  .sidebar.is-open { transform: translateX(0); }
  .content { padding: var(--s-4); }
  .topbar { padding: 0 var(--s-4); }
  .search { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .menu-toggle { display: grid !important; }
  .messages-panel { grid-template-columns: 1fr; height: auto; }
  .messages-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .messages-thread__body { min-height: 320px; }
  .drawer { width: 100%; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
.menu-toggle { display: none; }

@media (max-width: 560px) {
  .content { padding: var(--s-3); }
  .btn, .icon-btn { min-height: 44px; }
  .btn--sm { min-height: 36px; }
  .nav__item { min-height: 44px; }
  .topbar { padding: 0 var(--s-3); gap: var(--s-3); }
  .topbar__title { font-size: 16px; }
  .topbar__title small { display: none; }
  .topbar__applink-txt { display: none; }
  .topbar__applink { padding: 0; width: 40px; }
  .topbar__applink svg { margin: 0 auto; }
  .brand__name { font-size: 15px; }
  .page-head { margin-bottom: var(--s-4); }
  .page-head h1 { font-size: 20px; }
  .chart-card, .card--pad-lg { padding: var(--s-4); }
  .kpi { padding: var(--s-4); }
  .kpi__value { font-size: 24px; }
  .builder__board { grid-auto-columns: 220px; }
  .modal { padding: var(--s-5); }
  .grid-cards { grid-template-columns: 1fr; }
  .toast-stack { left: var(--s-3); right: var(--s-3); bottom: var(--s-3); }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

@media (max-width: 380px) {
  .content { padding: var(--s-2); }
  .due-row { flex-wrap: wrap; }
  .due-row .btn { margin-left: auto; }
}
