/* EventSystem — AVPAML7B — Design tokens & base styles */

:root {
  /* Primary — Azul institucional */
  --brand-900: #152A66;
  --brand-800: #17327A;
  --brand-700: #1E3A8A;
  --brand-600: #2347A8;
  --brand-500: #2E5AC6;
  --brand-200: #B8C6E9;
  --brand-100: #E8EDFA;
  --brand-50:  #F3F6FC;

  /* Secondary — Naranja AVPAML7B */
  --accent-700: #C2410C;
  --accent-600: #EA580C;
  --accent-500: #F97316;
  --accent-400: #FB923C;
  --accent-200: #FED7AA;
  --accent-100: #FFEDD5;
  --accent-50:  #FFF7ED;

  /* Tertiary — Slate */
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-200: #CBD5E1;
  --slate-100: #E2E8F0;
  --slate-50:  #F1F5F9;

  /* Legacy alert aliases (naranja sustituye al rojo antiguo) */
  --alert-600: var(--accent-600);
  --alert-500: var(--accent-500);
  --alert-100: var(--accent-100);

  /* Status */
  --ok-600: #16A34A;
  --ok-100: #DCFCE7;
  --warn-600: #CA8A04;
  --warn-100: #FEF3C7;
  --bad-600: #DC2626;
  --bad-100: #FEE2E2;

  /* Neutrals — Slate-aligned (Neutral #F8FAFC como base) */
  --ink-950: #0F172A;
  --ink-900: #1E293B;
  --ink-800: #334155;
  --ink-700: #475569;
  --ink-600: #64748B;
  --ink-500: #64748B;
  --ink-400: #94A3B8;
  --ink-300: #CBD5E1;
  --ink-200: #E2E8F0;
  --ink-150: #EBEEF3;
  --ink-100: #F1F5F9;
  --ink-50:  #F8FAFC;
  --ink-0:   #FFFFFF;

  /* Semantic (light) */
  --bg: #F8FAFC;
  --bg-elev: #FFFFFF;
  --bg-sunken: #F1F5F9;
  --surface: #FFFFFF;
  /* Alias semántico para "fondo de tarjeta" que usa el drawer de evento y
     varios componentes. No estaba definido y producía fondos transparentes
     (el drawer del evento dejaba ver el listado por detrás). Lo mapeamos
     al mismo blanco/elevado que usamos para superficies "altas". */
  --bg-card: var(--bg-elev);
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;
  --sidebar-bg: #0F2055;
  --sidebar-text: rgba(255,255,255,0.78);
  --sidebar-text-strong: #FFFFFF;
  --sidebar-active-bg: rgba(255,255,255,0.10);
  --sidebar-border: rgba(255,255,255,0.08);
  --header-bg: #FFFFFF;

  /* Radii / shadows */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16,22,45,0.05);
  --shadow-md: 0 2px 8px rgba(16,22,45,0.06), 0 1px 2px rgba(16,22,45,0.04);
  --shadow-lg: 0 10px 30px rgba(16,22,45,0.10), 0 2px 6px rgba(16,22,45,0.06);
  --shadow-xl: 0 24px 60px rgba(16,22,45,0.18);

  /* Typography */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0B0D14;
  --bg-elev: #14171F;
  --bg-sunken: #090B11;
  --surface: #161925;
  --bg-card: var(--bg-elev);
  --border: #242838;
  --border-strong: #2E3346;
  --text: #E8E9EE;
  --text-muted: #9AA0B0;
  --text-subtle: #6B7085;
  --sidebar-bg: #0A0C15;
  --sidebar-text: rgba(255,255,255,0.72);
  --sidebar-text-strong: #FFFFFF;
  --sidebar-active-bg: rgba(255,255,255,0.06);
  --sidebar-border: rgba(255,255,255,0.06);
  --header-bg: #14171F;
  --brand-100: rgba(46, 90, 198, 0.18);
  --brand-50: rgba(46, 90, 198, 0.08);
  --alert-100: rgba(230, 57, 70, 0.18);
  --ok-100: rgba(22, 163, 74, 0.15);
  --warn-100: rgba(202, 138, 4, 0.18);
  --bad-100: rgba(220, 38, 38, 0.18);
  --ink-150: #1E2230;
  --ink-100: #1A1E2B;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

html[data-theme="dark"],
html[data-theme="dark"] body,
body[data-theme="dark"],
body[data-theme="dark"] .app,
body[data-theme="dark"] .main,
html[data-theme="dark"] .app,
html[data-theme="dark"] .main {
  background: var(--bg);
  color: var(--text);
}

button { font-family: inherit; cursor: pointer; }

.brand-img {
  display: block;
  object-fit: contain;
}

.login-brand {
  text-align: center;
  margin-bottom: 20px;
}

.login-brand img {
  width: 112px;
  max-width: 42%;
  height: auto;
  margin: 0 auto 10px;
}

.login-brand .name {
  font-weight: 700;
  color: var(--text);
}

.public-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.public-brand img {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
}

.public-brand .name {
  font-weight: 700;
  color: var(--text);
}

.public-brand .sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Scrollbars */
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg-elev); }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ───────────── App shell ─────────────
   Layout grid de altura fija (100vh). El scroll del contenido vive dentro de
   `.main` (que tiene `overflow: auto`), nunca en el body. Eso garantiza que
   el sidebar nunca "cuelgue" visualmente al hacer scroll: como el contenedor
   `.app` mide exactamente lo que mide el viewport, los grid items rellenan
   ese alto sin desbordarse. */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  transition: grid-template-columns .22s ease;
}
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ───────────── Sidebar ───────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  height: 100%;
  min-height: 0; /* permite que .sidebar-nav pueda scrollear dentro del flex */
  overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 64px;
}
.sidebar-brand .mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 10px;
  object-fit: contain;
  padding: 4px;
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}
.sidebar-brand .brand-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sidebar-brand .title {
  font-weight: 700; font-size: 15px; color: #fff;
  letter-spacing: .01em; line-height: 1.15;
}
.sidebar-brand .sub {
  font-size: 11px; color: rgba(255,255,255,0.6);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
  line-height: 1.15;
}

.sidebar-nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.sidebar-nav .section-label {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  border: 0; background: transparent;
  width: 100%;
  margin: 2px 0;
  transition: background .12s, color .12s;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-strong);
  box-shadow: inset 2px 0 0 #F97316;
}
.nav-item .icon { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item.active .icon { opacity: 1; }
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 999px;
  background: #F97316; color: #fff;
}

.sidebar.collapsed .sidebar-brand .title,
.sidebar.collapsed .sidebar-brand .sub,
.sidebar.collapsed .sidebar-brand .brand-copy,
.sidebar.collapsed .nav-item .label,
.sidebar.collapsed .nav-item .badge,
.sidebar.collapsed .nav-item .chevron,
.sidebar.collapsed .nav-group-children,
.sidebar.collapsed .section-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 16px 8px; }
/* En modo colapsado, los grupos se "aplanan": el botón de cabecera se muestra
   como un nav-item normal y los hijos quedan ocultos. Para no perder la
   navegación, se asume que la cabecera del grupo no navega — el usuario
   tendrá que expandir el sidebar para entrar a sus secciones. */
.sidebar.collapsed .nav-group { padding: 0; border: 0; background: transparent; }
.sidebar.collapsed .nav-group .nav-group-head { padding: 10px; }

/* Grupo plegable
   El padre `.nav-group` aplica un fondo sutil cuando está abierto o cuando
   contiene la página activa, para anclar visualmente al usuario en el árbol.
   Los hijos se renderizan como `.nav-child` con indentación leve y un
   "rail" vertical sutil a la izquierda que indica jerarquía.
   La animación de expand/collapse usa `grid-template-rows: 0fr/1fr` (truco
   que permite animar height: auto sin saltos). */
.nav-group { display: flex; flex-direction: column; }
.nav-group .nav-group-head .chevron {
  margin-left: auto;
  width: 16px; height: 16px; flex: 0 0 16px;
  opacity: .55;
  transition: transform .18s ease, opacity .15s ease;
}
.nav-group:hover .nav-group-head .chevron,
.nav-group.has-active .nav-group-head .chevron { opacity: .9; }
.nav-group.open .nav-group-head .chevron { transform: rotate(90deg); opacity: 1; }
.nav-group.has-active .nav-group-head .label { color: #fff; }
.nav-group.has-active:not(.open) .nav-group-head { background: rgba(255,255,255,0.04); }
/* El wrapper externo .nav-group-children es el contenedor grid que se
   anima. Su único hijo directo (.nav-group-children-inner) recibe
   `overflow: hidden; min-height: 0` para que la animación
   grid-template-rows: 0fr → 1fr realmente colapse el contenido. Sin
   este wrapper interno, los <button> hijos directos no honraban el
   overflow y el grupo quedaba siempre visible. */
.nav-group .nav-group-children {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .22s ease;
}
.nav-group.open .nav-group-children { grid-template-rows: 1fr; }
.nav-group .nav-group-children-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* Cuando está abierto, los hijos respiran un poco bajo la cabecera */
.nav-group.open .nav-group-children-inner {
  padding: 2px 0 6px;
}
.nav-item.nav-child {
  padding-left: 36px; /* alinea el icono con el del padre + indent */
  font-size: 13px;
  font-weight: 500;
  position: relative;
}
.nav-item.nav-child::before {
  content: "";
  position: absolute;
  left: 21px; top: 6px; bottom: 6px;
  width: 1px;
  background: rgba(255,255,255,0.08);
}
.nav-item.nav-child:hover::before,
.nav-item.nav-child.active::before { background: rgba(249, 115, 22, 0.5); }
.nav-item.nav-child .icon { width: 16px; height: 16px; flex: 0 0 16px; opacity: .7; }
.nav-item.nav-child.active .icon { opacity: 1; }

.sidebar-footer {
  padding: 10px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,0.62); font-size: 12px;
}
.sidebar-footer .dot {
  width: 8px; height: 8px; border-radius: 999px; background: #16A34A;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.2);
}

/* ───────────── Header ───────────── */
.header {
  grid-area: header;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 22px;
  gap: 16px;
  min-width: 0;
  position: sticky; top: 0; z-index: 20;
}
.header .crumbs {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 13px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.header .crumbs .sep { color: var(--border-strong); }
.header .crumbs .current {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header .spacer { flex: 1; }

.search {
  position: relative;
  width: 340px;
  min-width: 220px;
  max-width: 36vw;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search input:focus {
  border-color: var(--brand-500);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px rgba(46,90,198,0.18);
}
.search .s-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-subtle);
}
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--text-muted);
  padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg-elev);
}

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: grid; place-items: center;
  position: relative;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.icon-btn.active { background: var(--bg-sunken); color: var(--text); }
.menu-toggle-mobile { display: none; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 999px;
  background: #F97316; border: 2px solid var(--bg-elev);
}
.icon-btn .dot.muted { background: var(--text-subtle); }
.notif-count {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: #F97316; color: #fff;
  border: 2px solid var(--header-bg);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  line-height: 1;
}
.notification-wrap { position: relative; }
.notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 370px;
  max-width: calc(100vw - 24px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  overflow: hidden;
}
.notification-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.notification-title { font-weight: 700; color: var(--text); }
.notification-sub { font-size: 12px; color: var(--text-muted); }
.link-btn {
  border: 0; background: transparent; color: var(--brand-500);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 6px; border-radius: 6px;
}
.link-btn:hover { background: var(--brand-50); color: var(--brand-700); }
.notification-empty {
  padding: 24px 16px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}
