/* ==============================================================
   FARMAMED Asys - Sistema visual "Hoja Clínica"
   Marco oscuro de marca + hoja de trabajo clara, tipografía Figtree
   y cifras tabulares. Mobile-first en lo estructural.

   Índice
   1. Tokens y temas          6. Formularios
   2. Base                    7. Tablas y paginación
   3. Estructura (shell)      8. Modales, toasts y alertas
   4. Topbar y notificaciones 9. Componentes de dominio
   5. Tarjetas y botones     10. Responsive y red de seguridad
   ============================================================== */

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

/* ==============================================================
   1. TOKENS Y TEMAS
   ============================================================== */
:root {
  /* Marca (el tema activo los redefine) */
  --primary: #3f7a17;
  --primary-hover: #33640f;
  --primary-light: #eef6e6;
  --primary-gradient: linear-gradient(135deg, #5a9a23 0%, #3f7a17 100%);
  --primary-shadow: rgba(63, 122, 23, 0.28);
  --on-primary: #ffffff;
  --border-focus: #5a9a23;
  --accent-lime: #84cc16;

  /* Marco de la aplicación */
  --shell-bg: #11261a;
  --shell-raised: #1b3626;
  --shell-line: rgba(255, 255, 255, 0.09);
  --shell-text: rgba(255, 255, 255, 0.74);
  --shell-text-strong: #ffffff;
  --shell-accent: #a3e635;

  --secondary: #0b63b6;
  --secondary-light: #e8f2fc;
  --accent-yellow: #facc15;
  --accent-amber: #d97706;
  --accent-red: #dc2626;

  /* Superficies */
  --bg-body: #f4f5f0;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #eff1e9;
  --border: #e1e4da;
  --border-strong: #c9cec1;

  /* Texto */
  --text-main: #16201a;
  --text-secondary: #47534b;
  --text-muted: #667168;

  /* Estados */
  --success: #047857;
  --success-bg: #e7f6ef;
  --success-border: #a7e3c9;
  --warning: #b45309;
  --warning-bg: #fdf3e0;
  --warning-border: #f4d9a4;
  --danger: #c81e1e;
  --danger-bg: #fdecec;
  --danger-border: #f7c4c4;
  --info: #1d4ed8;
  --info-bg: #e9f0fe;
  --info-border: #bfd2fa;

  /* Forma */
  --radius-xs: 0.5882rem;
  --radius-sm: 0.8235rem;
  --radius-md: 1.0588rem;
  --radius-lg: 1.4118rem;
  --radius-xl: 1.8824rem;
  --radius-full: 9999px;

  /* Elevación */
  --shadow-subtle: 0 1px 2px rgba(17, 38, 26, 0.05);
  --shadow-hover: 0 8px 24px -6px rgba(17, 38, 26, 0.14);
  --shadow-pop: 0 20px 44px -10px rgba(17, 38, 26, 0.3);
  --shadow-glow-green: 0 4px 12px rgba(17, 38, 26, 0.1);

  /* Movimiento */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;

  /* Estructura */
  --sidebar-w: 15.5294rem;
  --sheet-gap: 0.4706rem;
  --bottomnav-h: 3.7647rem;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

/* Temas claros */
body[data-theme="verde"], [data-theme="verde"] {
  --primary: #3f7a17; --primary-hover: #33640f; --primary-light: #eef6e6;
  --primary-gradient: linear-gradient(135deg, #5a9a23 0%, #3f7a17 100%);
  --primary-shadow: rgba(63, 122, 23, 0.28); --border-focus: #5a9a23; --accent-lime: #84cc16;
  --shell-bg: #11261a; --shell-raised: #1b3626; --shell-accent: #a3e635;
}
body[data-theme="azul"], [data-theme="azul"] {
  --primary: #2563eb; --primary-hover: #1d4ed8; --primary-light: #eaf1ff;
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --primary-shadow: rgba(37, 99, 235, 0.28); --border-focus: #3b82f6; --accent-lime: #38bdf8;
  --shell-bg: #0f1e3d; --shell-raised: #1a2c52; --shell-accent: #7dd3fc;
}
body[data-theme="rojo"], [data-theme="rojo"] {
  --primary: #c81e1e; --primary-hover: #a91a1a; --primary-light: #fdeeee;
  --primary-gradient: linear-gradient(135deg, #e53e3e 0%, #c81e1e 100%);
  --primary-shadow: rgba(200, 30, 30, 0.28); --border-focus: #e53e3e; --accent-lime: #f87171;
  --shell-bg: #2b1215; --shell-raised: #421d21; --shell-accent: #fda4af;
}
body[data-theme="morado"], [data-theme="morado"] {
  --primary: #7c3aed; --primary-hover: #6d28d9; --primary-light: #f3effe;
  --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  --primary-shadow: rgba(124, 58, 237, 0.28); --border-focus: #8b5cf6; --accent-lime: #a78bfa;
  --shell-bg: #1e1538; --shell-raised: #2e2250; --shell-accent: #c4b5fd;
}
body[data-theme="naranja"], [data-theme="naranja"] {
  --primary: #c2410c; --primary-hover: #a3360a; --primary-light: #fdf0e6;
  --primary-gradient: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  --primary-shadow: rgba(194, 65, 12, 0.28); --border-focus: #ea580c; --accent-lime: #fb923c;
  --shell-bg: #2b1a0e; --shell-raised: #432a18; --shell-accent: #fdba74;
}

/* Temas oscuros: base común */
body[data-theme*="-oscuro"], [data-theme*="-oscuro"] {
  --on-primary: #0b1210;
  --secondary: #60a5fa;
  --secondary-light: rgba(96, 165, 250, 0.16);
  --accent-amber: #fbbf24;
  --accent-red: #f87171;

  --bg-body: #0f1318;
  --bg-card: #181d24;
  --bg-input: #12161c;
  --bg-hover: #222831;
  --border: #2c333d;
  --border-strong: #414a57;

  --text-main: #eef1f4;
  --text-secondary: #b1bac5;
  --text-muted: #8f99a6;

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.14);
  --success-border: rgba(52, 211, 153, 0.34);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.14);
  --warning-border: rgba(251, 191, 36, 0.34);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.14);
  --danger-border: rgba(248, 113, 113, 0.34);
  --info: #93b4fb;
  --info-bg: rgba(147, 180, 251, 0.14);
  --info-border: rgba(147, 180, 251, 0.34);

  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 24px -6px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 20px 44px -10px rgba(0, 0, 0, 0.75);
  --shell-line: rgba(255, 255, 255, 0.07);
  color-scheme: dark;
}
body[data-theme="verde-oscuro"], [data-theme="verde-oscuro"] {
  --primary: #4ade80; --primary-hover: #6ee79a; --primary-light: rgba(74, 222, 128, 0.15);
  --primary-gradient: linear-gradient(135deg, #86efac 0%, #4ade80 100%);
  --primary-shadow: rgba(74, 222, 128, 0.3); --border-focus: #4ade80; --accent-lime: #84cc16;
  --shell-bg: #0a140f; --shell-raised: #15231b; --shell-accent: #4ade80;
}
body[data-theme="azul-oscuro"], [data-theme="azul-oscuro"] {
  --primary: #60a5fa; --primary-hover: #93c5fd; --primary-light: rgba(96, 165, 250, 0.16);
  --primary-gradient: linear-gradient(135deg, #93c5fd 0%, #60a5fa 100%);
  --primary-shadow: rgba(96, 165, 250, 0.3); --border-focus: #60a5fa; --accent-lime: #38bdf8;
  --shell-bg: #090f1e; --shell-raised: #141d33; --shell-accent: #60a5fa;
}
body[data-theme="rojo-oscuro"], [data-theme="rojo-oscuro"] {
  --primary: #f87171; --primary-hover: #fca5a5; --primary-light: rgba(248, 113, 113, 0.16);
  --primary-gradient: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
  --primary-shadow: rgba(248, 113, 113, 0.3); --border-focus: #f87171; --accent-lime: #f87171;
  --shell-bg: #160b0d; --shell-raised: #2a171a; --shell-accent: #f87171;
}
body[data-theme="morado-oscuro"], [data-theme="morado-oscuro"] {
  --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-light: rgba(167, 139, 250, 0.16);
  --primary-gradient: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
  --primary-shadow: rgba(167, 139, 250, 0.3); --border-focus: #a78bfa; --accent-lime: #a78bfa;
  --shell-bg: #100c1e; --shell-raised: #201a35; --shell-accent: #a78bfa;
}
body[data-theme="naranja-oscuro"], [data-theme="naranja-oscuro"] {
  --primary: #fb923c; --primary-hover: #fdba74; --primary-light: rgba(251, 146, 60, 0.16);
  --primary-gradient: linear-gradient(135deg, #fdba74 0%, #fb923c 100%);
  --primary-shadow: rgba(251, 146, 60, 0.3); --border-focus: #fb923c; --accent-lime: #fb923c;
  --shell-bg: #150e08; --shell-raised: #2a1e14; --shell-accent: #fb923c;
}

/* Tarjeta del terminal por tema */
.hikvision-credit-card { background: linear-gradient(140deg, var(--shell-raised) 0%, var(--shell-bg) 100%); }

/* ==============================================================
   2. BASE
   ============================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 106.25%; /* 17px: eleva toda la escala rem del sistema */
  -webkit-text-size-adjust: 100%;
}

/* Escala fluida para monitores grandes: toda la interfaz está en rem,
   así que subir la base mantiene las proporciones del diseño original
   (17px @1680 → ~18.3px @1920 → ~22px @2560 → tope 26px en 4K). */
@media screen and (min-width: 1680px) {
  html { font-size: clamp(1.0625rem, 0.4625rem + 0.57vw, 1.625rem); }
}

body {
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; }
a, button, label[for], select, summary, [onclick] { touch-action: manipulation; }
button, a[href], summary, [onclick], select { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.app-sidebar :focus-visible,
.bottom-nav :focus-visible { outline-color: var(--shell-accent); }

.skip-link {
  position: fixed;
  top: 0.4706rem;
  left: 0.4706rem;
  z-index: 100001;
  padding: 0.5882rem 0.9412rem;
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-weight: 700;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.i-16 { width: 0.9412rem; height: 0.9412rem; flex-shrink: 0; }
.i-18 { width: 1.0588rem; height: 1.0588rem; flex-shrink: 0; }
.i-20 { width: 1.1765rem; height: 1.1765rem; flex-shrink: 0; }

@keyframes spin { 100% { transform: rotate(360deg); } }

/* ==============================================================
   3. ESTRUCTURA (SHELL)
   ============================================================== */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--shell-bg);
  color: var(--shell-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  padding: 1.0588rem 0.7059rem 0.7059rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.7059rem;
  padding: 2px 0.4706rem 0.9412rem;
  border-bottom: 1px solid var(--shell-line);
}

.brand-logo-img {
  width: 2.4706rem;
  height: 2.4706rem;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 3px;
  flex-shrink: 0;
}

.brand-text { min-width: 0; flex: 1; }

.brand-text h1 {
  font-size: 1.06rem;
  font-weight: 800;
  color: var(--shell-text-strong);
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.brand-text span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--shell-accent);
}

.sidebar-close {
  display: none;
  width: 2.5882rem;
  height: 2.5882rem;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--shell-text-strong);
  border-radius: var(--radius-sm);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.7059rem 0 0.4706rem;
  scrollbar-width: thin;
  scrollbar-color: var(--shell-raised) transparent;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--shell-text);
  opacity: 0.75;
  padding: 0.9412rem 0.7059rem 0.3529rem;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7059rem;
  min-height: 2.4706rem;
  padding: 0.4706rem 0.7059rem;
  color: var(--shell-text);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-item svg { width: 1.1765rem; height: 1.1765rem; flex-shrink: 0; stroke-width: 1.75; }

.nav-item:hover {
  background-color: var(--shell-line);
  color: var(--shell-text-strong);
}

.nav-item.active {
  background-color: var(--shell-raised);
  color: var(--shell-text-strong);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5882rem;
  bottom: 0.5882rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--shell-accent);
}

.nav-item.active svg { color: var(--shell-accent); }

/* Pie del menú (solo en cajón móvil) */
.sidebar-footer {
  display: none;
  border-top: 1px solid var(--shell-line);
  padding-top: 0.4706rem;
}

.nav-item-danger { color: #fca5a5; }
.nav-item-danger:hover { color: #fecaca; }

/* Compatibilidad: tarjeta promocional */
.sidebar-promo-card {
  background: var(--shell-raised);
  color: #ffffff;
  padding: 0.9412rem;
  border-radius: var(--radius-md);
  margin-top: auto;
  border: 1px solid var(--shell-line);
}
.promo-badge-icon {
  width: 1.8824rem; height: 1.8824rem;
  background: var(--shell-bg);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.7059rem;
}
.sidebar-promo-card h4 { font-size: 0.92rem; font-weight: 700; margin-bottom: 0.2353rem; }
.sidebar-promo-card p { font-size: 0.76rem; color: var(--shell-text); margin-bottom: 0.7059rem; }
.sidebar-promo-btn {
  display: block; width: 100%;
  background: var(--primary); color: var(--on-primary);
  text-align: center; padding: 0.4706rem 0.7059rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem; font-weight: 700; text-decoration: none;
}
.sidebar-promo-btn:hover { background: var(--primary-hover); }

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 11, 0.6);
  z-index: 990;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.sidebar-scrim.show { opacity: 1; }

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-body);
}

.content-wrapper {
  padding: 1.4118rem clamp(0.9412rem, 2.4vw, 2.1176rem) 2.8235rem;
  display: flex;
  flex-direction: column;
  gap: 1.1765rem;
  max-width: 91.7647rem;
  width: 100%;
  margin: 0 auto;
}

/* Navegación inferior móvil */
.bottom-nav { display: none; }

/* ==============================================================
   4. TOPBAR Y NOTIFICACIONES
   ============================================================== */
.app-topbar {
  background: var(--bg-card);
  padding: 0.5882rem clamp(0.9412rem, 2.4vw, 2.1176rem);
  min-height: 3.7647rem;
  display: flex;
  align-items: center;
  gap: 0.9412rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left-area {
  display: flex;
  align-items: center;
  gap: 0.7059rem;
  min-width: 0;
  flex: 1;
}

.icon-btn.topbar-menu-btn { display: none; }

.topbar-heading { min-width: 0; }

.topbar-title {
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search-box {
  display: flex;
  align-items: center;
  gap: 0.4706rem;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.7059rem;
  height: 2.3529rem;
  width: clamp(10.5882rem, 20vw, 17.6471rem);
  flex-shrink: 1;
  color: var(--text-muted);
  transition: var(--transition);
}

.topbar-search-box:focus-within {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.topbar-search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.84rem;
  color: var(--text-main);
  width: 100%;
  min-width: 0;
}
.topbar-search-box input::placeholder { color: var(--text-muted); opacity: 1; }

.topbar-user-area {
  display: flex;
  align-items: center;
  gap: 0.4706rem;
  flex-shrink: 0;
}

.topbar-clock-pill {
  display: flex;
  align-items: center;
  gap: 0.4706rem;
  height: 2.3529rem;
  padding: 0 0.7059rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.topbar-clock-dot { width: 0.4118rem; height: 0.4118rem; border-radius: 50%; background: var(--primary); }

.icon-btn {
  width: 2.3529rem;
  height: 2.3529rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 0.4706rem;
  height: 2.3529rem;
  padding: 0 0.7059rem 0 0.2353rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}
.user-profile-pill:hover { background: var(--bg-hover); }

.user-avatar-circle {
  width: 1.8824rem;
  height: 1.8824rem;
  border-radius: var(--radius-xs);
  background: var(--shell-bg);
  color: var(--shell-accent);
  font-weight: 700;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info-text { line-height: 1.2; }
.user-info-text .name { font-size: 0.8rem; font-weight: 700; color: var(--text-main); white-space: nowrap; }
.user-info-text .role { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

/* Notificaciones del lector */
.notif-wrapper { position: relative; }
.notif-btn { position: relative; }

.notif-badge-dot {
  position: absolute;
  top: 0.4118rem;
  right: 0.4118rem;
  width: 0.4706rem;
  height: 0.4706rem;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px var(--bg-card);
  animation: pulse-live-dot 2.4s infinite ease-in-out;
}

@keyframes pulse-live-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 0.4706rem);
  right: 0;
  width: 23.5294rem;
  max-width: calc(100vw - 1.4118rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropdown-fade-in 0.18s var(--ease-out);
}
.notif-dropdown.show { display: flex; }

@keyframes dropdown-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-header {
  padding: 0.7059rem 0.9412rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4706rem;
}

.notif-device-strip {
  padding: 0.5882rem 0.9412rem;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7059rem;
}

.notif-device-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-device-info .ip-tag { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; color: var(--primary); }
.notif-device-info .status-text { font-size: 0.74rem; color: var(--text-muted); }

.notif-section-title {
  padding: 0.5882rem 0.9412rem 0.3529rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notif-list { max-height: 17.0588rem; overflow-y: auto; display: flex; flex-direction: column; }

.notif-item {
  padding: 0.5882rem 0.9412rem;
  display: flex;
  align-items: flex-start;
  gap: 0.7059rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }

.notif-item-icon {
  width: 1.8824rem;
  height: 1.8824rem;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-name { font-size: 0.82rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-meta { font-size: 0.74rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.3529rem; margin-top: 2px; flex-wrap: wrap; }

.notif-footer {
  padding: 0.5882rem 0.9412rem;
  background: var(--bg-body);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4706rem;
}
.notif-footer a { color: var(--primary); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 0.2353rem; }
.notif-footer a:hover { text-decoration: underline; }

.bg-blue { background: var(--info-bg); color: var(--info); }

/* ==============================================================
   5. TARJETAS Y BOTONES
   ============================================================== */
.card, .bento-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  position: relative;
  min-width: 0;
}
.card { overflow: hidden; }
.bento-card { padding: 1.1765rem; display: flex; flex-direction: column; }

.card-header, .bento-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7059rem;
  flex-wrap: wrap;
}
.card-header {
  padding: 0.9412rem 1.1765rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.bento-header { margin-bottom: 0.9412rem; }
.card-body { padding: 1.1765rem; }

.card-title, .bento-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4706rem;
}

/* KPIs */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.9412rem), 1fr));
  gap: 0.8235rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.0588rem 1.1765rem;
  box-shadow: var(--shadow-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7059rem;
  min-width: 0;
}

.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-info p { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.2353rem; }
.stat-info h3 { font-size: 1.85rem; font-weight: 700; line-height: 1.15; margin-bottom: 0.2353rem; color: var(--text-main); font-variant-numeric: tabular-nums; }

.stat-icon {
  width: 2.4706rem;
  height: 2.4706rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.green { background: var(--primary-light); color: var(--primary); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: #f3effe; color: #6d28d9; }
body[data-theme*="-oscuro"] .stat-icon.purple { background: rgba(192, 132, 252, 0.16); color: #c084fc; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 0.5294rem;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.35;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}
.badge-theme, .badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4706rem;
  min-height: 2.3529rem;
  padding: 0.4706rem 0.9412rem;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  transition: var(--transition);
}
.btn:active:not(:disabled) { opacity: 0.82; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--shell-bg); color: #ffffff; }
.btn-primary:hover { background: var(--shell-raised); }
body[data-theme*="-oscuro"] .btn-primary { background: var(--primary); color: var(--on-primary); }
body[data-theme*="-oscuro"] .btn-primary:hover { background: var(--primary-hover); }

.btn-green { background: var(--primary); color: var(--on-primary); }
.btn-green:hover { background: var(--primary-hover); }

.btn-danger { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.92); }
body[data-theme*="-oscuro"] .btn-danger { color: #1a0a0a; }

.btn-outline { background: var(--bg-card); border-color: var(--border-strong); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-hover); }

.btn-sm { min-height: 2.1176rem; padding: 0.3529rem 0.7059rem; font-size: 0.8rem; }
.btn-xs { min-height: 1.6471rem; padding: 3px 0.4706rem; font-size: 0.74rem; font-weight: 600; border-radius: var(--radius-xs); line-height: 1.3; }

/* Botón de ciclo de período */
.btn-period-cycle {
  display: inline-flex;
  align-items: center;
  gap: 0.4706rem;
  min-height: 2.3529rem;
  background: var(--primary);
  color: var(--on-primary);
  padding: 0.3529rem 0.7059rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.btn-period-cycle:hover { background: var(--primary-hover); }
.btn-period-cycle .cycle-icon { display: inline-flex; align-items: center; justify-content: center; }
.btn-period-cycle.is-cycling .cycle-icon { animation: cycle-spin-kf 0.4s ease; }
@keyframes cycle-spin-kf { to { transform: rotate(360deg); } }
.btn-period-cycle .period-text-wrapper { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 3.4118rem; }
.btn-period-cycle .period-tag { font-size: 0.68rem; opacity: 0.85; font-weight: 500; }
.btn-period-cycle .period-current-label { font-size: 0.86rem; font-weight: 700; display: inline-block; transition: opacity 0.18s ease; }
.btn-period-cycle.is-cycling .period-current-label { opacity: 0; }
.btn-period-cycle .cycle-next-hint { font-size: 0.74rem; background: rgba(255, 255, 255, 0.2); padding: 2px 0.4118rem; border-radius: var(--radius-xs); font-weight: 600; }

/* Pestañas */
.method-tab {
  background: transparent;
  border: 1px solid transparent;
  min-height: 2.1176rem;
  padding: 0.3529rem 0.7059rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.3529rem;
  white-space: nowrap;
}
.method-tab:hover { background: var(--bg-hover); color: var(--text-main); }
.method-tab.active { background: var(--primary-light); color: var(--primary); }

/* ==============================================================
   6. FORMULARIOS
   ============================================================== */
.form-group { margin-bottom: 0.9412rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.3529rem;
}

.form-control, .form-select {
  width: 100%;
  min-height: 2.4706rem;
  padding: 0.4706rem 0.7059rem;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  outline: none;
}
textarea.form-control { min-height: 4.9412rem; }
.form-control::placeholder { color: var(--text-muted); opacity: 1; }

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

body[data-theme*="-oscuro"] input,
body[data-theme*="-oscuro"] select,
body[data-theme*="-oscuro"] textarea { color: var(--text-main); }

.req-star, .form-label .req-star, .form-label span.req {
  color: var(--danger) !important;
  font-weight: 700 !important;
  margin-left: 3px !important;
  display: inline-block;
}

/* Chips de días laborales */
.day-chip {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  min-width: 0 !important;
  height: auto !important;
  user-select: none !important;
  cursor: pointer;
}
.day-chip input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.day-chip input[type="checkbox"]:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.day-chip span {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 2.5882rem !important;
  height: 2.3529rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: var(--radius-sm) !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text-secondary) !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  transition: var(--transition) !important;
}
.day-chip:hover span { border-color: var(--primary) !important; color: var(--primary) !important; }
.day-chip.active span,
.day-chip:has(input[type="checkbox"]:checked) span,
.day-chip input[type="checkbox"]:checked + span {
  background: var(--primary) !important;
  color: var(--on-primary) !important;
  border-color: var(--primary) !important;
  font-weight: 700 !important;
}

.preset-day-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.2353rem 0.5882rem;
  border-radius: var(--radius-xs);
  line-height: 1.3;
  transition: var(--transition);
}
.preset-day-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* Selector visual de tema */
.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.2941rem), 1fr));
  gap: 0.7059rem;
  margin-top: 0.8235rem;
}
.theme-card-option {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.8235rem 0.5882rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4706rem;
  background: var(--bg-card);
  transition: var(--transition);
  position: relative;
  text-align: center;
  cursor: pointer;
}
.theme-card-option:hover { border-color: var(--primary); }
.theme-card-option.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-light); }
.theme-color-circle {
  width: 2.3529rem;
  height: 2.3529rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.05rem;
  position: relative;
}
.theme-circle-split { border: 2px solid rgba(255, 255, 255, 0.3); }
.theme-color-circle .check-mark { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
.theme-card-name { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }

/* ==============================================================
   7. TABLAS Y PAGINACIÓN
   ============================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.table th {
  background: var(--bg-body);
  padding: 0.5882rem 0.9412rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.7059rem 0.9412rem;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }

.table-pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.7059rem;
  padding: 0.7059rem 1.1765rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}
.pagination-left, .pagination-right { display: flex; align-items: center; gap: 0.7059rem; flex-wrap: wrap; }
.pagination-info { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.pagination-info strong { color: var(--text-main); font-weight: 700; }
.pagination-size-wrapper { display: flex; align-items: center; gap: 0.3529rem; font-size: 0.8rem; color: var(--text-secondary); }
.pagination-size-select {
  padding: 0.2941rem 0.4706rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  outline: none;
}
.pagination-size-select:focus { border-color: var(--border-focus); }
.pagination-nav { display: inline-flex; align-items: center; gap: 0.2353rem; flex-wrap: wrap; }
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1176rem;
  height: 2.1176rem;
  padding: 0 0.4706rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  transition: var(--transition);
  user-select: none;
  cursor: pointer;
}
.pagination-btn:hover:not(:disabled):not(.active) { background: var(--bg-hover); border-color: var(--border-focus); color: var(--primary); }
.pagination-btn.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary) !important; font-weight: 700; }
.pagination-btn:disabled, .pagination-btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; background: var(--bg-body); }
.pagination-ellipsis { display: inline-flex; align-items: center; justify-content: center; width: 1.5294rem; height: 2.1176rem; font-size: 0.85rem; color: var(--text-muted); user-select: none; }

/* ==============================================================
   8. MODALES, TOASTS Y ALERTAS
   ============================================================== */
.modal-backdrop, .permiso-modal-overlay, .reports-modal-overlay, #modalPunches, #modalRawPunches {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 11, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.9412rem;
  z-index: 999;
}
.modal-backdrop.show { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 31.7647rem;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
  animation: modal-in 0.2s var(--ease-out);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  padding: 0.9412rem 1.1765rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7059rem;
}
.modal-body { padding: 1.1765rem; }
.modal-footer {
  padding: 0.8235rem 1.1765rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5882rem;
  flex-wrap: wrap;
  background: var(--bg-body);
}