.notification-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.notification-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 9px;
}
.notification-item + .notification-item { margin-top: 2px; }
.notification-item:hover { background: var(--bg-sunken); }
.notification-icon {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--bg-sunken);
  color: var(--text-muted);
}
.notification-message {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}
.notification-meta {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.notification-item.success .notification-icon { background: var(--ok-100); color: var(--ok-600); }
.notification-item.warning .notification-icon { background: var(--warn-100); color: var(--warn-600); }
.notification-item.error .notification-icon { background: var(--bad-100); color: var(--bad-600); }
.notification-item.info .notification-icon { background: var(--brand-100); color: var(--brand-700); }

.avatar {
  width: 34px; height: 34px; border-radius: 999px;
  background: linear-gradient(135deg, #2E5AC6, #1E3A8A);
  color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: 12.5px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
}
.user-chip:hover { background: var(--bg-sunken); }
.user-chip .name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.1;}
.user-chip .role { font-size: 11px; color: var(--text-muted); line-height: 1.1;}

/* ───────────── Main & page chrome ───────────── */
.main {
  grid-area: main;
  padding: 26px 32px 40px;
  overflow: auto;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-head > div:first-child { min-width: 0; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: 0; margin: 0 0 4px; color: var(--text); }
.page-sub { color: var(--text-muted); font-size: 13.5px; margin: 0; overflow-wrap: anywhere; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: 999px; /* pill */
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  background: transparent; color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--brand-700); color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { background: var(--brand-600); }
.btn.secondary {
  background: var(--bg-elev); color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background: var(--bg-sunken); }
.btn.ghost { color: var(--text-muted); }
.btn.ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn.danger {
  background: var(--alert-500); color: #fff;
}
.btn.danger:hover { background: var(--alert-600); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12px; gap: 6px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn svg { width: 15px; height: 15px; }

/* ───────────── Cards ───────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px;}
.card-body { padding: 18px; }

/* KPI card */
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.kpi .value {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi .foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-muted); }
.kpi .delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.kpi .delta.up { color: var(--ok-600); }
.kpi .delta.down { color: var(--bad-600); }
.kpi .accent {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.kpi.b-blue .accent { background: var(--brand-700); }
.kpi.b-green .accent { background: var(--ok-600); }
.kpi.b-red .accent { background: var(--alert-500); }
.kpi.b-amber .accent { background: var(--warn-600); }

/* ───── KPI compact: variante horizontal con icono a la izquierda ─────
   Más pequeña verticalmente (~78 px) para que no domine el dashboard
   cuando van 4 en fila. Conserva la barra "accent" izquierda como
   código de color rápido. */
.kpi.compact {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 18px;
}
.kpi.compact .kpi-icon {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--brand-700) 12%, transparent);
  color: var(--brand-700);
}
.kpi.compact .kpi-icon > svg,
.kpi.compact .kpi-icon .mud-icon-root {
  width: 22px; height: 22px;
}
.kpi.compact.b-blue  .kpi-icon { background: color-mix(in srgb, var(--brand-700) 14%, transparent);  color: var(--brand-700); }
.kpi.compact.b-green .kpi-icon { background: color-mix(in srgb, var(--ok-600) 14%, transparent);     color: var(--ok-600); }
.kpi.compact.b-red   .kpi-icon { background: color-mix(in srgb, var(--alert-500) 14%, transparent);  color: var(--alert-600); }
.kpi.compact.b-amber .kpi-icon { background: color-mix(in srgb, var(--warn-600) 14%, transparent);   color: var(--warn-600); }
.kpi.compact .kpi-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi.compact .label {
  font-size: 10.5px;
  letter-spacing: .05em;
}
.kpi.compact .value {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 700;
}
.kpi.compact .value .unit {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
}
.kpi.compact .foot {
  font-size: 11px;
  line-height: 1.2;
  gap: 8px;
}
.kpi.compact .foot .delta { font-size: 11px; }
.kpi.compact .foot .delta svg,
.kpi.compact .foot .delta .mud-icon-root {
  width: 12px; height: 12px;
}

.metric-value {
  margin: 6px 0 2px;
  color: var(--text);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.metric-value span {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 600;
}

.metric-value.alert {
  color: var(--alert-500);
}

/* ───────────── Badges ───────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  line-height: 1.4;
  letter-spacing: .005em;
}
.badge .b-dot {
  width: 6px; height: 6px; border-radius: 999px; background: currentColor;
}
.badge.ok { background: var(--ok-100); color: var(--ok-600); }
.badge.warn { background: var(--warn-100); color: var(--warn-600); }
.badge.bad { background: var(--bad-100); color: var(--bad-600); }
.badge.neutral { background: var(--bg-sunken); color: var(--text-muted); }
.badge.brand { background: var(--brand-100); color: var(--brand-700); }

/* ───────────── Table ───────────── */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  min-width: min-content;
}
.table-toolbar .count {
  color: var(--text-muted); font-size: 12.5px;
}
.input {
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(46,90,198,0.15); }

.input-mini {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  outline: none;
}

.input-mini:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(46,90,198,0.15);
}

.chip-filter {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 999px;
  font-size: 12px; color: var(--text);
  cursor: pointer;
}
.chip-filter:hover { background: var(--bg-sunken); }
.chip-filter.active { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }

table.data {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
table.data thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  white-space: nowrap;
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); }
[data-theme="dark"] table.data tbody tr:nth-child(even) td { background: rgba(255,255,255,0.015); }
table.data tbody tr:hover td { background: var(--bg-sunken); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .mini-avatar {
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--brand-100); color: var(--brand-700);
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700;
  margin-right: 10px; vertical-align: middle;
}

.row-action {
  border: 0; background: transparent;
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 7px;
  display: inline-grid; place-items: center;
  margin: 0 1px;
}
.row-action:hover { background: var(--bg-sunken); color: var(--text); }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 12.5px;
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pg {
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.pagination .pg.active { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.pagination .pg:disabled { opacity: 0.4; cursor: not-allowed; }

/* ───────────── Progress / charts ───────────── */
.progress {
  height: 6px; background: var(--bg-sunken);
  border-radius: 999px; overflow: hidden;
  position: relative;
}
.progress > span {
  display: block; height: 100%;
  background: var(--brand-700);
  border-radius: 999px;
}
.progress.warn > span { background: var(--warn-600); }
.progress.bad > span { background: var(--alert-500); }
.progress.ok > span { background: var(--ok-600); }

/* ───────────── Modal & drawer ───────────── */
.scrim {
  position: fixed; inset: 0; background: rgba(10,13,25,0.45);
  z-index: 900;
  display: grid; place-items: center;
  padding: 24px;
  backdrop-filter: blur(4px);
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.modal {
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-xl);
  animation: slideUp .18s ease;
  overflow: hidden;
}
.modal.wide { max-width: 840px; }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 22px; max-height: 70vh; overflow: auto; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--bg-sunken);
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 96vw;
  background: var(--bg-elev);
  box-shadow: var(--shadow-xl);
  z-index: 901;
  animation: slideRight .22s ease;
  display: flex; flex-direction: column;
}

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  outline: none;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(46,90,198,0.15);
}
.field textarea { min-height: 82px; resize: vertical; }
.field.invalid label { color: var(--bad-600); }
.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--bad-600);
  background: color-mix(in srgb, var(--bad-100) 18%, var(--bg-elev));
}
.field.invalid input:focus,
.field.invalid select:focus,
.field.invalid textarea:focus {
  border-color: var(--bad-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad-100) 70%, transparent);
}
.field-error {
  color: var(--bad-600);
  font-size: 11.5px;
  line-height: 1.35;
}
.password-input-wrap {
  position: relative;
}
.password-input-wrap input {
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}
.password-toggle:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field.full { grid-column: 1 / -1; }

/* ───────────── Toasts ───────────── */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 12px;
  padding: 12px 14px 12px 12px;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 380px;
  animation: slideUp .22s ease;
}
.toast .tdot {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; flex: 0 0 26px;
}
.toast.ok .tdot { background: var(--ok-100); color: var(--ok-600); }
.toast.bad .tdot { background: var(--bad-100); color: var(--bad-600); }
.toast.info .tdot { background: var(--brand-100); color: var(--brand-700); }
.toast .ttitle { font-size: 13px; font-weight: 600; }
.toast .tmsg { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Tabs */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  border: 0; background: transparent;
  padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-700);
  font-weight: 600;
}
[data-theme="dark"] .tab.active { color: var(--brand-500); border-bottom-color: var(--brand-500); }