/* Toasts */
#toastContainer {
  position: fixed;
  top: 1.1765rem;
  right: 1.1765rem;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 0.5882rem;
  max-width: 24.7059rem;
  width: calc(100vw - 2.3529rem);
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.7059rem;
  padding: 0.8235rem 0.9412rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: toastSlideIn 0.28s var(--ease-out) forwards;
}
.toast-item.toast-leave { animation: toastSlideOut 0.18s ease-in forwards; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(24px); }
}

.toast-icon-box { width: 2rem; height: 2rem; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-success .toast-icon-box { background: var(--success-bg); color: var(--success); }
.toast-danger .toast-icon-box, .toast-error .toast-icon-box { background: var(--danger-bg); color: var(--danger); }
.toast-warning .toast-icon-box { background: var(--warning-bg); color: var(--warning); }
.toast-info .toast-icon-box { background: var(--info-bg); color: var(--info); }

.toast-content { flex: 1; min-width: 0; }
.toast-title { font-size: 0.86rem; font-weight: 700; color: var(--text-main); margin-bottom: 2px; line-height: 1.25; }
.toast-message { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.45; overflow-wrap: anywhere; }
.toast-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.2353rem;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.toast-close-btn:hover { color: var(--text-main); background: var(--bg-hover); }
.toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--bg-hover); width: 100%; }
.toast-progress-bar { height: 100%; width: 100%; transition: width linear; }
.toast-success .toast-progress-bar { background: var(--success); }
.toast-danger .toast-progress-bar, .toast-error .toast-progress-bar { background: var(--danger); }
.toast-warning .toast-progress-bar { background: var(--warning); }
.toast-info .toast-progress-bar { background: var(--primary); }