/* Steps */
.steps {
  display: flex; align-items: center; gap: 0;
  margin-bottom: 22px;
}
.step {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
}
.step .num {
  width: 26px; height: 26px; border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--bg-elev);
  color: var(--text-muted);
}
.step.done .num { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.step.current .num { background: #fff; border-color: var(--brand-700); color: var(--brand-700); box-shadow: 0 0 0 3px var(--brand-100);}
.step.current { color: var(--text); font-weight: 600;}
.step.done { color: var(--text); }
.step .line { flex: 1; height: 1.5px; background: var(--border-strong); margin: 0 14px; min-width: 30px;}
.step.done + .step .num, .step.done .line { /* -- */ }

/* Empty state */
.empty {
  padding: 40px 24px; text-align: center;
}
.empty .illus {
  width: 120px; height: 90px; margin: 0 auto 16px;
  background: var(--bg-sunken); border-radius: 14px;
  display: grid; place-items: center;
  font-size: 40px;
  border: 1px dashed var(--border-strong);
}
.empty h4 { margin: 0 0 6px; font-size: 15px; }
.empty p { color: var(--text-muted); font-size: 13px; max-width: 360px; margin: 0 auto 16px; }

/* Skeleton
   Equilibrio entre anti-parpadeo y feedback rápido: el shimmer arranca a
   opacidad media (0.35) para que sea visible al instante. Anima fade-in a
   opacidad plena en 80ms. Así:
   - Cargas <80ms: el shimmer apenas asoma (es casi instantáneo).
   - Cargas 80-300ms: el usuario ve feedback claro de que algo está pasando.
   - Cargas >300ms: shimmer plenamente visible.
   Versión anterior dejaba opacity:0 durante 280ms, lo que hacía sentir
   lentas las navegaciones cuando los datos tardaban 200-500ms (la pantalla
   quedaba en blanco sin feedback). */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes skeleton-fade-in { from { opacity: 0.35; } to { opacity: 1; } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 0%, var(--ink-150) 50%, var(--bg-sunken) 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  opacity: 0.35;
  animation: shimmer 1.4s linear infinite, skeleton-fade-in 0.08s ease-out 0s forwards;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; opacity: 1; background: var(--bg-sunken); }
}

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.grid.c-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.c-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.dashboard { grid-template-columns: 2fr 1fr; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row > * { min-width: 0; }
.spacer { flex: 1; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); }

/* Quick actions tile
   Cada acción es una fila con icono + título + subtítulo. Se busca consistencia
   visual: todos los iconos del mismo tamaño dentro del mismo "chip" de color y
   todas las cards del mismo alto, sea cual sea el icono Material que entre. */
.qa {
  display: flex; align-items: center; gap: 14px;
  min-height: 64px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: left;
  width: 100%;
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .12s;
}
.qa:hover { border-color: var(--brand-500); background: var(--brand-50); transform: translateY(-1px); }
.qa:active { transform: translateY(0); }
.qa .qa-body {
  display: flex; flex-direction: column; min-width: 0; flex: 1;
}
.qa .qa-t { font-weight: 600; font-size: 13.5px; line-height: 1.25; color: var(--text); }
.qa .qa-s { font-size: 11.75px; color: var(--text-muted); line-height: 1.35; margin-top: 2px; }

/* Event card */
.event-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .12s, transform .12s, box-shadow .12s;
  cursor: pointer;
}
.event-card:hover { border-color: var(--brand-500); box-shadow: var(--shadow-md); }
.event-card .cover {
  aspect-ratio: 16/9;
  background: repeating-linear-gradient(135deg, var(--brand-700) 0 8px, var(--brand-600) 8px 16px);
  position: relative;
  color: #fff;
}
.event-card .cover.c2 { background: repeating-linear-gradient(135deg, #F97316 0 8px, #EA580C 8px 16px);}
.event-card .cover.c3 { background: repeating-linear-gradient(135deg, #16A34A 0 8px, #128A3E 8px 16px);}
.event-card .cover.c4 { background: repeating-linear-gradient(135deg, #CA8A04 0 8px, #A67703 8px 16px);}
.event-card .cover .status {
  position: absolute; top: 10px; left: 10px;
}
.event-card .cover .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px;
  color: rgba(255,255,255,0.75); letter-spacing: .06em;
  text-transform: uppercase;
}
.event-card .info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.event-card .title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.event-card .meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.event-card .fill {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px;
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* Sparkline / bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 6px 2px;}
.bars .bar {
  flex: 1; background: var(--brand-700);
  border-radius: 5px 5px 0 0;
  min-height: 6px;
  position: relative;
  transition: background .12s;
}
.bars .bar:hover { background: var(--brand-500); }
.bars .bar.alt { background: var(--brand-500); opacity: .75;}

/* QR Studio */
.qr-studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(340px, 1.15fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.qr-panel,
.qr-preview-shell {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.qr-panel {
  min-width: 0;
  overflow: hidden;
}

.qr-panel-head,
.qr-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.qr-panel-head h3,
.qr-preview-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.qr-panel-head span,
.qr-preview-head span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.qr-input-panel,
.qr-controls-panel {
  padding-bottom: 16px;
}

.qr-input-panel > .field,
.qr-controls-panel .field {
  margin: 14px 18px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-sunken);
  flex: 0 0 auto;
}

.segmented button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.segmented button.active {
  background: var(--bg-elev);
  color: var(--brand-700);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .segmented button.active {
  color: var(--brand-500);
}

.qr-value,
.qr-batch {
  min-height: 150px;
  line-height: 1.5;
}

.qr-batch {
  min-height: 230px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.qr-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 18px;
}

.qr-presets button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.qr-presets button:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}

.qr-presets span {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
}

.checker,
.qr-preview-box.transparent {
  background-image:
    linear-gradient(45deg, rgba(100,116,139,0.22) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(100,116,139,0.22) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(100,116,139,0.22) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(100,116,139,0.22) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.qr-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 4px;
}

.qr-settings .field:nth-child(3),
.qr-settings .field:nth-child(4),
.qr-settings .toggle-line,
.qr-settings .color-grid,
.qr-settings .split-line,
.qr-settings > .btn {
  grid-column: 1 / -1;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 2px 18px 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.toggle-line input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-700);
  flex: 0 0 auto;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 18px 14px;
}

.color-grid.one {
  grid-template-columns: minmax(0, 1fr);
}

.color-grid label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
}

.color-grid input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
}

.color-grid input[type="color"]:disabled {
  opacity: .45;
}

.split-line {
  height: 1px;
  margin: 8px 18px 14px;
  background: var(--border);
}

.qr-controls-panel input[type="range"] {
  height: 6px;
  padding: 0;
  accent-color: var(--brand-700);
}

.qr-preview-panel {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  min-width: 0;
}

.qr-preview-shell {
  overflow: hidden;
}

.qr-preview-box {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 24px;
  background: var(--bg-sunken);
}

.qr-preview-box img {
  display: block;
  width: min(100%, 420px);
  max-height: 62vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.qr-preview-box.transparent img {
  box-shadow: none;
}

.qr-preview-box .empty {
  padding: 20px;
}

.qr-error {
  margin: 14px 18px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--bad-600) 28%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--bad-100) 50%, var(--bg-elev));
  color: var(--bad-600);
  font-size: 12px;
  line-height: 1.4;
}

.qr-preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}

@media (max-width: 1260px) {
  .qr-studio-grid {
    grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  }

  .qr-preview-panel {
    grid-column: 1 / -1;
    position: static;
  }

  .qr-preview-box {
    min-height: 360px;
  }
}

@media (max-width: 760px) {
  .qr-studio-grid,
  .qr-settings {
    grid-template-columns: 1fr;
  }

  .qr-panel-head,
  .qr-preview-head,
  .qr-preview-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented,
  .qr-preview-actions .btn {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .qr-presets,
  .color-grid {
    grid-template-columns: 1fr;
  }
}

/* Responsive helpers */
.mobile-sidebar-scrim {
  display: none;
}

@media (max-width: 1100px) {
  .search {
    width: 280px;
    max-width: 30vw;
  }

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

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

  .grid.dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  :root {
    --header-h: 56px;
  }

  .app,
  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 120;
    display: flex;
    width: min(86vw, 320px);
    max-width: 320px;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-xl);
  }

  .app.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app.mobile-sidebar-open .sidebar.collapsed .sidebar-brand .title,
  .app.mobile-sidebar-open .sidebar.collapsed .sidebar-brand .sub,
  .app.mobile-sidebar-open .sidebar.collapsed .nav-item .label,
  .app.mobile-sidebar-open .sidebar.collapsed .nav-item .badge,
  .app.mobile-sidebar-open .sidebar.collapsed .section-label,
  .app.mobile-sidebar-open .sidebar.collapsed .sidebar-footer .footer-copy {
    display: initial;
  }

  .app.mobile-sidebar-open .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 9px 10px;
  }

  .app.mobile-sidebar-open .sidebar.collapsed .sidebar-brand {
    justify-content: flex-start;
    padding: 16px 18px;
  }

  .mobile-sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(5, 8, 18, 0.54);
    backdrop-filter: blur(2px);
  }

  .header {
    padding: 0 12px;
    gap: 8px;
  }

  .menu-toggle-desktop {
    display: none;
  }

  .menu-toggle-mobile {
    display: grid;
  }

  .header .crumbs {
    flex: 1 1 auto;
    font-size: 12px;
  }

  .header .crumbs span:first-child,
  .header .crumbs .sep {
    display: none;
  }

  .header .search {
    display: none;
  }

  .icon-btn {
    flex: 0 0 36px;
  }

  .user-chip {
    flex: 0 0 auto;
    padding: 2px;
    border-radius: 11px;
    gap: 4px;
  }

  .user-chip > div:not(.avatar),
  .user-chip .mud-icon-root {
    display: none;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }

  .main {
    padding: 18px 14px 32px;
    overflow-x: hidden;
  }

  .page-head {
    align-items: stretch;
    margin-bottom: 18px;
  }

  .page-title {
    font-size: 22px;
    line-height: 1.15;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn,
  .page-actions .input {
    flex: 1 1 150px;
    justify-content: center;
    min-width: 0;
  }

  .table-toolbar {
    align-items: stretch;
    min-width: 0;
  }

  .table-toolbar .search {
    display: block;
    width: 100% !important;
    min-width: 0;
    max-width: none;
  }

  .table-toolbar .row {
    flex-wrap: wrap;
    width: 100%;
  }

  .table-toolbar .spacer {
    display: none;
  }

  table.data {
    min-width: 760px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 0 0 auto;
  }

  .card,
  .kpi,
  .event-card {
    min-width: 0;
  }

  .card-head .row {
    width: 100%;
  }

  .card-head .search {
    width: 100% !important;
    min-width: 0;
    max-width: none;
  }

  .card-head .input-mini {
    flex: 1 1 140px;
    min-width: 0;
  }

  .modal {
    max-height: calc(100dvh - 24px);
  }

  .modal-body {
    max-height: calc(100dvh - 150px);
  }

  .drawer {
    width: min(100vw, 520px);
  }

  .toast-wrap {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .notification-panel {
    position: fixed;
    top: calc(var(--header-h) + 8px);
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 16px 12px 28px;
  }

  .grid.c-4,
  .grid.c-3,
  .grid.c-2,
  .grid.dashboard {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-grid .field,
  .form-grid .field.full {
    grid-column: 1 / -1;
  }

  .scrim {
    align-items: end;
    padding: 10px;
  }

  .modal,
  .modal.wide {
    max-width: none;
    width: 100%;
    border-radius: 12px;
  }

  .modal-head {
    padding: 15px 16px;
  }

  .modal-body {
    padding: 16px;
    max-height: calc(100dvh - 150px);
  }

  .modal-foot {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .modal-foot .btn {
    flex: 1 1 140px;
    justify-content: center;
  }

  .card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .kpi {
    padding: 14px 16px;
  }

  .kpi .value {
    font-size: 25px;
    line-height: 1.15;
  }

  .metric-value {
    font-size: 28px;
  }

  .metric-value span {
    font-size: 15px;
  }

  .row {
    flex-wrap: wrap;
  }

  .qa {
    align-items: flex-start;
  }

  .event-card .fill {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .event-card .fill > div {
    margin: 0 !important;
  }

  .bars {
    height: 150px;
    min-width: 520px;
  }

  .card-body:has(.bars) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 520px) {
  .header {
    gap: 6px;
  }

  .header .crumbs {
    max-width: 34vw;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .btn {
    min-width: 0;
    padding-inline: 12px;
  }

  .page-actions .btn,
  .page-actions .input {
    flex-basis: 100%;
  }

  .table-toolbar {
    padding: 10px;
  }

  table.data {
    min-width: 700px;
  }

  .notification-panel {
    left: 8px;
    right: 8px;
  }
}

/* ============================================================
   Panel /admin/usuarios — chips de rol, multi-select, fila inactiva
   ============================================================ */
.role-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.role-pill strong { font-weight: 700; }
/* "Desarrollador" usa color sobrio gris-azul; comunica "técnico" sin
   competir visualmente con los roles operativos. */
.role-desarrollador { background: color-mix(in srgb, #6366f1 14%, transparent); color: #4f46e5; border-color: color-mix(in srgb, #6366f1 30%, transparent); }
.role-admin     { background: color-mix(in srgb, var(--alert-500) 14%, transparent); color: var(--alert-600); border-color: color-mix(in srgb, var(--alert-500) 30%, transparent); }
.role-tesorero  { background: color-mix(in srgb, var(--brand-700) 14%, transparent); color: var(--brand-700); border-color: color-mix(in srgb, var(--brand-700) 30%, transparent); }
.role-secretario{ background: color-mix(in srgb, var(--ok-600) 14%, transparent);    color: var(--ok-600);    border-color: color-mix(in srgb, var(--ok-600) 30%, transparent); }
.role-operador  { background: color-mix(in srgb, var(--warn-600) 16%, transparent);  color: var(--warn-600);  border-color: color-mix(in srgb, var(--warn-600) 30%, transparent); }
.role-default   { background: var(--bg-sunken); color: var(--text-muted); border-color: var(--border); }

.role-checks {
  display: flex; flex-direction: column; gap: 8px;
}
.role-check {
  display: grid;
  grid-template-columns: 18px auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.role-check:hover { background: var(--bg-sunken); }
.role-check.checked { border-color: var(--brand-700); background: color-mix(in srgb, var(--brand-700) 6%, var(--bg-elev)); }
.role-check input[type=checkbox] { margin: 0; cursor: pointer; }
.role-check .role-desc { font-size: 11.5px; line-height: 1.35; }

table.data tr.row-disabled td {
  opacity: 0.55;
  font-style: italic;
}
table.data tr.row-disabled .mini-avatar {
  background: var(--bg-sunken);
  color: var(--text-muted);
}

.row-action[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.row-action[disabled]:hover {
  background: transparent;
  color: var(--text-muted);
}

/* Pequeñas variantes de color para mini-avatar (fila usuarios) */
table.data .mini-avatar.avatar-c0 { background: color-mix(in srgb, var(--brand-700) 18%, transparent); color: var(--brand-700); }
table.data .mini-avatar.avatar-c1 { background: color-mix(in srgb, var(--ok-600) 18%, transparent);    color: var(--ok-600); }
table.data .mini-avatar.avatar-c2 { background: color-mix(in srgb, var(--warn-600) 18%, transparent);  color: var(--warn-600); }
table.data .mini-avatar.avatar-c3 { background: color-mix(in srgb, var(--alert-500) 18%, transparent); color: var(--alert-600); }
table.data .mini-avatar.avatar-c4 { background: color-mix(in srgb, var(--brand-700) 14%, transparent); color: var(--brand-700); }
table.data .mini-avatar.avatar-c5 { background: var(--bg-sunken); color: var(--text-muted); }

/* ───────── Overrides forzados sobre MudBlazor (carga después en index.html) ───────── */

/* Sidebar: tamaño y alineación uniformes para todos los iconos del menú,
   independientes de mud-icon-size-* o intrinsic SVG sizing. */
.sidebar-nav .nav-item {
  padding-left: 12px;
  padding-right: 12px;
  justify-content: flex-start;
  text-align: left;
}
.sidebar-nav .nav-item .icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex: 0 0 18px;
  display: inline-block;
  vertical-align: middle;
}
.sidebar-nav .nav-item .label {
  flex: 1 1 auto;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chip de icono (Acciones rápidas, listados de avisos, etc.).
   Tamaño y centrado fijos para que distintos iconos Material se vean igual de
   "anchos" aunque internamente tengan padding distinto. */
.qa-ico {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-100);
  color: var(--brand-700);
}
.qa-ico > svg,
.qa-ico .mud-icon-root {
  width: 22px;
  height: 22px;
  font-size: 22px;
  display: block;
}

/* Quick-action button: foco accesible coherente con el design system. */
.qa { outline: none; }
.qa:focus-visible {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(46,90,198,0.18);
}

/* ───────── Tablas: cabeceras ordenables + filas clicables ───────── */
table.data thead th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 26px;
}
table.data thead th.sortable:hover { color: var(--text); background: color-mix(in srgb, var(--bg-sunken) 70%, var(--brand-100)); }
table.data thead th.sortable.actions { padding-right: 14px; }
table.data thead th .sort-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity .12s, color .12s;
}
table.data thead th.sortable:hover .sort-arrow { opacity: 0.5; }
table.data thead th.sortable.sorted { color: var(--brand-700); }
table.data thead th.sortable.sorted .sort-arrow { opacity: 1; color: var(--brand-700); }

table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--brand-50); }
[data-theme="dark"] table.data tbody tr.clickable:hover td {
  background: color-mix(in srgb, var(--brand-700) 18%, transparent);
}
/* Acciones de fila: no deben heredar el cursor pointer del tr clickable */
table.data tbody tr.clickable td.actions,
table.data tbody tr.clickable td .row-action,
table.data tbody tr.clickable td button {
  cursor: pointer;
}

/* ============================================================ */
/* Layout publico (anonimo): MisTickets, TicketPublico, Reserva */
/* ============================================================ */
.public-shell {
  min-height: 100vh;
  background: var(--bg);
  padding: 28px 18px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.public-hero {
  width: 100%;
  max-width: 880px;
}
.public-hero-inner {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color: #fff;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.public-brand-mark img {
  width: 78px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 18px rgba(0,0,0,0.18));
  background: rgba(255,255,255,0.94);
  border-radius: var(--r-md);
  padding: 6px;
}
.public-eyebrow {
  margin: 0 0 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: rgba(255,255,255,0.78);
}
.public-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.public-sub {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(255,255,255,0.92);
  max-width: 60ch;
}
@media (max-width: 560px) {
  .public-hero-inner { grid-template-columns: 60px 1fr; padding: 18px 18px; gap: 14px; }
  .public-brand-mark img { width: 56px; }
  .public-title { font-size: 22px; }
}

.public-content {
  width: 100%;
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.public-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 22px 24px;
}
.public-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 4px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.public-toolbar strong { color: var(--text); }
@media (max-width: 560px) {
  .public-toolbar .btn { width: 100%; justify-content: center; }
}

.public-footer {
  width: 100%;
  max-width: 880px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px 0;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.public-footer a { color: var(--brand-700); }

.empty-state {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 28px;
}
.empty-state h2 {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.empty-state p { margin: 0; max-width: 52ch; }
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  color: var(--brand-700);
}
.empty-icon.warning { background: var(--bad-100); color: var(--bad-600); }
.empty-icon.success { background: var(--ok-100); color: var(--ok-600); }

/* Ticket grid (MisTickets + TicketPublico) */
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.ticket-card { padding: 0; overflow: hidden; }
.ticket-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.ticket-num { font-weight: 700; color: var(--text); font-size: 14.5px; }
.ticket-card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ticket-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ticket-qr {
  width: 100%;
  height: auto;
  min-height: 220px;
  max-width: 320px;
  margin: 0 auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: #fff;
}

/* Tarjeta principal en TicketPublico (mobile-first, QR grande) */
.ticket-public-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}
.ticket-public-card .ticket-qr-large {
  width: 100%;
  max-width: 360px;
  height: auto;
  margin: 6px auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: #fff;
}
.ticket-public-card .event-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.ticket-public-card .event-when {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}
.ticket-public-card .help {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Reserva publica */
.reserva-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 22px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.reserva-info h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.reserva-info p { margin: 0; font-size: 13.5px; color: var(--text-muted); line-height: 1.5; }
.reserva-info .price-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.reserva-info .price-row span { font-size: 13.5px; color: var(--text); }
.reserva-info .price-row strong { color: var(--brand-700); }

.reserva-cerrada {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--bad-100);
  color: var(--bad-600);
  border: 1px solid color-mix(in srgb, var(--bad-600) 25%, transparent);
  font-size: 13.5px;
}

/* ============================================================ *
 * QR Studio - barra de plantillas guardadas
 * ============================================================ */
.qr-templates-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  margin-bottom: 18px;
  background: color-mix(in srgb, var(--brand-50) 60%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  flex-wrap: wrap;
}
.qr-tpl-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--brand-900);
  white-space: nowrap;
}
.qr-tpl-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.qr-tpl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.qr-tpl-chip:hover {
  border-color: var(--brand-700);
  color: var(--brand-900);
}
.qr-tpl-chip.active {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: white;
}
.qr-tpl-chip .qr-tpl-x {
  display: inline-flex;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.qr-tpl-chip .qr-tpl-x:hover {
  background: var(--bad-100);
  color: var(--bad-600);
}

/* ============================================================ *
 * Editor de Entradas (/plantillas-entrada)
 * ============================================================ */
.entrada-editor-grid {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - 220px);
}
@media (max-width: 1100px) {
  .entrada-editor-grid { grid-template-columns: 1fr; }
}
.entrada-aside,
.entrada-props {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.ee-aside-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.ee-aside-head h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-700);
}
.ee-empty {
  text-align: center;
  padding: 32px 12px;
  color: var(--text-muted);
}
.ee-empty p { font-size: 13px; margin: 8px 0 0; }
.ee-tpl-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ee-tpl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.12s ease;
}
.ee-tpl-item:hover { background: var(--bg-elev); border-color: var(--border); }
.ee-tpl-item.active {
  background: color-mix(in srgb, var(--brand-700) 8%, var(--surface));
  border-color: var(--brand-700);
}
.ee-tpl-orient {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--brand-50) 100%, transparent);
  color: var(--brand-900);
  flex-shrink: 0;
}
.ee-tpl-text { flex: 1; min-width: 0; }
.ee-tpl-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.ee-tpl-meta { font-size: 11.5px; color: var(--text-muted); }
.ee-tpl-del {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}
.ee-tpl-del:hover { background: var(--bad-100); color: var(--bad-600); }