/* Alertas en página */
.alert-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.7059rem;
  padding: 0.8235rem 0.9412rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.1765rem;
  animation: alertFadeIn 0.22s ease-out;
}
@keyframes alertFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.alert-card-success { background: var(--success-bg); border: 1px solid var(--success-border); }
.alert-card-danger, .alert-card-error { background: var(--danger-bg); border: 1px solid var(--danger-border); }
.alert-card-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); }
.alert-card-info { background: var(--info-bg); border: 1px solid var(--info-border); }

.alert-card-icon { width: 1.8824rem; height: 1.8824rem; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--bg-card); }
.alert-card-success .alert-card-icon, .alert-card-success .alert-card-title, .alert-card-success .alert-card-text { color: var(--success); }
.alert-card-danger .alert-card-icon, .alert-card-error .alert-card-icon, .alert-card-danger .alert-card-title, .alert-card-error .alert-card-title, .alert-card-danger .alert-card-text, .alert-card-error .alert-card-text { color: var(--danger); }
.alert-card-warning .alert-card-icon, .alert-card-warning .alert-card-title, .alert-card-warning .alert-card-text { color: var(--warning); }
.alert-card-info .alert-card-icon, .alert-card-info .alert-card-title, .alert-card-info .alert-card-text { color: var(--info); }

.alert-card-content { flex: 1; min-width: 0; }
.alert-card-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; }
.alert-card-text { font-size: 0.82rem; font-weight: 500; line-height: 1.45; }
.alert-card-close {
  background: transparent;
  border: none;
  padding: 0.2353rem;
  border-radius: var(--radius-xs);
  opacity: 0.7;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.alert-card-close:hover { opacity: 1; color: var(--text-main); }

/* ==============================================================
   9. COMPONENTES DE DOMINIO
   ============================================================== */
/* Tarjeta del terminal Hikvision */
.hikvision-credit-card {
  border-radius: var(--radius-lg);
  padding: 1.1765rem;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--shell-line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 10.5882rem;
}
.card-chip { width: 2.1176rem; height: 1.5294rem; background: var(--shell-accent); border-radius: var(--radius-xs); margin-bottom: 0.9412rem; }
.card-num { font-family: var(--font-mono); font-size: 1rem; letter-spacing: 2px; font-weight: 600; margin-bottom: 0.7059rem; overflow-wrap: anywhere; }
.card-holder { display: flex; align-items: center; justify-content: space-between; gap: 0.4706rem; font-size: 0.76rem; opacity: 0.92; }

/* Acciones rápidas */
.quick-action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5882rem; margin-top: 0.9412rem; }
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3529rem;
  min-height: 4.2353rem;
  padding: 0.5882rem 0.3529rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
  transition: var(--transition);
}
.quick-action-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.quick-action-btn svg { width: 1.2941rem; height: 1.2941rem; }