.ee-presets {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.ee-presets-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 4px;
}

/* Centro: lienzo */
.entrada-canvas-wrap {
  display: flex; flex-direction: column;
  gap: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}
.ee-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 8px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.ee-zoom {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.ee-undo {
  display: inline-flex; align-items: center; gap: 4px;
  border-left: 1px solid var(--border);
  padding-left: 8px;
}
.ee-multi-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.ee-shortcuts-hint {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--bg-elev);
  border-radius: var(--r-pill);
  cursor: help;
}
.ee-canvas-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, var(--ink-100) 25%, transparent 25%),
    linear-gradient(-45deg, var(--ink-100) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--ink-100) 75%),
    linear-gradient(-45deg, transparent 75%, var(--ink-100) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: var(--ink-50);
  padding: 24px;
  border-radius: var(--r-md);
  min-height: 400px;
  overflow: auto;
}
.ee-canvas {
  position: relative;
  box-shadow: var(--shadow-xl);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
  cursor: default;
}
.ee-qr-preview {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,0.78);
  outline: 2px dashed var(--brand-700);
  border-radius: 4px;
  cursor: pointer;
  color: var(--brand-900);
  z-index: 5;
}
.ee-field {
  position: absolute;
  padding: 2px 4px;
  cursor: move;
  outline: 1px dashed transparent;
  white-space: pre-wrap;
  line-height: 1.2;
  user-select: none;
  touch-action: none;
}
.ee-field:hover {
  outline-color: color-mix(in srgb, var(--brand-700) 60%, transparent);
}
.ee-field.selected {
  outline: 2px solid var(--brand-700);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--brand-700) 8%, transparent);
}
.ee-qr-area {
  position: absolute;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--brand-700);
  color: var(--brand-700);
  font-weight: 700;
  cursor: pointer;
  z-index: 8;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  font-size: 14px;
}
.ee-qr-area:hover { background: var(--brand-700); color: white; }
.ee-qr-area.active { background: var(--brand-700); color: white; }

.ee-add-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.ee-add-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 11px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.12s ease;
}
.ee-add-chip:hover { background: var(--brand-700); color: white; border-color: var(--brand-700); }

/* Panel derecho: propiedades */
.ee-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elev);
  border-radius: var(--r-md);
  padding: 4px;
  margin-bottom: 12px;
}
.ee-tabs button {
  flex: 1;
  padding: 8px 6px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.ee-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ee-tabs button:disabled { opacity: 0.45; cursor: not-allowed; }
.ee-props-body { display: flex; flex-direction: column; gap: 12px; }
.ee-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.ee-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ee-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.ee-field-head {
  display: flex; align-items: center; justify-content: space-between;
}
.ee-preview-img {
  margin-top: 10px;
  background: var(--ink-100);
  padding: 8px;
  border-radius: var(--r-md);
}
.ee-preview-img img { width: 100%; display: block; border-radius: 4px; }
.color-pick {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12.5px; color: var(--text-muted);
}
.color-pick input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
.segmented.full { width: 100%; }
.segmented.full button { flex: 1; }

/* ============================================================ *
 * Wizard de Eventos (/eventos/nuevo)
 * ============================================================ */
.wizard-shell {
  max-width: 1400px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px;
}
.wizard-head {
  display: flex; flex-direction: column; gap: 14px;
}
.wizard-title h1 {
  font-size: 28px; font-weight: 700; margin: 6px 0 4px; color: var(--text);
}
.wizard-title p { margin: 0; }
.wizard-stepper {
  display: flex; align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.wizard-step {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 0;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.wizard-step:disabled { opacity: 0.45; cursor: not-allowed; }
.wizard-step.active { background: var(--brand-700); color: white; }
.wizard-step.done { color: var(--brand-900); }
.wizard-step.done .wizard-step-dot { background: var(--brand-700); color: white; }
.wizard-step-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 11px;
  flex-shrink: 0;
}
.wizard-step.active .wizard-step-dot { background: white; color: var(--brand-700); border-color: white; }
.wizard-step-line {
  width: 24px; height: 2px;
  background: var(--border);
  flex-shrink: 0;
}
.wizard-step-line.done { background: var(--brand-700); }

.wizard-grid {
  display: grid;
  grid-template-columns: 1fr 460px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1100px) {
  .wizard-grid { grid-template-columns: 1fr; }
}

.wizard-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 480px;
}
.wz-step h2 {
  font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 4px;
}
.wz-step .muted { margin: 0 0 18px; }

.wizard-foot {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.wz-tipos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.wz-tipo-card {
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.wz-tipo-card:hover {
  border-color: var(--brand-700);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.wz-tipo-card.active {
  border-color: var(--brand-700);
  background: color-mix(in srgb, var(--brand-700) 10%, var(--surface));
}
.wz-tipo-icon {
  width: 56px; height: 56px;
  margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-700) 12%, transparent);
  color: var(--brand-900);
}
.wz-tipo-card.active .wz-tipo-icon { background: var(--brand-700); color: white; }
.wz-tipo-label { font-weight: 700; font-size: 14px; color: var(--text); }
.wz-tipo-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

.wz-section-h {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 18px 0 8px;
}
.wz-tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.wz-tpl-card {
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
}
.wz-tpl-card:hover { border-color: var(--brand-700); }
.wz-tpl-card.active {
  border-color: var(--brand-700);
  background: color-mix(in srgb, var(--brand-700) 8%, var(--surface));
}
.wz-tpl-card.sm { padding: 8px; }
.wz-tpl-thumb {
  height: 80px;
  border-radius: var(--r-md);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-900);
  margin-bottom: 8px;
  overflow: hidden;
}
.wz-tpl-thumb.vertical { background: linear-gradient(135deg, var(--brand-50), var(--brand-100)); }
.wz-tpl-thumb.horizontal { background: linear-gradient(45deg, var(--accent-100), var(--brand-50)); }
.wz-tpl-thumb img { width: 80%; max-height: 76px; object-fit: contain; }
.wz-tpl-thumb.loading { opacity: 0.55; position: relative; }
.wz-tpl-loading {
  position: absolute; right: 8px; bottom: 8px;
  width: 14px; height: 14px;
  border: 2px solid color-mix(in srgb, var(--brand-700) 30%, transparent);
  border-top-color: var(--brand-700);
  border-radius: 50%;
  animation: wzspin 0.8s linear infinite;
}
@keyframes wzspin { to { transform: rotate(360deg); } }
.wz-tpl-name { font-weight: 600; font-size: 13px; color: var(--text); }

.wz-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-50);
  border: 1px solid color-mix(in srgb, var(--accent-700) 25%, transparent);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
}
.wz-help a { color: var(--brand-700); font-weight: 600; }

.wz-summary {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.wz-summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.wz-summary-row:last-child { border-bottom: 0; }
.wz-summary-row strong { text-align: right; }

/* Preview lateral del wizard */
.wizard-preview {
  position: sticky;
  top: 88px;
}
.wizard-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.wizard-preview-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.wizard-preview-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--brand-50);
  color: var(--brand-900);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
}
.wizard-preview-img {
  background: var(--ink-100);
  padding: 12px;
  border-radius: var(--r-md);
}
.wizard-preview-img img { width: 100%; display: block; border-radius: 4px; }
.wizard-preview-placeholder {
  background: var(--bg-elev);
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
}
.wizard-preview-placeholder p { font-size: 13px; margin: 12px 0 0; }
.wizard-preview-summary {
  margin-top: 14px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.wizard-preview-row {
  display: flex; justify-content: space-between;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.wizard-preview-row:last-child { border-bottom: 0; }
.wizard-preview-row strong { text-align: right; }

/* ============== Mis sesiones (/mi-cuenta/sesiones) ============== */
.sesiones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.sesion-card {
  position: relative;
  transition: transform .08s ease, box-shadow .12s ease;
}
.sesion-card:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.sesion-card.actual {
  border-color: color-mix(in srgb, var(--ok-600) 60%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok-600) 18%, transparent);
}
.sesion-icono {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  color: var(--accent);
}
.sesion-card.actual .sesion-icono {
  background: color-mix(in srgb, var(--ok-600) 14%, var(--bg));
  color: var(--ok-600);
}
.sesion-cuerpo { flex: 1; min-width: 0; }
.sesion-titulo { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; flex-wrap: wrap; }
.sesion-ua {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  word-break: break-all;
  line-height: 1.4;
}
.sesion-acciones { flex-shrink: 0; }
.btn.warning {
  background: color-mix(in srgb, var(--warn-600) 14%, transparent);
  color: var(--warn-600);
  border: 1px solid color-mix(in srgb, var(--warn-600) 30%, var(--border));
}
.btn.warning:hover:not(:disabled) {
  background: color-mix(in srgb, var(--warn-600) 22%, transparent);
}

/* Menu del user-chip del header */
.user-chip-wrap { position: relative; }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: 6px;
  z-index: 50;
}
.user-menu .user-menu-head {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-menu .user-menu-head .nm { font-size: 13px; font-weight: 600; color: var(--text); }
.user-menu .user-menu-head .em { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.user-menu button.user-menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: 0; background: transparent;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.user-menu button.user-menu-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.user-menu button.user-menu-item.danger { color: var(--bad-600); }
.user-menu button.user-menu-item.danger:hover { background: color-mix(in srgb, var(--bad-600) 10%, transparent); }
.user-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.user-menu-scrim {
  position: fixed; inset: 0;
  z-index: 49;
}

/* --- Avisos: motor automatico + toggle plantilla --- */
.motor-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: help;
  user-select: none;
}
.motor-pill .b-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 8px;
}
.motor-pill.on { border-color: color-mix(in srgb, var(--ok-600) 35%, var(--border)); }
.motor-pill.on .b-dot {
  background: var(--ok-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok-600) 18%, transparent);
}
.motor-pill.off { color: var(--text-muted); }
.motor-pill.off .b-dot { background: var(--warn-600); }

.toggle {
  position: relative;
  display: inline-block;
  width: 38px; height: 22px;
  flex: 0 0 38px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s ease, border-color .15s ease;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  left: 2px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
  transition: left .15s ease, background .15s ease;
}
.toggle input:checked + .slider {
  background: color-mix(in srgb, var(--ok-600) 70%, transparent);
  border-color: color-mix(in srgb, var(--ok-600) 60%, var(--border));
}
.toggle input:checked + .slider::before { left: 18px; }
.toggle input:focus-visible + .slider {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 2px;
}

/* ───────────── Modal detalle del socio (/socios) ─────────────
   Antes era un drawer lateral derecho — el operador prefiere un modal
   centrado grande (estilo "Detalle de la solicitud") porque permite
   tablas más anchas dentro y deja el listado visible al fondo. La clase
   `.socio-drawer` se mantiene por compatibilidad con todos los `.sd-*`
   internos; lo que cambia es la posición/forma del contenedor.

   `.drawer-overlay` sigue siendo el fondo fijo genérico (lo usa también
   el drawer de eventos). El modificador `.drawer-overlay.centered`
   activa el modo "modal centrado" sin tocar a los otros consumidores. */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(10,13,25,0.45);
  backdrop-filter: blur(2px);
  z-index: 950;
  animation: fadeIn .14s ease;
}
.drawer-overlay.centered {
  display: grid;
  place-items: center;
  padding: 24px;
}
.socio-drawer {
  position: relative;
  width: min(1100px, 100%);
  max-height: min(92vh, 920px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  z-index: 951;
  display: flex; flex-direction: column;
  animation: socioModalIn .18s ease;
  outline: none;
  overflow: hidden;
}
@keyframes socioModalIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sd-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.sd-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sd-identity .mini-avatar.lg {
  width: 44px; height: 44px;
  background: var(--brand-100); color: var(--brand-700);
  border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: 14px; font-weight: 700;
  flex: 0 0 44px;
}
.sd-titles { min-width: 0; }
.sd-name {
  font-size: 16px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 540px;
}
.sd-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted);
  margin-top: 2px;
}
.sd-meta .mono { font-family: var(--font-mono, monospace); font-size: 12px; }
.sd-dot { color: var(--text-muted); opacity: 0.6; }
.sd-actions { display: flex; align-items: center; gap: 8px; }
.sd-actions .btn { padding: 7px 12px; font-size: 12.5px; }

.sd-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sd-tab {
  border: 0; background: transparent;
  padding: 12px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.sd-tab:hover { color: var(--text); }
.sd-tab.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-700);
  font-weight: 600;
}
[data-theme="dark"] .sd-tab.active { color: var(--brand-500); border-bottom-color: var(--brand-500); }

.sd-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
}
.sd-section { display: flex; flex-direction: column; gap: 16px; }
.sd-loading { display: flex; flex-direction: column; gap: 12px; }
.sd-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 36px 16px;
  color: var(--text-muted);
  text-align: center;
}
.sd-empty h4 { margin: 0; color: var(--text); font-size: 15px; }
.sd-empty p { margin: 0; font-size: 13px; }

/* Antes 2 columnas fijas; ahora aprovecha el ancho del modal (1100px) con
   auto-fit. En anchos cortos cae a 1 columna sin necesidad de media query. */
.sd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 20px;
}
.sd-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--bg-sunken);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.sd-stat { display: flex; flex-direction: column; gap: 2px; }
.sd-stat-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sd-stat-value { font-size: 15px; font-weight: 700; color: var(--text); }
.sd-eur { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.sd-row-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.sd-h { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.sd-inline-empty {
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
.sd-inline-empty.muted { color: var(--text-muted); }

.sd-table-wrap { overflow-x: auto; }
.sd-table {
  width: 100%;
  font-size: 12.5px;
}
.sd-table th { padding: 8px 10px; }
.sd-table td { padding: 8px 10px; }
.sd-table .row-action { padding: 4px 6px; }

.sd-history {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.sd-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.sd-history-row:first-child { border-top: 0; }
.sd-history-period { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.sd-history-importe { font-size: 13.5px; font-weight: 700; color: var(--text); text-align: right; }
.sd-history-meta { grid-column: 1 / -1; font-size: 11.5px; }

.sd-just-cell {
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.sd-just-cell label.row-action {
  display: inline-grid; place-items: center;
  cursor: pointer;
}
.sd-upload-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--brand-700);
  cursor: pointer;
  font-size: 12px; font-weight: 600;
}
.sd-upload-link:hover {
  background: var(--brand-100);
  border-style: solid;
  border-color: var(--brand-500);
}
[data-theme="dark"] .sd-upload-link { color: var(--brand-500); }

.sd-foot-note { margin: 6px 0 0; }

/* ───── Pestaña "Documentos" del modal del socio ─────
   Bloque uploader (input file estilizado + campos meta) + tabla. */
.sd-doc-uploader {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-sunken);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.sd-doc-up-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}
.sd-doc-up-row > input[type="text"],
.sd-doc-up-row .sd-doc-up-cat,
.sd-doc-up-row .sd-doc-up-desc {
  flex: 1 1 200px;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.sd-doc-up-row .sd-doc-up-desc { flex: 2 1 300px; }
.sd-doc-up-row > input[type="text"]:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.sd-doc-up-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  flex: 1 1 280px;
  min-width: 0;
}
.sd-doc-up-file:hover { border-color: var(--brand-500); background: var(--brand-100); color: var(--brand-700); }
.sd-doc-up-file > span {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}
.sd-doc-up-file:hover > span { color: var(--brand-700); }

.sd-doc-ico {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  background: var(--bg-sunken);
  border-radius: 6px;
  margin-right: 8px;
  vertical-align: middle;
}
.sd-doc-ico .mud-icon-root { width: 16px; height: 16px; }

.sd-notas {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  outline: none;
  resize: vertical;
}
.sd-notas:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(46,90,198,0.15);
}
.sd-notas-view {
  padding: 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.sd-danger {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--bad-600) 28%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--bad-100) 30%, transparent);
}
.sd-danger .btn.danger,
.sd-danger .btn.ghost.danger {
  color: var(--bad-600);
  border-color: color-mix(in srgb, var(--bad-600) 40%, var(--border));
}
.sd-danger .btn.danger:hover { background: var(--bad-600); color: white; border-color: var(--bad-600); }
.sd-confirm { display: flex; flex-direction: column; gap: 10px; }
.sd-confirm-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.sd-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.field-locked input,
.field-locked select {
  background: var(--bg-sunken);
  cursor: not-allowed;
  opacity: 0.85;
}
.field-lock-hint {
  font-size: 11px; font-weight: 500; color: var(--text-muted); margin-left: 6px;
}

@media (max-width: 760px) {
  .drawer-overlay.centered { padding: 12px; }
  .socio-drawer {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    border-radius: 10px;
  }
  .sd-grid { grid-template-columns: 1fr; }
  .sd-stats { grid-template-columns: 1fr 1fr; }
  .sd-history-row { grid-template-columns: 1fr; }
  .sd-history-importe { text-align: left; }
  .sd-name { max-width: 200px; }
}


/* ───────────────── Recaudación mensual: barras apiladas ────────────────────
   Reescrito en 2026-05-08. Antes era un .bars HTML sencillo con dos divs por
   mes; ahora es un gráfico con eje Y ticks, líneas guía, barras apiladas
   reales (un solo "tallo" por mes con segmentos), tooltip flotante y resumen
   anual con desglose Cuotas/Donativos.
   Hecho con grid + CSS variables para no necesitar SVG ni JS de chart. */
.recaud-summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 4px 4px 14px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 14px;
}
.recaud-sum-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-subtle); }
.recaud-sum-value { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 2px; }
.recaud-sum-value .recaud-eur { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 4px; }
.recaud-sum-bar {
  flex: 1; max-width: 280px;
  height: 8px; border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
  display: flex;
  position: relative;
}
.recaud-sum-bar-cuotas {
  height: 100%; width: var(--w, 0%);
  background: linear-gradient(90deg, var(--brand-700), var(--brand-500));
  transition: width .6s cubic-bezier(.4,.0,.2,1);
}
.recaud-sum-bar-don {
  height: 100%; flex: 1;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-600) 60%, transparent), color-mix(in srgb, var(--accent-600) 30%, transparent));
}

.recaud-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.recaud-swatch {
  width: 12px; height: 12px; border-radius: 3px; display: inline-block;
}
.recaud-swatch.cuotas { background: linear-gradient(180deg, var(--brand-700), var(--brand-500)); }
.recaud-swatch.donativos { background: linear-gradient(180deg, color-mix(in srgb, var(--accent-600) 80%, transparent), color-mix(in srgb, var(--accent-600) 45%, transparent)); }
.recaud-swatch.current {
  background: transparent;
  border: 1.5px solid var(--brand-500);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand-500) 25%, transparent);
}

.recaud-chart {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  height: 200px;
}
.recaud-yaxis {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 4px 0 22px; /* 22px = espacio del eje X (etiquetas mes) abajo */
  text-align: right;
}
.recaud-ytick {
  font-size: 10.5px; color: var(--text-subtle); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.recaud-plot {
  position: relative;
}
.recaud-grid-lines {
  position: absolute; inset: 4px 0 22px 0;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none;
  z-index: 0;
}
.recaud-grid-lines span {
  display: block; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--border) 25%, var(--border) 75%, transparent 100%);
  opacity: .55;
}
.recaud-bars {
  position: relative; z-index: 1;
  display: flex; gap: 6px;
  height: 100%;
  padding-bottom: 22px;
  align-items: flex-end;
}
.recaud-bar-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  height: 100%;
  position: relative;
  cursor: default;
}
.recaud-bar-stack {
  width: 100%;
  flex: 1 1 auto;
  display: flex; flex-direction: column-reverse;
  border-radius: 5px 5px 0 0;
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg-sunken) 60%, transparent));
}
.recaud-bar {
  height: var(--h, 0%);
  width: 100%;
  transition: height .55s cubic-bezier(.34,1.2,.55,1);
  animation: recaud-rise .55s cubic-bezier(.34,1.2,.55,1);
}
.recaud-bar.cuotas {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
}
.recaud-bar.donativos {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent-600) 78%, transparent),
    color-mix(in srgb, var(--accent-600) 45%, transparent));
}
@keyframes recaud-rise { from { height: 0; } }

.recaud-bar-col:hover .recaud-bar-stack { box-shadow: 0 0 0 1px var(--brand-500); }
.recaud-bar-col.is-current .recaud-bar-stack {
  outline: 1.5px solid var(--brand-500);
  outline-offset: 1px;
  border-radius: 5px 5px 0 0;
}
.recaud-bar-col.is-current .recaud-month { color: var(--brand-700); font-weight: 700; }
.recaud-bar-col.is-empty .recaud-bar-stack {
  /* Indicador discreto para meses sin movimiento — una línea base. */
  background:
    linear-gradient(0deg, var(--border) 0%, var(--border) 1.5px, transparent 1.5px),
    var(--bg-sunken);
}

.recaud-month {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  position: absolute;
  bottom: 4px;
  left: 0; right: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Tooltip — flota sobre la barra al hover. */
.recaud-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translate(-50%, 4px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 8px 10px;
  font-size: 11.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  z-index: 10;
  min-width: 140px;
}
.recaud-bar-col:hover .recaud-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}
.recaud-tooltip .rt-month {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-subtle); margin-bottom: 2px;
}
.recaud-tooltip .rt-total {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
}
.recaud-tooltip .rt-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-muted);
  line-height: 1.6;
}
.recaud-tooltip .rt-row .rt-val {
  margin-left: auto;
  font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.recaud-tooltip .rt-dot {
  width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px;
}
.recaud-tooltip .rt-dot.cuotas { background: var(--brand-700); }
.recaud-tooltip .rt-dot.donativos { background: color-mix(in srgb, var(--accent-600) 70%, transparent); }

/* Tooltip se invierte si la barra es de las primeras dos columnas (no se sale por la izquierda) */
.recaud-bar-col:first-child .recaud-tooltip,
.recaud-bar-col:nth-child(2) .recaud-tooltip {
  left: 0; transform: translate(0, 4px);
}
.recaud-bar-col:first-child:hover .recaud-tooltip,
.recaud-bar-col:nth-child(2):hover .recaud-tooltip {
  transform: translate(0, 0);
}
.recaud-bar-col:nth-last-child(-n+2) .recaud-tooltip {
  left: auto; right: 0; transform: translate(0, 4px);
}
.recaud-bar-col:nth-last-child(-n+2):hover .recaud-tooltip {
  transform: translate(0, 0);
}

@media (max-width: 720px) {
  .recaud-summary { flex-direction: column; align-items: stretch; gap: 8px; }
  .recaud-sum-bar { max-width: none; }
  .recaud-month { font-size: 9.5px; }
}

/* ─────────────── Buscador global del header ──────────────────────────────
   Reescrito en 2026-05-08. Antes era un <input> sin lógica; ahora dispara
   /api/buscar tras 220ms de inactividad y muestra resultados agrupados por
   tipo (socios / eventos / cuotas / donativos) con navegación por teclado
   (↑ ↓ Enter Esc) y resaltado del término coincidente. Atajo Ctrl+K (⌘K en
   Mac) para enfocar desde cualquier sitio. */
.search-wrap {
  position: relative;
  width: 360px;
  min-width: 220px;
  max-width: 38vw;
}
.search-wrap .search { width: 100%; max-width: none; }

.search.open input {
  border-color: var(--brand-500);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px rgba(46,90,198,0.18);
}

.search .s-spinner {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: inline-flex;
}
.search .s-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px;
  border: 0; background: transparent;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-subtle);
  cursor: pointer;
}
.search .s-clear:hover { background: var(--bg-sunken); color: var(--text); }