/* Avatares */
.avatars-quick-row { display: flex; align-items: center; justify-content: space-between; gap: 0.4706rem; padding-top: 0.5882rem; flex-wrap: wrap; }
.avatar-person-item { display: flex; flex-direction: column; align-items: center; gap: 0.3529rem; text-decoration: none; cursor: pointer; }
.avatar-wrapper {
  width: 2.8235rem;
  height: 2.8235rem;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-main);
  position: relative;
  font-size: 0.95rem;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--border);
  transition: var(--transition);
}
.avatar-person-item:hover .avatar-wrapper { box-shadow: 0 0 0 2px var(--primary); }
.avatar-dot-online { width: 0.6471rem; height: 0.6471rem; background: var(--primary); border: 2px solid var(--bg-card); border-radius: 50%; position: absolute; bottom: 0; right: 0; }
.avatar-name-label { font-size: 0.74rem; font-weight: 600; color: var(--text-main); }

/* Progreso segmentado */
.segmented-progress-bar { display: flex; gap: 3px; height: 0.7059rem; margin: 0.8235rem 0 0.4706rem; }
.segment-item { flex: 1; border-radius: 3px; background: var(--bg-hover); }
.segment-item.active-green { background: var(--accent-lime); }
.segment-item.active-darkgreen { background: var(--primary); }
.segment-item.active-yellow { background: #facc15; }
.segment-item.active-amber { background: #f59e0b; }

/* Actividad reciente */
.transaction-list { display: flex; flex-direction: column; gap: 0.2353rem; }
.transaction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7059rem;
  padding: 0.5882rem 0.7059rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.transaction-row:hover { background: var(--bg-hover); }
.tx-left { display: flex; align-items: center; gap: 0.7059rem; min-width: 0; }
.tx-icon-box { width: 2.3529rem; height: 2.3529rem; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.tx-icon-box.green { background: var(--primary-light); color: var(--primary); }
.tx-icon-box.blue { background: var(--secondary-light); color: var(--secondary); }
.tx-icon-box.amber { background: var(--warning-bg); color: var(--warning); }
.tx-icon-box.dark { background: var(--shell-bg); color: #ffffff; }
.tx-info { min-width: 0; }
.tx-info h5 { font-size: 0.86rem; font-weight: 700; color: var(--text-main); margin-bottom: 1px; }
.tx-info p { font-size: 0.76rem; color: var(--text-muted); }
.tx-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 0.2353rem; flex-shrink: 0; }
.tx-time { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--text-main); }

/* Respaldo y restauración */
.backup-tabs { display: flex; gap: 0.2353rem; border-bottom: 1px solid var(--border); padding: 0 1.1765rem; background: var(--bg-body); overflow-x: auto; scrollbar-width: none; }
.backup-tab-btn {
  padding: 0.7059rem 0.8235rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.84rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4706rem;
  white-space: nowrap;
  position: relative;
  top: 1px;
  transition: var(--transition);
}
.backup-tab-btn:hover { color: var(--text-main); }
.backup-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.backup-tab-badge { background: var(--primary-light); color: var(--primary); font-size: 0.72rem; font-weight: 700; padding: 2px 0.4118rem; border-radius: var(--radius-xs); }

.backup-type-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.8235rem;
  background: var(--bg-card);
  display: flex;
  align-items: flex-start;
  gap: 0.7059rem;
  transition: var(--transition);
  cursor: pointer;
}
.backup-type-card:hover { border-color: var(--primary); }
.backup-type-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: inset 0 0 0 1px var(--primary); }

.backup-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.8824rem 1.1765rem;
  text-align: center;
  background: var(--bg-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  cursor: pointer;
}
.backup-dropzone:hover, .backup-dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }

.backup-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7059rem;
  flex-wrap: wrap;
  padding: 0.7059rem 0.8235rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: var(--transition);
}
.backup-file-item:hover { border-color: var(--border-strong); }

/* Pantallas de acceso (login y recuperar) */
.auth-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(27.0588rem, 40%);
  padding: 0.8235rem;
  overflow: hidden;
  background:
    radial-gradient(70% 60% at 12% 4%, color-mix(in srgb, var(--primary) 46%, transparent), transparent 70%),
    radial-gradient(60% 55% at 62% 104%, color-mix(in srgb, var(--shell-accent) 26%, transparent), transparent 70%),
    var(--shell-bg);
}