.search-backdrop {
  position: fixed; inset: 0;
  z-index: 90;
  background: transparent;
}

.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 480px);
  max-width: 720px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 6px 6px 8px;
  animation: search-pop .12s ease-out;
}
@keyframes search-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-state {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.search-state.empty { color: var(--text); }
.search-state strong { color: var(--text); font-weight: 600; }

.search-tips {
  padding: 12px 14px 14px;
}
.search-tips .tips-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-subtle);
  margin-bottom: 8px;
}
.search-tips ul {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.search-tips li {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 8px;
}
.search-tips li > .mud-icon-root, .search-tips li svg {
  color: var(--brand-700);
  flex: 0 0 18px;
}
.search-tips li em { font-style: normal; color: var(--text-subtle); }
.search-tips li code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text);
}

.search-group { padding: 4px; }
.search-group + .search-group { border-top: 1px dashed var(--border); margin-top: 4px; }
.search-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-subtle);
}
.search-group-head .search-group-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  flex: 0 0 18px;
}
.search-group-head .search-group-icon.socio    { background: var(--brand-100);  color: var(--brand-700); }
.search-group-head .search-group-icon.evento   { background: var(--warn-100);   color: var(--warn-600); }
.search-group-head .search-group-icon.cuota    { background: var(--ok-100);     color: var(--ok-600); }
.search-group-head .search-group-icon.donativo { background: var(--alert-100);  color: var(--alert-600); }
.search-group-title { flex: 1; }
.search-group-count {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0;
  font-weight: 600;
}

.search-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0; background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.search-item:hover, .search-item.active {
  background: var(--brand-50);
}
.search-item.active { box-shadow: inset 0 0 0 1px var(--brand-200); }

.search-item-tipo {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.search-item-tipo.socio    { background: var(--brand-100);  color: var(--brand-700); }
.search-item-tipo.evento   { background: var(--warn-100);   color: var(--warn-600); }
.search-item-tipo.cuota    { background: var(--ok-100);     color: var(--ok-600); }
.search-item-tipo.donativo { background: var(--alert-100);  color: var(--alert-600); }
.search-item-tipo .mud-icon-root { width: 18px; height: 18px; }

.search-item-text { flex: 1; min-width: 0; }
.search-item-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-item-sub {
  font-size: 11.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-item mark {
  background: color-mix(in srgb, var(--warn-100) 80%, transparent);
  color: var(--warn-600);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 700;
}
.search-item.active mark {
  background: var(--warn-100);
}
.search-item-go {
  color: var(--text-subtle);
  flex: 0 0 18px;
  opacity: 0.6;
}
.search-item.active .search-item-go { color: var(--brand-700); opacity: 1; }

.search-foot {
  display: flex; gap: 14px;
  padding: 8px 12px 4px;
  font-size: 11px;
  color: var(--text-subtle);
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}
.search-foot kbd {
  padding: 1px 6px;
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-sunken);
  margin-right: 4px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .search-wrap { width: 200px; }
  .search-panel { width: min(92vw, 520px); right: 0; left: auto; }
}

/* ─── App Toasts (AppNotificationsHost) ────────────────────────────────────── */

.app-toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1400;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.app-toast {
  pointer-events: auto;
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: flex-start;
  gap: 10px;
  width: 360px;
  max-width: 100%;
  padding: 12px 12px 14px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-500);
  border-radius: 12px;
  box-shadow: var(--shadow-md, 0 8px 28px rgba(0,0,0,0.18));
  overflow: hidden;
  animation: app-toast-in 220ms cubic-bezier(.2,.8,.2,1) both;
  font-family: var(--font-sans, inherit);
}

.app-toast.dismissing {
  animation: app-toast-out 220ms cubic-bezier(.6,0,.8,.2) forwards;
}

.app-toast.severity-success { border-left-color: var(--ok-600); }
.app-toast.severity-warning { border-left-color: var(--warn-600); }
.app-toast.severity-error   { border-left-color: var(--bad-600); }
.app-toast.severity-info    { border-left-color: var(--brand-500); }

.app-toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  background: var(--brand-100);
  color: var(--brand-700);
}
.app-toast.severity-success .app-toast-icon { background: var(--ok-100); color: var(--ok-600); }
.app-toast.severity-warning .app-toast-icon { background: var(--warn-100); color: var(--warn-600); }
.app-toast.severity-error   .app-toast-icon { background: var(--bad-100); color: var(--bad-600); }
.app-toast.severity-info    .app-toast-icon { background: var(--brand-100); color: var(--brand-700); }

.app-toast-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-toast-message {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: flex;
  gap: 6px;
  align-items: center;
}

.app-toast-detail {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.app-toast-grouped-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: color-mix(in srgb, var(--brand-500) 18%, transparent);
  color: var(--brand-700);
}

.app-toast-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.app-toast-action {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.app-toast-action:hover:not(:disabled) {
  background: var(--brand-50);
  border-color: var(--brand-500);
  color: var(--brand-700);
}
.app-toast-action:disabled {
  opacity: 0.7;
  cursor: progress;
}

.app-toast-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.app-toast-close:hover {
  background: var(--bg-sunken, color-mix(in srgb, var(--text) 6%, transparent));
  color: var(--text);
}

.app-toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: color-mix(in srgb, var(--brand-500) 70%, transparent);
  transform-origin: left center;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}
.app-toast.severity-success .app-toast-progress { background: color-mix(in srgb, var(--ok-600) 70%, transparent); }
.app-toast.severity-warning .app-toast-progress { background: color-mix(in srgb, var(--warn-600) 70%, transparent); }
.app-toast.severity-error   .app-toast-progress { background: color-mix(in srgb, var(--bad-600) 70%, transparent); }

@keyframes app-toast-in {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes app-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}
@keyframes toast-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

@media (max-width: 600px) {
  .app-toast-host {
    right: 16px;
    left: 16px;
    bottom: 16px;
    align-items: stretch;
  }
  .app-toast {
    width: auto;
  }
  @keyframes app-toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes app-toast-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(20px); }
  }
}

/* =============================================================
   Atajos de teclado: prefix hint + cheatsheet (modal)
   - Prefix hint: badge flotante mientras un chord (g X) esta a medias.
   - Cheatsheet: modal listando todos los atajos disponibles. Tabs por grupo.
   ============================================================= */

.kbd-prefix-hint {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 12.5px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--shadow) 60%, transparent);
  animation: kbd-prefix-pop 140ms ease-out;
}
.kbd-prefix-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--text);
}
@keyframes kbd-prefix-pop {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.kbd-cheat-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--shadow) 70%, transparent);
  backdrop-filter: blur(2px);
  z-index: 9100;
  animation: kbd-cheat-fade 140ms ease-out;
}
.kbd-cheat {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 90vw);
  max-height: min(640px, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px color-mix(in srgb, var(--shadow) 80%, transparent);
  z-index: 9101;
  animation: kbd-cheat-pop 160ms cubic-bezier(.2,.9,.4,1.1);
}
@keyframes kbd-cheat-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes kbd-cheat-pop {
  from { transform: translate(-50%, -50%) scale(.96); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}
.kbd-cheat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.kbd-cheat-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.kbd-cheat-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 2px;
}
.kbd-cheat-sub kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-sunken);
  color: var(--text-muted);
}

.kbd-cheat-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.kbd-cheat-tab {
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.kbd-cheat-tab:hover { color: var(--text); background: var(--bg-sunken); }
.kbd-cheat-tab.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-700);
}

.kbd-cheat-body {
  padding: 14px 18px;
  overflow-y: auto;
  flex: 1;
}
.kbd-cheat-empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
}

.kbd-cheat-group { margin-bottom: 18px; }
.kbd-cheat-group:last-child { margin-bottom: 4px; }
.kbd-cheat-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-subtle);
  margin: 0 0 6px;
}
.kbd-cheat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.kbd-cheat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 6px;
  border-radius: 6px;
}
.kbd-cheat-item:hover { background: var(--bg-sunken); }
.kbd-cheat-item.info-only { opacity: .85; }
.kbd-cheat-item-label {
  font-size: 13.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.kbd-cheat-context {
  font-style: normal;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--brand-700);
  background: color-mix(in srgb, var(--brand-700) 10%, transparent);
  padding: 1px 6px;
  border-radius: 999px;
}
.kbd-cheat-item-keys {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.kbd-cheat-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kbd-cheat-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
}
/* "luego" entre dos teclas de un chord */
.kbd-cheat-keys kbd:nth-child(odd):not(:first-child) {
  /* no aplica directo: el "luego" no es kbd, ver siguiente */
}
.kbd-cheat-keys :not(kbd) {
  font-size: 10.5px;
  color: var(--text-subtle);
  text-transform: lowercase;
  font-style: italic;
}

.kbd-cheat-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
  background: var(--bg-sunken);
  border-radius: 0 0 14px 14px;
}
.kbd-cheat-tip kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-card);
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .kbd-cheat { width: 94vw; max-height: 86vh; }
  .kbd-cheat-head { padding: 14px 14px 8px; }
  .kbd-cheat-body { padding: 12px 14px; }
  .kbd-cheat-foot { padding: 10px 14px; }
}

/* =====================================================================
   Drawer de detalle de evento (componente EventoDetalleDrawer)
   Reutiliza la mayoria de estructura del drawer del socio (.drawer-overlay
   y todas las clases .sd-*); aqui solo van las variantes propias de eventos.
   ===================================================================== */

.evento-drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(100vw, 620px);
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  outline: none;
  animation: ed-slidein 180ms ease-out;
}

@keyframes ed-slidein {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.ed-head {
  padding: 18px 20px 16px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: repeating-linear-gradient(135deg, var(--brand-700) 0 8px, var(--brand-600) 8px 16px);
}
.ed-head.c2 { background: repeating-linear-gradient(135deg, #F97316 0 8px, #EA580C 8px 16px); }
.ed-head.c3 { background: repeating-linear-gradient(135deg, #16A34A 0 8px, #128A3E 8px 16px); }
.ed-head.c4 { background: repeating-linear-gradient(135deg, #CA8A04 0 8px, #A67703 8px 16px); }

.ed-head-inner { flex: 1; min-width: 0; }
.ed-head-meta { margin-bottom: 8px; }
.ed-head-meta .badge { background: rgba(255, 255, 255, 0.18); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.ed-head-meta .badge .b-dot { background: #fff; }

.ed-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
  word-break: break-word;
}
.ed-meta {
  margin-top: 8px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.92);
}
.ed-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.ed-head-actions .btn { background: rgba(255, 255, 255, 0.16); color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.ed-head-actions .btn:hover { background: rgba(255, 255, 255, 0.26); }
.ed-head-actions .btn.primary { background: #fff; color: var(--brand-700); border-color: #fff; }
.ed-head-actions .btn.primary:hover { background: var(--brand-50); }
.ed-head-actions .icon-btn { background: rgba(255, 255, 255, 0.16); color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.ed-head-actions .icon-btn:hover { background: rgba(255, 255, 255, 0.26); }

.ed-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--warn-500) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn-500) 40%, transparent);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
}

.ed-descripcion {
  background: var(--bg-sunken);
  border-radius: 8px;
  padding: 12px 14px;
}
.ed-descripcion h4 { margin: 0 0 6px; }
.ed-descripcion p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }

.ed-tickets-filtros {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ed-tickets-filtros .search { min-width: 180px; }

.ed-pasarlista-input {
  font-size: 28px !important;
  font-family: var(--font-mono) !important;
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 14px 12px !important;
}
.ed-pasarlista-ultimo {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}
.ed-pasarlista-ultimo.ok {
  background: color-mix(in srgb, var(--ok-500) 14%, transparent);
  border-color: color-mix(in srgb, var(--ok-500) 40%, transparent);
  color: var(--text);
}
.ed-pasarlista-ultimo.warn {
  background: color-mix(in srgb, var(--warn-500) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn-500) 40%, transparent);
  color: var(--text);
}

.ed-plantilla-vacia {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ed-plantilla-vacia p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.ed-plantilla-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ed-plantilla-lista li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}
.ed-plantilla-lista li > .strong { flex: 1; }
.ed-plantilla-preview {
  background: var(--bg-sunken);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  justify-content: center;
  min-height: 200px;
}
.ed-plantilla-preview img {
  max-width: 100%;
  max-height: 480px;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.ed-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 14px;
}
.ed-timeline::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}
.ed-timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}
.ed-timeline-dot {
  position: absolute;
  left: -8px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-500);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--border);
}
.ed-timeline-dot.ok { background: var(--ok-500); }
.ed-timeline-dot.warn { background: var(--warn-500); }
.ed-timeline-dot.neutral { background: var(--text-muted); }
.ed-timeline-body { flex: 1; padding-left: 16px; }
.ed-timeline-body .small { margin-top: 2px; }

@media (max-width: 760px) {
  .evento-drawer { width: 100vw; }
  .ed-head { flex-direction: column; gap: 10px; }
  .ed-head-actions { align-self: flex-end; }
  .ed-title { font-size: 18px; }
  .ed-tickets-filtros { flex-direction: column; align-items: stretch; }
  .ed-tickets-filtros .search,
  .ed-tickets-filtros .input-mini { width: 100%; }
}

/* ==========================================================================
 * Selección masiva en /socios + envío masivo + wizard de plantillas (PROMPT_13)
 * ========================================================================== */

/* Barra contextual que aparece cuando hay socios seleccionados.
 * Se sitúa entre el page-head y el table-wrap, sticky para que no se vaya al
 * scrollear listas largas. Color brand sutil para diferenciarse del card. */
.seleccion-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--brand) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--border));
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 5;
  animation: seleccion-bar-in 140ms ease-out;
}

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

/* Columna del checkbox en la tabla. Centrado y compacto. */
.data th.check-col,
.data td.check-col {
  width: 36px;
  padding: 0 4px;
  text-align: center;
  vertical-align: middle;
}

.data th.check-col input,
.data td.check-col input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Punto naranja indicador de selección parcial en la cabecera, ya que el
 * atributo HTML 'indeterminate' solo se setea por JS y no nos vale. */
.data th.check-col.parcial { position: relative; }
.data th.check-col.parcial::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn-500, #f59e0b);
}

.data tr.selected td {
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
}

/* ----- Modal de envío masivo ----- */

.envio-masivo .em-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.em-chip {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 11.5px;
}

.em-chip.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

.em-body { max-height: 60vh; overflow: auto; }

.em-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 18px;
}

.em-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.em-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.em-vars {
  background: var(--bg-sunken);
  border-radius: 10px;
  padding: 10px 12px;
}

.em-vars-head { margin-bottom: 6px; font-weight: 600; }

.em-vars-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.em-var-chip {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.em-preview-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.em-preview-title { font-weight: 600; }

.em-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 14px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-radius: 10px;
  min-height: 200px;
}

.em-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.em-preview-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.em-preview-asunto {
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}

.em-preview-cuerpo {
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 13.5px;
  color: var(--text);
  min-height: 100px;
}

.em-preview-vacias {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--text-muted);
}

.em-preview-vacias code {
  background: color-mix(in srgb, var(--warn-500, #f59e0b) 14%, var(--bg-sunken));
  padding: 1px 6px;
  border-radius: 4px;
}

.em-confirm-text {
  flex: 1;
  color: var(--text-muted);
}

@media (max-width: 880px) {
  .em-grid { grid-template-columns: 1fr; }
}

/* ----- Pestaña Plantillas /avisos: cards ----- */

.plantillas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.plantilla-card { display: flex; flex-direction: column; }

.plantilla-ico {
  background: var(--brand-100, color-mix(in srgb, var(--brand) 14%, var(--surface)));
  color: var(--brand-700, var(--brand));
}

.plantilla-preview {
  background: var(--bg-sunken);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  max-height: 88px;
  overflow: hidden;
  position: relative;
}

.plantilla-preview::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18px;
  background: linear-gradient(to bottom, transparent, var(--bg-sunken));
  pointer-events: none;
}

.plantilla-placeholder {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand-700, var(--brand));
  font-family: var(--mono-font, "JetBrains Mono", monospace);
  font-size: 11.5px;
  padding: 0 4px;
  border-radius: 3px;
}

/* ----- Wizard PlantillaEditor ----- */

.pe-modal .modal-body { max-height: 65vh; overflow: auto; }

.pe-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 24px 0;
  background: var(--surface);
}

.pe-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 13px;
  position: relative;
  flex: 1;
}

.pe-step:not(:last-child)::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: 8px;
}

.pe-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}

.pe-step.active .pe-step-num,
.pe-step.done .pe-step-num {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.pe-step.active .pe-step-label,
.pe-step.done .pe-step-label {
  color: var(--text);
  font-weight: 600;
}

.pe-tipos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.pe-tipo-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 100ms ease, background-color 100ms ease;
}

.pe-tipo-card:hover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
}

.pe-tipo-card.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
  outline-offset: -2px;
}

.pe-grid-cuerpo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 14px;
}

.pe-cuerpo-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.pe-vars-panel {
  background: var(--bg-sunken);
  border-radius: 10px;
  padding: 12px;
  align-self: flex-start;
  position: sticky;
  top: 0;
  max-height: 480px;
  overflow: auto;
}

.pe-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
}

.pe-var-row:hover { background: var(--surface); }

.pe-var-row code {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--brand-700, var(--brand));
}

.pe-resumen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pe-resumen-row {
  display: flex;
  gap: 14px;
  align-items: baseline;
}

.pe-resumen-row.column {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.pe-resumen-cuerpo {
  background: var(--bg-sunken);
  padding: 12px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 0;
  max-height: 240px;
  overflow: auto;
}

@media (max-width: 880px) {
  .pe-grid-cuerpo { grid-template-columns: 1fr; }
  .pe-vars-panel { position: static; max-height: 200px; }
}

/* ───────────────────────────────────────────────────────────────────────────
   DataList Pro — toolbar con selector de columnas, fila de filtrado y vistas
   guardadas. Lo monta <DataListToolbar> sobre <table class="data">. Reemplaza
   al patrón viejo .table-toolbar manteniendo la misma altura visual para que
   las páginas se sientan iguales tras la migración.
   ─────────────────────────────────────────────────────────────────────────── */

.dl-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  min-width: min-content;
}

.dl-tb-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.dl-tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.dl-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  max-width: 100%;
}
.dl-search .s-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.dl-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.dl-search input::placeholder { color: var(--text-muted); }
.dl-search input:focus {
  border-color: var(--brand-500);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 20%, transparent);
}

.dl-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dl-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dl-count {
  color: var(--text-muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.dl-vista-anchor {
  position: relative;
  display: inline-flex;
}

.dl-vista-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.dl-vista-btn:hover { background: var(--bg-sunken); border-color: var(--border-strong); }
.dl-vista-btn.open {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-500);
}
[data-theme="dark"] .dl-vista-btn.open {
  background: color-mix(in srgb, var(--brand-700) 22%, transparent);
  color: #DDE7FF;
}

/* Scrim invisible que cubre todo el viewport para detectar click-outside.
   Se queda DETRÁS del popover (z-index menor) para no bloquearlo. */
.dl-vista-scrim {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 80;
}

.dl-vista-popover {
  /* position:fixed con coordenadas calculadas en JS (PosicionarPopoverAsync)
     para sobresalir de contenedores con overflow restringido (table-wrap). */
  position: fixed;
  z-index: 81;
  width: 340px;
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: dl-pop-in 120ms ease-out;
  font-size: 13px;
}

@keyframes dl-pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dl-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  flex: 0 0 auto;
}
.dl-pop-close {
  width: 26px; height: 26px;
  display: inline-grid; place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}
.dl-pop-close:hover { background: var(--bg-elev); color: var(--text); }

.dl-pop-section {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.dl-pop-section + .dl-pop-section { padding-top: 0; }
.dl-pop-section:last-child { padding-bottom: 12px; }

.dl-pop-section-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 2px 0 4px;
}

.dl-pop-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.45;
}

.dl-pop-divider {
  height: 1px;
  background: var(--border);
  margin: 0 14px;
  flex: 0 0 auto;
}

/* ── Selector de columnas con drag&drop ───────────────────────────────── */

.dl-col-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 4px;
}

.dl-col-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  transition: background 100ms ease;
}
.dl-col-row:hover { background: var(--bg-sunken); }
.dl-col-row.locked { cursor: default; opacity: 0.85; }
.dl-col-row.dragging { opacity: 0.4; cursor: grabbing; }
.dl-col-row.drop-target {
  background: color-mix(in srgb, var(--brand-500) 16%, transparent);
  outline: 1px dashed var(--brand-500);
}

.dl-drag-handle {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 12px;
  color: var(--text-subtle);
  letter-spacing: -2px;
  flex: 0 0 18px;
}
.dl-col-row.locked .dl-drag-handle { color: var(--border-strong); }

.dl-col-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: inherit;
}
.dl-col-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-700);
  cursor: pointer;
  flex: 0 0 16px;
}
.dl-col-toggle input[type="checkbox"]:disabled { cursor: not-allowed; }
.dl-col-toggle span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dl-locked-tag {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.dl-pop-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  cursor: pointer;
}
.dl-pop-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-700);
  cursor: pointer;
}

/* ── Vistas guardadas ─────────────────────────────────────────────────── */

.dl-views {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dl-view-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 8px;
  transition: background 100ms ease, border-color 100ms ease;
}
.dl-view-chip:hover { background: var(--bg-sunken); }
.dl-view-chip.confirming {
  border-color: var(--bad-600);
  background: color-mix(in srgb, var(--bad-600) 8%, var(--bg-elev));
}

.dl-view-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.dl-view-name:hover { background: var(--brand-50); color: var(--brand-700); }
.dl-view-name span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dl-view-action {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}
.dl-view-action:hover { background: var(--bg-sunken); color: var(--text); }
.dl-view-action.primary {
  color: #fff;
  background: var(--brand-700);
}
.dl-view-action.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.dl-view-action.primary:hover:not(:disabled) { background: var(--brand-500); }
.dl-view-action.danger {
  color: var(--bad-600);
  font-size: 12px;
  font-weight: 600;
  width: auto;
  padding: 0 8px;
}
.dl-view-action.danger:hover { background: color-mix(in srgb, var(--bad-600) 15%, transparent); }

.dl-view-confirm {
  flex: 1;
  font-size: 12.5px;
  color: var(--bad-600);
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dl-save-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.dl-save-input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--brand-500);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.dl-save-input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 20%, transparent);
}

.dl-pop-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  border-radius: 8px;
  color: var(--brand-700);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 4px;
  transition: background 100ms ease, border-color 100ms ease;
}
.dl-pop-add:hover {
  background: var(--brand-50);
  border-color: var(--brand-500);
}
[data-theme="dark"] .dl-pop-add {
  color: #B7C8FF;
}
[data-theme="dark"] .dl-pop-add:hover {
  background: color-mix(in srgb, var(--brand-700) 18%, transparent);
}

.dl-pop-reset {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  flex: 0 0 auto;
}
.dl-pop-reset:hover { background: var(--bg-sunken); color: var(--text); }

/* ── Fila de filtrado ─────────────────────────────────────────────────── */

table.data tr.dl-filter-row td.dl-filter-cell {
  background: var(--bg-sunken);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr.dl-filter-row:hover td.dl-filter-cell {
  background: var(--bg-sunken); /* No oscurecer en hover. */
}
[data-theme="dark"] table.data tr.dl-filter-row td.dl-filter-cell {
  background: color-mix(in srgb, var(--bg-sunken) 80%, transparent);
}

.dl-filter-cell.first { padding-left: 14px; }

.dl-filter-input,
.dl-filter-select {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  transition: border-color 100ms ease, background 100ms ease;
}
.dl-filter-input::placeholder { color: var(--text-subtle); }
.dl-filter-input:hover,
.dl-filter-select:hover { border-color: var(--border); }
.dl-filter-input:focus,
.dl-filter-select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-500) 18%, transparent);
}

.dl-filter-range {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dl-filter-mini {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.dl-filter-mini:hover { border-color: var(--border); }
.dl-filter-mini:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.dl-filter-sep {
  color: var(--text-subtle);
  font-size: 11px;
  flex: 0 0 auto;
}

.dl-filter-clear {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}
.dl-filter-clear:hover { background: var(--bg-elev); color: var(--bad-600); }

/* ── Densidad compacta ────────────────────────────────────────────────── */

table.data.compact thead th {
  padding: 6px 10px;
  font-size: 11px;
}
table.data.compact tbody td {
  padding: 7px 10px;
  font-size: 12.5px;
}
table.data.compact .row-action {
  width: 24px;
  height: 24px;
}
table.data.compact .mini-avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
  margin-right: 8px;
}

/* ── Mobile ───────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .dl-toolbar { gap: 8px; padding: 10px 12px; }
  .dl-tb-left { width: 100%; }
  .dl-search { width: 100%; }
  .dl-tb-right { width: 100%; justify-content: flex-end; }
  .dl-vista-popover {
    /* En móvil ignoramos las coords inline (style) y centramos al estilo bottom-sheet. */
    width: calc(100vw - 24px);
    max-width: 360px;
    top: auto !important;
    right: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
    max-height: 80vh;
  }
}

/* =====================================================================
   Mi día — widget contextual del Dashboard
   La brújula del operador al entrar: tareas pendientes según rol y fecha.
   ===================================================================== */

.mi-dia {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.mi-dia-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 18px;
  background: linear-gradient(135deg, var(--brand-50) 0%, var(--surface) 70%);
  border-bottom: 1px solid var(--border);
}

/* Modo compacto del widget: solo deja la franja del contador + refresh
   (sin saludo/fecha/frase). 10/12 px de alto en lugar de 80. */
.mi-dia-head--compact {
  padding: 10px 14px;
}
.mi-dia--compact .mi-dia-body { padding-top: 8px; }

[data-theme="dark"] .mi-dia-head {
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--brand-700) 22%, var(--surface)) 0%,
    var(--surface) 70%);
}

.mi-dia-title { min-width: 0; flex: 1; }

.mi-dia-saludo {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.25;
}

.mi-dia-fecha {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.mi-dia-frase {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text);
  font-style: italic;
}

.mi-dia-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.mi-dia-counts {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  white-space: nowrap;
}

.mi-dia-refresh.is-loading svg {
  animation: mi-dia-spin 0.8s linear infinite;
}

@keyframes mi-dia-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.mi-dia-body { padding: 4px 0; }