.auth-brand {
  position: relative;
  color: var(--shell-text);
  padding: clamp(1.4118rem, 4vw, 3.2941rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2.3529rem;
  min-width: 0;
}
.auth-brand > :not(.auth-print) { position: relative; z-index: 1; }

/* Huella de fondo: se dibuja al entrar y un haz la recorre */
.auth-print {
  position: absolute;
  right: -16%;
  bottom: -34%;
  width: min(72vh, 44vw);
  height: auto;
  stroke-width: 0.2;
  pointer-events: none;
}
.auth-print-base { stroke: var(--shell-accent); opacity: 0.3; }
.auth-print-base path { stroke-dasharray: 1; animation: authDraw 1.8s cubic-bezier(.33, 0, .2, 1) both; }
.auth-print-glow { stroke: #ffffff; stroke-width: 0.26; opacity: 0.85; }
.auth-print-beam { animation: authScan 5.5s cubic-bezier(.45, 0, .55, 1) 1.2s infinite both; }

.auth-brand-mark { display: flex; align-items: center; gap: 0.8235rem; color: var(--shell-text-strong); font-weight: 800; font-size: 1.12rem; letter-spacing: 0.01em; }
.auth-brand-mark em { font-style: normal; font-weight: 500; opacity: 0.72; }
.auth-brand-mark img { width: 3.0588rem; height: 3.0588rem; object-fit: contain; background: #ffffff; border-radius: var(--radius-sm); padding: 0.2353rem; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32); }

.auth-clock { margin-bottom: clamp(1.1765rem, 3vh, 2rem); }
.auth-clock-time {
  display: flex;
  align-items: baseline;
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: clamp(3.4rem, 7.4vw, 6.4rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--shell-text-strong);
  font-variant-numeric: tabular-nums;
}
.auth-clock-time i { margin: 0 -0.1em; font-style: normal; color: var(--shell-accent); animation: authBlink 2s steps(1) infinite; }
.auth-clock-time small { margin-left: 0.28em; font-size: 0.24em; font-weight: 600; letter-spacing: 0.06em; color: var(--shell-accent); }
.auth-clock-date { display: block; margin-top: 0.7059rem; font-size: 1rem; font-weight: 500; color: var(--shell-text); }
.auth-clock-date::first-letter { text-transform: uppercase; }

.auth-brand-headline { font-size: clamp(1.75rem, 3vw, 2.75rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.02em; color: var(--shell-text-strong); max-width: 14em; text-wrap: balance; }
.auth-brand-copy { margin-top: 0.7059rem; font-size: 1rem; line-height: 1.55; max-width: 30em; }

.auth-brand-points { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4706rem; font-size: 0.82rem; font-weight: 600; color: var(--shell-text-strong); }
.auth-brand-points li {
  padding: 0.4706rem 0.8235rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
}

/* Hoja del formulario: la misma hoja clara del resto de la aplicación */
.auth-panel {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.6471rem, 5vw, 3.7647rem);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}
.auth-card, .login-container { width: 100%; max-width: 24.1176rem; }
.auth-card > * { animation: authRise 0.55s cubic-bezier(.2, .7, .2, 1) both; }
.auth-card > :nth-child(2) { animation-delay: 0.05s; }
.auth-card > :nth-child(3) { animation-delay: 0.1s; }
.auth-card > :nth-child(4) { animation-delay: 0.15s; }
.auth-card > :nth-child(5) { animation-delay: 0.2s; }

.auth-eyebrow { display: inline-flex; align-items: center; gap: 0.4706rem; margin-bottom: 0.7059rem; font-size: 0.8rem; font-weight: 700; color: var(--primary); }
.auth-eyebrow::before { content: ""; width: 0.4706rem; height: 0.4706rem; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }
.auth-title { font-size: clamp(1.8rem, 3vw, 2.25rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.02em; color: var(--text-main); margin-bottom: 0.4706rem; }
.auth-subtitle { font-size: 0.96rem; line-height: 1.5; color: var(--text-secondary); margin-bottom: 1.6471rem; }
.auth-footnote { display: flex; align-items: center; justify-content: center; gap: 0.4706rem; margin-top: 1.5294rem; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.auth-card .form-label { font-weight: 600; margin-bottom: 0.4706rem; }
.auth-card .form-control {
  min-height: 3.1765rem;
  border-radius: var(--radius-md);
  background: var(--bg-body);
  border: 1.5px solid transparent;
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 1rem;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.auth-card .form-control:hover { box-shadow: inset 0 0 0 1px var(--text-muted); }
.auth-card .form-control:focus {
  background: var(--bg-card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
  outline: none;
}
.auth-field { position: relative; }
.auth-field > svg { position: absolute; left: 1rem; top: 50%; width: 1.1765rem; height: 1.1765rem; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; transition: color 0.18s ease; }
.auth-field:focus-within > svg { color: var(--primary); }
.auth-field .form-control { padding-left: 2.9412rem; padding-right: 2.9412rem; }

.auth-hint { display: flex; align-items: center; gap: 0.3529rem; margin-top: 0.4706rem; font-size: 0.8rem; font-weight: 600; color: var(--warning, #b45309); }
.auth-hint[hidden] { display: none; }

.auth-options { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5882rem 0.9412rem; margin-bottom: 1.4118rem; font-size: 0.875rem; }
.auth-options a { color: var(--primary); font-weight: 600; text-decoration: none; white-space: nowrap; }
.auth-options a:hover { text-decoration: underline; }

.ui-switch { display: inline-flex; align-items: center; gap: 0.5882rem; cursor: pointer; color: var(--text-main); user-select: none; }
.ui-switch input {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 2.4706rem;
  height: 1.4118rem;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong, #c9cdd3);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.ui-switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 1.0588rem;
  height: 1.0588rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(.2, .7, .2, 1);
}
.ui-switch input:checked { background: var(--primary); }
.ui-switch input:checked::after { transform: translateX(1.0588rem); }

.auth-submit {
  width: 100%;
  min-height: 3.2941rem;
  gap: 0.5882rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--on-primary, #ffffff);
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--primary) 34%, transparent);
  transition: transform 0.16s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.auth-submit:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 18px 36px color-mix(in srgb, var(--primary) 42%, transparent); }
.auth-submit:active { transform: translateY(0) scale(0.99); }
.auth-submit svg { width: 1.1765rem; height: 1.1765rem; transition: transform 0.2s ease; }
.auth-submit:hover svg { transform: translateX(3px); }
.auth-submit .auth-spinner { display: none; }
.auth-submit.is-loading { pointer-events: none; filter: saturate(0.8); }
.auth-submit.is-loading .auth-arrow { display: none; }
.auth-submit.is-loading .auth-spinner { display: block; animation: authSpin 0.8s linear infinite; }

@keyframes authDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes authScan { 0% { transform: translateY(0); } 60%, 100% { transform: translateY(31px); } }
@keyframes authRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes authBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.35; } }
@keyframes authSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .auth-print-base path, .auth-card > *, .auth-clock-time i { animation: none; }
  .auth-print-glow { display: none; }
  .auth-print-base path { stroke-dashoffset: 0; }
}

.password-toggle svg[hidden] { display: none; }
.password-wrapper { position: relative; }
.password-toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2.3529rem;
  height: 2.3529rem;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Recuadros con radio escrito a mano en las vistas: siguen la misma escala */
[style*="border-radius: 10px"],
[style*="border-radius: 12px"],
[style*="border-radius: 14px"] { border-radius: var(--radius-md) !important; }

.alert { padding: 0.7059rem 0.8235rem; border-radius: var(--radius-sm); font-size: 0.84rem; font-weight: 500; margin-bottom: 1.0588rem; display: flex; align-items: center; gap: 0.5882rem; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }

/* ==============================================================
   10. RESPONSIVE
   Los breakpoints se limitan a pantalla: la impresión tiene su
   propio bloque al final.
   ============================================================== */

/* Escritorio: el marco oscuro abraza una hoja con desplazamiento propio */
@media screen and (min-width: 993px) {
  body { background: var(--shell-bg); }
  .app-container { height: 100vh; height: 100dvh; overflow: hidden; }
  .app-sidebar { height: 100%; }
  .app-main {
    height: calc(100% - var(--sheet-gap) * 2);
    margin: var(--sheet-gap) var(--sheet-gap) var(--sheet-gap) 0;
    border-radius: var(--radius-xl);
    overflow-x: hidden;
    overflow-y: auto;
  }
  body.auth-body { background: var(--shell-bg); }
}

/* Pantallas medianas: se libera espacio en la barra superior */
@media screen and (max-width: 1280px) {
  .topbar-subtitle, .topbar-clock-pill { display: none; }
  .dashboard-bento-grid { grid-template-columns: minmax(0, 1fr) !important; }
}

/* Rejillas en línea de dos zonas: se apilan en tableta */
@media screen and (max-width: 992px) {
  .content-wrapper [style*="grid-template-columns: 2fr 1fr"],
  .content-wrapper [style*="grid-template-columns: 2.2fr 1fr"],
  .content-wrapper [style*="grid-template-columns: 1.2fr 1.8fr"],
  .content-wrapper [style*="grid-template-columns: 1.25fr 1fr"],
  .content-wrapper [style*="grid-template-columns: 290px 1fr"],
  .content-wrapper [style*="minmax(460px"],
  .content-wrapper [style*="minmax(440px"],
  .content-wrapper [style*="minmax(320px"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Tableta y móvil: cajón lateral + barra inferior */
  html, body { overflow-x: clip; }

  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(17.6471rem, 86vw);
    z-index: 1000;
    overflow-y: auto;
    padding-bottom: calc(0.7059rem + env(safe-area-inset-bottom));
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.26s var(--ease-out), visibility 0s linear 0.26s;
  }
  .app-sidebar.open {
    transform: none;
    visibility: visible;
    transition: transform 0.26s var(--ease-out), visibility 0s;
    box-shadow: var(--shadow-pop);
  }
  .sidebar-close { display: inline-flex; }
  .sidebar-footer { display: block; }
  .sidebar-nav { flex: 1 0 auto; overflow: visible; }
  .sidebar-scrim.is-mounted:not([hidden]) { display: block; }
  .nav-item { min-height: 2.7059rem; }

  body.nav-locked { overflow: hidden; }

  .app-topbar { position: static; min-height: 3.4118rem; padding: 0.4706rem 0.9412rem; flex-wrap: wrap; gap: 0.4706rem 0.5882rem; }
  .icon-btn.topbar-menu-btn { display: flex; }
  .topbar-title { font-size: 1rem; }
  .topbar-search-box { order: 3; width: 100%; height: 2.5882rem; }
  body:not(:has(.content-wrapper table)) .topbar-search-box { display: none; }
  .topbar-settings, .topbar-logout { display: none; }
  .user-info-text { display: none; }
  .user-profile-pill { padding: 0; border: none; background: transparent; height: 2.5882rem; }
  .user-avatar-circle { width: 2.1176rem; height: 2.1176rem; }
  .icon-btn { width: 2.5882rem; height: 2.5882rem; }

  .content-wrapper {
    padding: 0.9412rem 0.9412rem calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 1.4118rem);
    gap: 0.9412rem;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--shell-bg);
    border-top: 1px solid var(--shell-line);
    z-index: 900;
  }
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--shell-text);
    font-size: 0.68rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
  }
  .bottom-nav-item svg { width: 1.2941rem; height: 1.2941rem; stroke-width: 1.75; }
  .bottom-nav-item.active { color: var(--shell-text-strong); font-weight: 700; }
  .bottom-nav-item.active svg { color: var(--shell-accent); }

  /* Notificaciones como hoja inferior */
  .notif-dropdown {
    position: fixed;
    top: auto;
    left: 0.4706rem;
    right: 0.4706rem;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 0.4706rem);
    width: auto;
    max-width: none;
    max-height: 72vh;
    max-height: 72dvh;
    overflow-y: auto;
  }
  .notif-device-strip, .notif-footer { flex-wrap: wrap; }

  /* El lanzador de toasts se mueve sobre la barra inferior */
  #toastContainer {
    top: auto;
    right: 0.4706rem;
    left: 0.4706rem;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 0.4706rem);
    width: auto;
    max-width: none;
  }
}