.mi-dia-lista {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mi-dia-tarea {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 120ms ease;
}

.mi-dia-tarea:last-child { border-bottom: none; }

/* Borde izquierdo de severidad — pegado al lateral, sin desplazar contenido. */
.mi-dia-tarea::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
}

.mi-dia-tarea.is-info::before    { background: var(--brand-500); }
.mi-dia-tarea.is-atencion::before { background: var(--warn-600); }
.mi-dia-tarea.is-critico::before {
  background: var(--bad-600);
  animation: mi-dia-pulse 2s ease-in-out infinite;
}

@keyframes mi-dia-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--bad-600) 35%, transparent); }
  50%      { box-shadow: 0 0 0 4px color-mix(in oklab, var(--bad-600) 0%, transparent); }
}

.mi-dia-tarea:hover { background: var(--bg-sunken); }
.mi-dia-tarea.is-zen:hover { background: transparent; }

/* Icono coloreado por categoría */
.mi-dia-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  color: var(--text-muted);
}

.mi-dia-icon.cat-cuotas      { background: var(--ok-100);     color: var(--ok-600); }
.mi-dia-icon.cat-donativos   { background: var(--brand-100);  color: var(--brand-700); }
.mi-dia-icon.cat-solicitudes { background: var(--accent-100); color: var(--accent-600); }
.mi-dia-icon.cat-eventos     { background: var(--warn-100);   color: var(--warn-600); }
.mi-dia-icon.cat-avisos      { background: var(--brand-100);  color: var(--brand-700); }
.mi-dia-icon.cat-sistema     { background: var(--ink-100);    color: var(--ink-700); }

/* Tarea sintética "Todo al día": tono cálido, sin borde de severidad. */
.mi-dia-celebra {
  background: linear-gradient(135deg, var(--accent-100) 0%, var(--brand-100) 100%);
  color: var(--accent-600);
}

.mi-dia-tarea.is-zen::before { display: none; }

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

.mi-dia-tt {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.mi-dia-dt {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

/* Botón de acción al final de la fila */
.mi-dia-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--brand-700);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 120ms ease;
}

.mi-dia-go:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
}

.mi-dia-go:focus-visible {
  outline: none;
  background: var(--brand-50);
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(46, 90, 198, 0.18);
}

[data-theme="dark"] .mi-dia-go:hover {
  background: color-mix(in oklab, var(--brand-700) 25%, transparent);
}

/* Estado de error en línea */
.mi-dia-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Skeleton mientras carga */
.mi-dia-tarea.is-skeleton::before { display: none; }

.mi-dia-skel {
  background: var(--bg-sunken);
}

.mi-dia-skel-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    var(--bg-sunken) 0%,
    color-mix(in oklab, var(--bg-sunken) 60%, var(--surface)) 40%,
    var(--bg-sunken) 80%);
  background-size: 200% 100%;
  animation: mi-dia-shimmer 1.4s ease-in-out infinite;
  margin: 4px 0;
}

.mi-dia-skel-line.w-60 { width: 60%; }
.mi-dia-skel-line.w-40 { width: 40%; }

@keyframes mi-dia-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Mobile: el botón de acción se apila debajo del texto. */
@media (max-width: 640px) {
  .mi-dia-head {
    padding: 18px 16px 14px;
    flex-direction: column;
    gap: 10px;
  }
  .mi-dia-head-actions { align-self: flex-end; }
  .mi-dia-tarea {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .mi-dia-go {
    margin-left: 54px; /* alineado con el texto, no con el icono */
    margin-top: 2px;
  }
  .mi-dia-saludo { font-size: 20px; }
}

/* ───────────────────────────────────────────────────────────────────────────
   Command palette (Ctrl+P / ⌘+P)
   Paleta de acciones estilo VS Code / Linear. Buscador fuzzy con resaltado de
   coincidencias y atajos al lado de cada accion. Backdrop con blur, animacion
   scale+fade. Mobile-first. Coordina con KeyboardShortcutService — el atajo
   palette.open vive en su catalogo.
   ─────────────────────────────────────────────────────────────────────────── */

.cp-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink-950) 45%, transparent);
  backdrop-filter: blur(2px);
  z-index: 9200;
  animation: cp-fade 120ms ease-out;
}

.cp {
  position: fixed;
  top: 14vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 9201;
  overflow: hidden;
  animation: cp-pop 140ms cubic-bezier(.2,.9,.4,1.05);
}

@keyframes cp-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes cp-pop {
  from { transform: translateX(-50%) scale(.95); opacity: 0; }
  to   { transform: translateX(-50%) scale(1);   opacity: 1; }
}

.cp-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cp-input-icon {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.cp-input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  padding: 4px 0;
  min-width: 0;
}

.cp-input::placeholder {
  color: var(--text-subtle);
}

.cp-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.cp-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.cp-list {
  overflow-y: auto;
  padding: 6px 6px 8px;
  flex: 1;
}

.cp-cat-head {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-subtle);
  padding: 12px 12px 4px;
}

.cp-cat-head:first-child {
  padding-top: 6px;
}

.cp-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-sans);
  border-left: 3px solid transparent;
  transition: background-color 80ms ease, border-left-color 80ms ease;
}

.cp-item:hover {
  background: var(--bg-sunken);
}

.cp-item.active {
  background: var(--bg-sunken);
  border-left-color: var(--brand-500);
}

.cp-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Iconos por categoria — color suave de fondo + tinta */
.cp-item-icon.nav     { color: var(--brand-500); background: color-mix(in srgb, var(--brand-500) 12%, transparent); }
.cp-item-icon.create  { color: var(--ok-600);    background: color-mix(in srgb, var(--ok-600) 14%, transparent); }
.cp-item-icon.report  { color: var(--brand-700); background: color-mix(in srgb, var(--brand-700) 14%, transparent); }
.cp-item-icon.action  { color: var(--accent-600);background: color-mix(in srgb, var(--accent-600) 14%, transparent); }
.cp-item-icon.theme   { color: var(--accent-600);background: color-mix(in srgb, var(--accent-600) 12%, transparent); }
.cp-item-icon.session { color: var(--bad-600);   background: color-mix(in srgb, var(--bad-600) 14%, transparent); }
.cp-item-icon.help    { color: var(--text-muted);background: var(--bg-sunken); }
.cp-item-icon.recent  { color: var(--brand-700); background: color-mix(in srgb, var(--brand-700) 16%, transparent); }

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

.cp-item-title {
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-item-title mark {
  background: color-mix(in srgb, var(--accent-500) 38%, transparent);
  color: var(--text);
  padding: 0;
  border-radius: 2px;
  font-weight: 600;
}

.cp-item-cat {
  font-size: 11.5px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.cp-item-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cp-item-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.cp-item-shortcut em {
  font-style: italic;
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: lowercase;
}

.cp-empty {
  padding: 36px 22px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
  line-height: 1.7;
}

.cp-empty kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-sunken);
  color: var(--text-muted);
  margin: 0 2px;
}

.cp-foot {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-subtle);
  font-size: 11px;
  flex-shrink: 0;
}

.cp-foot kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-elev);
  color: var(--text-muted);
  margin: 0 1px;
}

.cp-foot-count {
  margin-left: auto;
}

@media (max-width: 600px) {
  .cp {
    top: 6vh;
    width: 96vw;
    max-height: 86vh;
  }
  .cp-input { font-size: 16px; /* evita zoom de iOS al enfocar */ }
  .cp-foot { font-size: 10px; gap: 8px; flex-wrap: wrap; }
  .cp-foot-count { width: 100%; margin-left: 0; }
  .cp-item-title { white-space: normal; }
  .cp-item-shortcut { display: none; /* en movil, atajos no aplican */ }
}

/* ════════════════════════════════════════════════════════════════════════════
   LOGROS (/logros) — pagina + cards + toasts variante hito + confeti
   ──────────────────────────────────────────────────────────────────────────── */

/* Resumen de progreso */
.logros-resumen {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.logros-resumen-num {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.logros-resumen-num .muted { font-size: 22px; font-weight: 500; color: var(--text-muted); }
.logros-resumen-bar {
  height: 6px;
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.logros-resumen-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
  border-radius: var(--r-pill);
  transition: width 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Tabs (filtro por categoria) */
.logros-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
}
.logros-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.logros-tab:hover { background: var(--bg-sunken); }
.logros-tab.active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #FFFFFF;
}
.logros-tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}
.logros-tab.active .logros-tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
}

/* Section titles */
.logros-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 12px;
}
.logros-section-title.bloqueados { color: var(--text-muted); margin-top: 30px; }
.logros-section-title .muted { color: var(--text-subtle); font-weight: 500; }

/* Grid de cards */
.logros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.logros-grid.skel .logro-card { padding: 0; }

/* Logro card */
.logro-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.logro-card.desbloqueado:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.logro-card.bloqueado {
  opacity: 0.7;
  filter: saturate(0.4);
}

.logro-card-icon {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--logro-color, var(--text-subtle)) 12%, transparent);
  color: var(--logro-color, var(--text-muted));
  --logro-color: var(--text-subtle);
}
.logro-card.desbloqueado .logro-card-icon {
  background: color-mix(in srgb, var(--logro-color) 18%, transparent);
}
.logro-card.bloqueado .logro-card-icon {
  background: var(--bg-sunken);
  color: var(--text-subtle);
}

.logro-card-lock {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
}
.logro-card-lock .mud-icon-root.mud-svg-icon { width: 13px; height: 13px; }

.logro-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.logro-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logro-dificultad {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.logro-dificultad.d-bronce { background: #F4E2D2; color: #8C5023; }
.logro-dificultad.d-plata  { background: #E2E8F0; color: #475569; }
.logro-dificultad.d-oro    { background: #FFF1C2; color: #8C6900; }
.logro-card-veces {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-600);
  background: var(--brand-50);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}
.logro-card-titulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-top: 2px;
}
.logro-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}
.logro-card-fecha {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ok-600);
  margin-top: auto;
  padding-top: 6px;
  font-weight: 500;
}
.logro-card-fecha.bloqueado {
  color: var(--text-subtle);
  font-weight: 400;
}
.logro-card-fecha .mud-icon-root.mud-svg-icon { width: 14px; height: 14px; }

.logro-card-progreso {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.logro-card-progreso-num {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.logro-card-progreso-bar {
  height: 4px;
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.logro-card-progreso-fill {
  height: 100%;
  background: var(--brand-500);
  border-radius: var(--r-pill);
  transition: width 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Dark mode tweaks de las pildoras de dificultad */
[data-theme="dark"] .logro-dificultad.d-bronce { background: #4A311E; color: #F4D5B5; }
[data-theme="dark"] .logro-dificultad.d-plata  { background: #2A3142; color: #C9D2EE; }
[data-theme="dark"] .logro-dificultad.d-oro    { background: #4D3F12; color: #FFE085; }

@media (max-width: 720px) {
  .logros-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .logro-card { min-height: 160px; padding: 14px; }
  .logro-card-titulo { font-size: 14px; }
  .logros-resumen-num { font-size: 26px; }
  .logros-resumen-num .muted { font-size: 18px; }
}

/* ──────────────────────────────────────────────────────────────────────────
   Toast variante "hito-*" — gradiente brand calido + icono pulsante.
   La diferencia con un toast Success normal es PEQUENA a proposito: la idea
   no es gritar, es marcar el momento. Mas cercano a un GitHub que a un Duolingo.
   ────────────────────────────────────────────────────────────────────────── */

.app-toast[data-category^="hito-"] {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--brand-500) 14%, var(--bg-elev)),
    var(--bg-elev) 70%);
  border-color: color-mix(in srgb, var(--brand-500) 35%, transparent);
}
.app-toast[data-category^="hito-"] .app-toast-icon {
  color: var(--brand-600);
  animation: hito-pulse 1400ms ease-in-out 2;
}
.app-toast[data-category="hito-bronce"] .app-toast-icon { color: #B57339; }
.app-toast[data-category="hito-plata"]  .app-toast-icon { color: #6B7280; }
.app-toast[data-category="hito-oro"]    .app-toast-icon { color: #D9A100; }

.app-toast[data-category="hito-oro"] {
  border-color: color-mix(in srgb, #D9A100 45%, transparent);
  box-shadow: 0 6px 20px color-mix(in srgb, #D9A100 18%, transparent), var(--shadow-md);
}

@keyframes hito-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ──────────────────────────────────────────────────────────────────────────
   Confeti sobre el icono del toast. Anchored al .app-toast-icon, sin afectar
   layout. Se autodestruye via JS tras la animacion (~1.4s + buffer).
   ────────────────────────────────────────────────────────────────────────── */

.hito-confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}
.hito-confetti-piece {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(0deg);
  animation: hito-confetti-fly 1300ms cubic-bezier(0.18, 0.84, 0.32, 1) forwards;
}
@keyframes hito-confetti-fly {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(0.6); }
  20%  { opacity: 1; }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px) + 30px))
      rotate(var(--rot, 360deg))
      scale(1);
  }
}

/* Reduced motion: el operador con esa preferencia no quiere efectos llamativos.
   Mantenemos el cambio de color del icono pero quitamos animaciones. */
@media (prefers-reduced-motion: reduce) {
  .app-toast[data-category^="hito-"] .app-toast-icon { animation: none; }
  .hito-confetti-piece { animation: none; opacity: 0; }
  .logro-card.desbloqueado:hover { transform: none; }
}