@media screen and (max-width: 768px) {
  /* Evita el zoom automático de iOS al enfocar campos */
  .form-control, .form-select, .topbar-search-box input,
  .content-wrapper input:not([type="checkbox"]):not([type="radio"]),
  .content-wrapper select, .content-wrapper textarea,
  .modal-box input:not([type="checkbox"]):not([type="radio"]),
  .modal-box select, .modal-box textarea { font-size: 16px; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5882rem; }
  .stat-card { padding: 0.8235rem; }
  .stat-info h3 { font-size: 1.5rem; }
  .stat-icon { width: 2.1176rem; height: 2.1176rem; }

  /* Modales como hoja anclada abajo */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-box { max-width: none !important; border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 92vh; max-height: 92dvh; }
  .modal-footer { padding-bottom: calc(0.8235rem + env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1 1 auto; }

  .card-header { padding: 0.8235rem 0.9412rem; }
  .card-body, .bento-card { padding: 0.9412rem; }

  /* Botones táctiles */
  .btn, .btn-sm { min-height: 2.5882rem; }
  .pagination-btn { min-width: 2.5882rem; height: 2.5882rem; }
  .pagination-ellipsis { height: 2.5882rem; }

  /* Pantalla de acceso a una columna */
  .auth-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; padding: 0; }
  .auth-brand { padding: 1.2941rem 1.2941rem 1.7647rem; gap: 1.2941rem; }
  .auth-brand-copy, .auth-brand-points { display: none; }
  .auth-print { right: -18%; top: -12%; bottom: auto; width: min(82vw, 25.8824rem); }
  .auth-clock { margin-bottom: 0.8235rem; }
  .auth-clock-time { font-size: clamp(2.9rem, 13vw, 4.2rem); }
  .auth-clock-date { margin-top: 0.4706rem; font-size: 0.92rem; }
  .auth-brand-headline { font-size: clamp(1.2rem, 4.4vw, 1.6rem); }
  .auth-panel { align-items: flex-start; padding: 1.8824rem 1.2941rem calc(2.1176rem + env(safe-area-inset-bottom)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.28); }
  .auth-card { margin: 0 auto; }
  .auth-title { font-size: 1.75rem; }
  .auth-subtitle { margin-bottom: 1.2941rem; }
}

/* Teléfono: rejillas en línea, tablas como tarjetas */
@media screen and (max-width: 640px) {
  .content-wrapper [style*="grid-template-columns: 1fr 1fr"],
  .content-wrapper [style*="grid-template-columns: repeat(2, 1fr)"],
  .content-wrapper [style*="grid-template-columns: repeat(3, 1fr)"],
  .content-wrapper [style*="grid-template-columns: 2fr 1fr 1fr"],
  .modal-box [style*="grid-template-columns: 1fr 1fr"],
  .modal-box [style*="grid-template-columns: repeat(2, 1fr)"],
  .modal-box [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .content-wrapper [style*="grid-template-columns: repeat(4, 1fr)"],
  .content-wrapper [style*="minmax(165px"],
  .content-wrapper [style*="minmax(200px"],
  .content-wrapper [style*="minmax(210px"],
  .content-wrapper [style*="minmax(220px"],
  .content-wrapper [style*="minmax(230px"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .content-wrapper [style*="minmax(260px"],
  .content-wrapper [style*="minmax(280px"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .quick-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Las barras de acciones con muchos botones envuelven */
  .card-header > div, .bento-header > div { flex-wrap: wrap; min-width: 0; }

  .table-pagination-container { flex-direction: column; align-items: stretch; text-align: center; padding: 0.7059rem 0.9412rem; }
  .pagination-left, .pagination-right { justify-content: center; width: 100%; }

  /* Tablas con pocas columnas se leen como tarjetas */
  .dashboard-kpi-icon, .stat-card .stat-icon { display: none !important; }
  table.table--cards { min-width: 0 !important; }
  table.table--cards, table.table--cards tbody { display: block; width: 100%; }
  table.table--cards thead { display: none; }
  table.table--cards tbody tr {
    display: block;
    padding: 0.2353rem 0.9412rem 0.5882rem;
    border-bottom: 1px solid var(--border);
  }
  table.table--cards tbody tr:hover { background: transparent; }
  table.table--cards tbody td {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.2353rem 0.9412rem;
    padding: 0.4118rem 0;
    border-bottom: none;
    text-align: right;
    min-width: 0;
    width: auto !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  table.table--cards tbody td > * { max-width: 100%; min-width: 0; }

  .calendar-controls-group { flex-wrap: wrap; max-width: 100%; min-width: 0; }
  .calendar-nav-pill { max-width: 100%; min-width: 0; }
  table.table--cards tbody td::before {
    content: attr(data-label);
    flex-shrink: 0;
    max-width: 45%;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
  }
  table.table--cards tbody td:first-child { justify-content: flex-start; text-align: left; font-weight: 600; padding-top: 0.5882rem; }
  table.table--cards tbody td:first-child::before,
  table.table--cards tbody td[data-label=""]::before,
  table.table--cards tbody td[colspan]::before { display: none; }
  table.table--cards tbody td[colspan] { display: block; text-align: center; }
  table.table--cards tbody td[data-label=""]:not(:first-child) { justify-content: flex-end; flex-wrap: wrap; }
}

/* Teléfonos pequeños */
@media screen and (max-width: 380px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .bottom-nav-item { font-size: 0.64rem; }
}

/* Modo oscuro: neutraliza colores fijos escritos en las vistas */
body[data-theme*="-oscuro"] [style*="background: #ffffff"],
body[data-theme*="-oscuro"] [style*="background:#ffffff"],
body[data-theme*="-oscuro"] [style*="background: #fff;"],
body[data-theme*="-oscuro"] [style*="background: white"] { background: var(--bg-card) !important; }
body[data-theme*="-oscuro"] [style*="background: #f3f4f6"],
body[data-theme*="-oscuro"] [style*="background: #f8fafc"],
body[data-theme*="-oscuro"] [style*="background: #f1f5f9"],
body[data-theme*="-oscuro"] [style*="background: #f9fafb"] { background: var(--bg-hover) !important; }
body[data-theme*="-oscuro"] [style*="background: #fef2f2"] { background: var(--danger-bg) !important; }
body[data-theme*="-oscuro"] [style*="background: #ecfdf5"] { background: var(--success-bg) !important; }
body[data-theme*="-oscuro"] [style*="background: #fffbeb"] { background: var(--warning-bg) !important; }
body[data-theme*="-oscuro"] [style*=" color: #111827"],
body[data-theme*="-oscuro"] [style^="color: #111827"],
body[data-theme*="-oscuro"] [style*=";color: #111827"],
body[data-theme*="-oscuro"] [style*=" color: #1e293b"],
body[data-theme*="-oscuro"] [style^="color: #1e293b"] { color: var(--text-main) !important; }
body[data-theme*="-oscuro"] [style*=" color: #4b5563"],
body[data-theme*="-oscuro"] [style^="color: #4b5563"],
body[data-theme*="-oscuro"] [style*=" color: #475569"],
body[data-theme*="-oscuro"] [style^="color: #475569"] { color: var(--text-secondary) !important; }
body[data-theme*="-oscuro"] [style*=" color: #991b1b"],
body[data-theme*="-oscuro"] [style*=" color: #7f1d1d"] { color: var(--danger) !important; }
body[data-theme*="-oscuro"] [style*=" color: #166534"] { color: var(--success) !important; }
body[data-theme*="-oscuro"] [style*="background: var(--primary)"][style*="color: #fff"] { color: var(--on-primary) !important; }

/* Accesibilidad: movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Impresión: desaparece el marco y todo el contenido fluye en blanco */
@media print {
  html { font-size: 100%; }
  body { background: #ffffff !important; }
  .app-sidebar, .app-topbar, .bottom-nav, .sidebar-scrim, #toastContainer, .table-pagination-container { display: none !important; }
  .app-container, .app-main { display: block; height: auto !important; overflow: visible !important; margin: 0 !important; border-radius: 0 !important; background: #ffffff !important; }
  .content-wrapper { padding: 0 !important; max-width: none; }
  .card, .bento-card, .stat-card { box-shadow: none; }
  .table tbody tr[data-paged-hidden] { display: table-row !important; }
}

/* Marcas por revisar */
.nav-badge { margin-left: auto; min-width: 1.2941rem; padding: 1px 0.4118rem; border-radius: var(--radius-full); background: var(--shell-accent); color: var(--shell-bg); font-size: 0.72rem; font-style: normal; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.review-list { list-style: none; margin: 0; padding: 0; }
.review-item { display: flex; align-items: center; justify-content: space-between; gap: 1.1765rem; padding: 1.0588rem 1.2941rem; border-top: 1px solid var(--border); }
.review-main { min-width: 0; flex: 1; }
.review-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4706rem 0.5882rem; color: var(--text-main); }
.review-meta { margin: 0.2353rem 0 0; font-size: 0.8rem; color: var(--text-muted); }
.review-detail { margin: 0.3529rem 0 0; font-size: 0.875rem; color: var(--text-secondary); line-height: 1.45; }
.review-actions, .review-form { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4706rem; }
.review-actions { justify-content: flex-end; flex-shrink: 0; }
.review-form .form-control { width: 7.6471rem; }
.review-empty { padding: 3.2941rem 1.1765rem; text-align: center; color: var(--text-muted); }
.review-empty svg { width: 2.5882rem; height: 2.5882rem; margin: 0 auto 0.5882rem; color: var(--primary); }
@media screen and (max-width: 640px) {
  .review-item { flex-direction: column; align-items: stretch; gap: 0.7059rem; padding: 0.9412rem; }
  .review-actions { justify-content: flex-start; }
  .review-form { flex: 1 1 100%; }
  .review-form .form-control { flex: 1; width: auto; }
}

/* Panel de inasistentes */
.absent-panel { margin-bottom: 1.1765rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.absent-panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.7059rem 1.1765rem; padding: 0.9412rem 1.1765rem; }
.absent-panel-title { display: flex; align-items: center; gap: 0.7059rem; min-width: 0; }
.absent-panel-title strong { display: block; color: var(--text-main); font-size: 0.98rem; }
.absent-panel-title span:not(.absent-panel-icon) { font-size: 0.82rem; color: var(--text-muted); }
.absent-panel-icon { display: grid; place-items: center; width: 2.3529rem; height: 2.3529rem; flex-shrink: 0; border-radius: var(--radius-sm); background: var(--danger-bg); color: var(--danger); }
.absent-panel-icon svg { width: 1.2941rem; height: 1.2941rem; }
.absent-panel-body { padding: 0 1.1765rem 1.0588rem; border-top: 1px solid var(--border); }
.absent-panel-body[hidden] { display: none; }
.absent-empty { margin: 1.0588rem 0 0; text-align: center; font-size: 0.9rem; color: var(--text-muted); }
.absent-list { list-style: none; margin: 0.9412rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15.2941rem, 1fr)); gap: 0.5882rem; }
.absent-item { display: flex; align-items: flex-start; gap: 0.5882rem; min-width: 0; padding: 0.5882rem 0.7059rem; background: var(--bg-body); border-radius: var(--radius-md); }
.absent-avatar { display: grid; place-items: center; width: 2.1176rem; height: 2.1176rem; flex-shrink: 0; border-radius: 50%; background: var(--danger-bg); color: var(--danger); font-size: 0.76rem; font-weight: 800; }
.absent-info { min-width: 0; flex: 1; }
.absent-info > a { display: block; font-size: 0.875rem; font-weight: 700; color: var(--text-main); text-decoration: none; overflow-wrap: anywhere; }
.absent-info > a:hover { color: var(--primary); }
.absent-info > span { display: block; font-size: 0.76rem; color: var(--text-muted); }
.absent-dates { display: flex; flex-wrap: wrap; gap: 0.2353rem; margin-top: 0.3529rem; }
.absent-dates a { padding: 1px 0.4118rem; border-radius: var(--radius-full); background: var(--bg-card); border: 1px solid var(--border); font-size: 0.7rem; font-variant-numeric: tabular-nums; color: var(--text-secondary); text-decoration: none; }
.absent-dates a:hover { border-color: var(--primary); color: var(--primary); }
.absent-count { flex-shrink: 0; font-size: 1.05rem; font-weight: 800; color: var(--danger); font-variant-numeric: tabular-nums; }
@media screen and (max-width: 768px) {
  .dashboard-kpi-row .dashboard-kpi-card:last-child { grid-column: 1 / -1; }
}

/* Inicio: cinco indicadores caben sin apretar el contenido */
@media screen and (min-width: 641px) {
  .dashboard-kpi-row .dashboard-kpi-card { position: relative; }
  .dashboard-kpi-row .dashboard-kpi-card > div:first-child { width: 100%; min-width: 0; }
  .dashboard-kpi-row .dashboard-kpi-card > div:first-child > div:first-child { padding-right: 2.4706rem; }
  .dashboard-kpi-row .dashboard-kpi-card > div:first-child > div:last-child { flex-wrap: wrap; }
  .dashboard-kpi-row .dashboard-kpi-icon { position: absolute; top: 0.8235rem; right: 0.8235rem; width: 2.1176rem; height: 2.1176rem; }
  .dashboard-kpi-row .dashboard-kpi-icon svg { width: 1.0588rem !important; height: 1.0588rem !important; }
}

/* Calendario en teléfono: las etiquetas caben en la celda */
@media screen and (max-width: 640px) {
  .cal-day-cell .badge-pill-attendees,
  .cal-day-cell .badge-pill-absent,
  .cal-day-cell .badge-pill-late { padding: 3px 0.2941rem; font-size: 0.62rem; letter-spacing: -0.01em; }
  .cal-day-cell .badge-pill-attendees svg,
  .cal-day-cell .badge-pill-absent svg,
  .cal-day-cell .badge-pill-late svg { display: none; }
}

/* Inicio en teléfonos pequeños: los textos de cada indicador bajan de línea en vez de salirse */
.dashboard-kpi-row .dashboard-kpi-card > div:first-child { min-width: 0; }
.dashboard-kpi-row .dashboard-kpi-card > div:first-child > div:last-child { flex-wrap: wrap; row-gap: 0.2353rem; }

/* Inasistentes: quienes aún no marcan antes de las 12:00 */
.absent-subtitle { margin: 1.0588rem 0 0; font-size: 0.82rem; line-height: 1.5; color: var(--text-muted); }
.absent-subtitle strong { display: block; font-size: 0.9rem; color: var(--text-main); }
.absent-item.is-pending { background: transparent; border: 1px dashed var(--border); }
.absent-item.is-pending .absent-avatar { background: var(--bg-body); color: var(--text-muted); }
