/* =====================================================================
   BLEC — Business Leak Control · sistema de diseno
   Capa puramente visual. Conserva TODOS los nombres de clase usados por
   las vistas EJS y los hooks del JS. No cambia comportamiento.
   Paleta de marca extraida del logo: morado #6A2F8B y gris #777777.
   Mobile-first, responsive y accesible (foco visible, contraste AA).
   Conviven: tailwind.css (utilidades) + este archivo (componentes).
   ===================================================================== */

/* ---------- Tokens (modo claro) ----------------------------------- */
:root {
  /* Acento: morado BLEC (exacto del logo) */
  --accent: #6a2f8b;
  --accent-600: #582674;
  --accent-700: #47205d;
  --accent-weak: #f2e9f9;
  --accent-contrast: #ffffff;

  /* Neutros con matiz lavanda/ciruela */
  --bg: #f4f1f7;
  --bg-grad-1: #e5d3f2;
  --surface: #ffffff;
  --surface-2: #faf8fc;
  --surface-3: #f2eef6;
  --text: #231832;
  --text-muted: #6f6a77;
  --border: #e7e2ee;
  --border-strong: #cfc7da;
  --ring: #8e51b3;

  /* Estados */
  --ok: #16a34a;  --ok-bg: #dcfce7;  --ok-ink: #14532d;  --ok-bd: #bbf7d0;
  --err: #dc2626; --err-bg: #fee2e2; --err-ink: #7f1d1d; --err-bd: #fecaca;
  --info: #0369a1;--info-bg: #e0f2fe;--info-ink: #075985;--info-bd: #bae6fd;
  --warn: #b45309;--warn-bg: #fef3c7;--warn-ink: #92400e;

  /* Espaciado */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem;

  /* Tipografia */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radios y sombras */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(2, 6, 23, .06), 0 1px 3px rgba(2, 6, 23, .07);
  --shadow: 0 6px 16px rgba(2, 6, 23, .08), 0 2px 6px rgba(2, 6, 23, .05);
  --shadow-lg: 0 18px 40px rgba(2, 6, 23, .14);

  --topbar-bg: #251233;
  --control-h: 2.6rem;
}

/* ---------- Tokens (modo oscuro del SO) --------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #b384d3;
    --accent-600: #cfb0e5;
    --accent-700: #e5d3f2;
    --accent-weak: #371849;
    --accent-contrast: #250f33;

    --bg: #140e1c;
    --bg-grad-1: #371849;
    --surface: #1d1529;
    --surface-2: #251a33;
    --surface-3: #2c203c;
    --text: #efe9f6;
    --text-muted: #a99bbb;
    --border: #382a4a;
    --border-strong: #4a3960;
    --ring: #b384d3;

    --ok-bg: #052e16; --ok-ink: #bbf7d0; --ok-bd: #14532d;
    --err-bg: #3a0d0d; --err-ink: #fecaca; --err-bd: #7f1d1d;
    --info-bg: #082f49; --info-ink: #bae6fd; --info-bd: #0c4a6e;
    --warn-bg: #3a2a06; --warn-ink: #fde68a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 6px 18px rgba(0, 0, 0, .55);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, .6);
    --topbar-bg: #180f22;
  }
}

/* ---------- Base --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
/* El preflight de Tailwind (cargado antes que este archivo) resetea
   encabezados, parrafos y enlaces del navegador; se restituyen aqui
   defaults coherentes con el sistema de diseno. */
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }
h1 { font-size: 1.6rem; margin: 0 0 var(--sp-3); }
h2 { font-size: 1.2rem; margin: 0 0 var(--sp-2); }
h3 { font-size: 1.05rem; margin: 0 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Pantalla completa (dashboard del viewer) -------------- */
body.fullscreen {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}
/* Visor de Excel: contenedor en COLUMNA (pestañas arriba + panel abajo).
   Es lo que se maximiza en pantalla completa, asi la barra de pestañas queda
   dentro y se puede cambiar de vista sin salir. */
.excel-viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;       /* fallback */
  height: 100dvh;
  background: var(--bg);
}
/* Barra de pestañas (arriba, alto automatico). */
.viewer-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  padding-right: 3.25rem;            /* hueco para el boton flotante ⋮ */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: .3rem .8rem;
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab.is-active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 600; }

/* Zona de paneles: ocupa el resto del alto disponible. */
.viewer-panels { position: relative; flex: 1; min-height: 0; }

/* Panel del embed: llena la zona de paneles y RECORTA la barra inferior de
   OneDrive (otro origen, no se puede borrar por DOM). */
.embed-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: #000;
}
/* Solo el panel activo es visible -> al volver conserva scroll y filtros. */
.tab-panel[hidden] { display: none; }

/* iframe mas alto que el contenedor: empuja la barra de iconos fuera de vista. */
.viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  /* Oculta SOLO la franja de iconos de OneDrive. Afinable entre 24px y 40px. */
  height: calc(100% + 30px);
  border: 0;
  display: block;
}

/* Pantalla completa: maximiza TODO el visor (pestañas + panel activo).
   Overlay CSS (iPhone incluido) + API nativa (escritorio/Android). Fondo solido
   del tema para que el fullscreen nativo no muestre bordes negros. */
.excel-viewer.is-fullscreen {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 9999;
  background: var(--bg);
}
.fs-exit {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  z-index: 10000;
  align-items: center;
  gap: .35rem;
  background: rgba(37, 18, 51, .88);
  color: #fff;
  border: 0;
  padding: .5rem .85rem;
  border-radius: var(--r-pill);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.excel-viewer.is-fullscreen .fs-exit { display: inline-flex; }

/* Spinner de carga del embed (se oculta en el load del iframe). */
.embed-spinner { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; pointer-events: none; }
.embed-spinner::after {
  content: "";
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  animation: embed-spin .8s linear infinite;
}
@keyframes embed-spin { to { transform: rotate(360deg); } }
.embed-wrap.is-loaded .embed-spinner { display: none; }

/* Filas de "Vistas" en el formulario de empresa (admin). */
fieldset.field { border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-4); margin: 0; }
fieldset.field legend { font-weight: 600; font-size: .9rem; padding: 0 .35rem; }
.embed-rows { display: grid; gap: var(--sp-2); margin: var(--sp-2) 0; }
.embed-row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.embed-row input {
  min-height: var(--control-h);
  padding: .5rem .65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .92rem;
}
.embed-row input[name="embed_label"] { flex: 0 0 9rem; min-width: 7rem; }
.embed-row input[name="embed_url"] { flex: 1 1 14rem; min-width: 0; }
.embed-row-actions { display: flex; gap: .25rem; }
/* Checkboxes de "Acceso a vistas" en el formulario de usuario. */
.embed-checklist {
  display: grid; gap: var(--sp-2);
  margin-top: var(--sp-2); padding: var(--sp-3);
  border: 1px dashed var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-2);
  max-height: 240px; overflow: auto;
}
.embed-checklist[hidden] { display: none; }
/* Barra flotante por encima del iframe (no resta altura) */
.viewer-toolbar {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  right: env(safe-area-inset-right, 0);
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2);
}
.toolbar-toggle {
  border: 0;
  width: 42px; height: 42px;
  border-radius: var(--r-pill);
  background: rgba(37, 18, 51, .78);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.toolbar-content {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  background: rgba(37, 18, 51, .92);
  color: #fff;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  max-width: min(92vw, 560px);
}
.toolbar-content.is-hidden { display: none; }
.toolbar-title { font-weight: 600; }
.toolbar-link { color: #d8cfe3; text-decoration: none; font-size: .9rem; }
.toolbar-link:hover { color: #fff; text-decoration: underline; }
.btn-logout {
  background: #ef4444; color: #fff; border: 0;
  padding: .45rem .85rem; border-radius: var(--r-sm); cursor: pointer; font: inherit;
}
.btn-logout:hover { background: #dc2626; }

/* Pantalla de aviso (viewer sin empresa) */
.notice-screen { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-5); background: var(--bg); }
.notice-card {
  background: var(--surface); padding: var(--sp-6); border-radius: var(--r-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  max-width: 500px; width: 100%; text-align: center;
}
.notice-text { color: var(--text-muted); }
.notice-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; margin-top: var(--sp-4); }
.notice-actions .btn-primary { width: auto; }

/* ---------- Layout centrado (login, 2FA, change-password, error) -- */
body.centered {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-5);
  background:
    radial-gradient(1100px 560px at 50% -15%, var(--bg-grad-1) 0%, transparent 62%),
    var(--bg);
}
.auth-card {
  background: var(--surface); width: 100%; max-width: 420px; padding: var(--sp-6);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.auth-title { margin: 0 0 var(--sp-1); font-size: 1.55rem; text-align: center; }
/* Isotipo BLEC sobre chip blanco: nitido en modo claro y oscuro. */
.auth-title::before {
  content: ""; display: block; width: 56px; height: 56px; margin: 0 auto var(--sp-3);
  border-radius: 14px;
  background: #ffffff url("/images/blec-icon-192.png") center / 74% no-repeat;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.auth-sub { margin: 0 0 var(--sp-5); color: var(--text-muted); text-align: center; }
.auth-alt { margin-top: var(--sp-4); text-align: center; }

/* ---------- App (paginas internas con barra superior) ------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(120deg, var(--topbar-bg) 0%, #47205d 140%);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-3) var(--sp-5); flex-wrap: wrap;
  box-shadow: var(--shadow);
  border-bottom: 1px solid rgba(179, 132, 211, .28);
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; letter-spacing: .2px; display: inline-flex; align-items: center; gap: .55rem; }
/* Isotipo BLEC sobre chip blanco para que resalte en la barra oscura. */
.brand::before {
  content: ""; width: 1.7rem; height: 1.7rem; border-radius: 8px;
  background: #ffffff url("/images/blec-icon-192.png") center / 74% no-repeat;
}
.brand .brand-sub { display: block; font-size: .6rem; font-weight: 600; letter-spacing: .18em; color: #b9a6cc; text-transform: uppercase; }
.topnav { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.topnav a {
  color: #d8cfe3; text-decoration: none; font-size: .95rem;
  padding: .35rem .7rem; border-radius: var(--r-pill);
  transition: background .12s ease, color .12s ease;
}
.topnav a:hover { color: #fff; background: rgba(179, 132, 211, .18); }
.topnav .who { color: #a08fb3; font-size: .85rem; padding: 0 .35rem; }

.container { max-width: 1140px; margin: 0 auto; padding: var(--sp-6) var(--sp-4) var(--sp-7); }
.container.narrow { max-width: 600px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.page-head h1 { margin: 0; font-size: 1.6rem; }

/* ---------- Formularios -------------------------------------------- */
.form { display: grid; gap: var(--sp-4); margin-top: var(--sp-4); }
.field { display: grid; gap: var(--sp-1); }
.field > span { font-weight: 600; font-size: .9rem; }
.field input, .field select {
  width: 100%; min-height: var(--control-h); padding: .65rem .8rem;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 1rem; background: var(--surface); color: var(--text);
}
.field input::placeholder { color: #a79fb2; }
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak);
}
.checkbox { display: flex; align-items: center; gap: var(--sp-2); }
.checkbox input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.hint { color: var(--text-muted); font-size: .85rem; margin: 0; }
.form-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ---------- Botones ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: .55rem 1rem; border-radius: var(--r-sm);
  font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  transition: background .12s ease, border-color .12s ease, transform .05s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-600) 100%);
  color: var(--accent-contrast); border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(142, 81, 179, .12); box-shadow: none; }
.btn-danger { color: var(--err); border-color: var(--err-bd); background: var(--surface); }
.btn-danger:hover { background: var(--err-bg); color: var(--err-ink); }
.btn-sm { min-height: 2rem; padding: .3rem .6rem; font-size: .8rem; }
.inline { display: inline; }
form.inline { display: inline-block; }
.linklike { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; font: inherit; color: inherit; text-decoration: underline; min-height: auto; }
.toolbar-link.linklike, .topnav .linklike { color: #d8cfe3; text-decoration: none; }
.toolbar-link.linklike:hover, .topnav .linklike:hover { color: #fff; text-decoration: underline; }

/* ---------- Desplegable (boton Salir) ----------------------------- */
.menu { position: relative; display: inline-block; }
.menu-trigger {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: var(--control-h); padding: .5rem .85rem;
  background: transparent; color: inherit; cursor: pointer; font: inherit; font-weight: 600;
  border: 1px solid rgba(160, 143, 179, .45); border-radius: var(--r-sm);
}
.menu-trigger:hover { background: rgba(160, 143, 179, .18); }
.menu-trigger .caret { font-size: .8em; opacity: .8; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); padding: var(--sp-1); z-index: 60;
  display: grid; gap: 2px;
}
.menu-list[hidden] { display: none; }
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: .55rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item-danger { color: var(--err); }
.menu-item-danger:hover { background: var(--err-bg); color: var(--err-ink); }

/* ---------- Modales ----------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: var(--sp-4);
  background: rgba(2, 6, 23, .55); backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: var(--sp-6);
  width: 100%; max-width: 460px;
}
.modal-title { margin: 0 0 var(--sp-2); font-size: 1.2rem; }
.modal-text { margin: 0 0 var(--sp-5); color: var(--text-muted); }
.modal-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--sp-4); }
.modal-actions .btn { width: auto; }
body.modal-open { overflow: hidden; }

/* ---------- Flash -------------------------------------------------- */
.flash-stack { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.flash {
  padding: .8rem .95rem; border-radius: var(--r-sm); font-size: .92rem;
  border: 1px solid transparent; border-left-width: 4px; word-break: break-word;
}
.flash-success { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-bd); }
.flash-error { background: var(--err-bg); color: var(--err-ink); border-color: var(--err-bd); }
.flash-info { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-bd); }

/* ---------- Dashboard de administracion (metricas + acciones) ----- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); margin: var(--sp-5) 0; }
.stat-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: var(--sp-5); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.stat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(180deg, var(--accent), var(--accent-700)); }
.stat-number { font-size: 2.5rem; font-weight: 800; color: var(--accent); line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-weight: 600; }
.stat-sub { color: var(--text-muted); font-size: .85rem; }

.quick-actions { margin-top: var(--sp-6); }
.quick-actions h2 { font-size: 1.05rem; margin-bottom: var(--sp-1); color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-3); }
.action-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: var(--sp-5); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: var(--sp-2);
  transition: transform .1s ease, border-color .1s ease, box-shadow .1s ease;
}
.action-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.action-icon {
  width: 2.6rem; height: 2.6rem; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; border-radius: 10px; background: var(--accent-weak); color: var(--accent-600);
}
.action-title { font-weight: 700; font-size: 1.02rem; }
.action-desc { color: var(--text-muted); font-size: .85rem; }

/* ---------- Bloque de contacto con el administrador --------------- */
.contact-box { margin-top: var(--sp-5); padding: var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2); text-align: center; }
.contact-lead { margin: 0 0 var(--sp-2); font-weight: 600; color: var(--text-muted); font-size: .9rem; }
.contact-items { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }
.contact-item {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: .45rem .85rem; border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  text-decoration: none; color: var(--accent); font-weight: 600; font-size: .9rem; background: var(--surface);
}
.contact-item:hover { border-color: var(--accent); background: var(--accent-weak); }

/* ---------- Separadores y subsecciones (formularios admin) -------- */
.sep { border: none; border-top: 1px solid var(--border); margin: var(--sp-6) 0 var(--sp-4); }
.subsection { margin-bottom: var(--sp-5); }
.subsection h2 { font-size: 1.05rem; margin-bottom: var(--sp-1); }

/* ---------- Tablas ------------------------------------------------- */
.table-wrap { margin-top: var(--sp-4); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.data-table th, .data-table td { padding: .8rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { background: var(--surface-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.data-table tbody tr:hover { background: var(--surface-3); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .empty { text-align: center; color: var(--text-muted); padding: var(--sp-6); }
.actions { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.rename-form { display: flex; gap: var(--sp-1); align-items: center; }
.rename-form input { min-height: 2rem; padding: .3rem .5rem; font-size: .85rem; min-width: 0; flex: 1 1 8rem; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.url-cell { max-width: 320px; }
.ellipsis { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

.tag { display: inline-block; padding: .14rem .55rem; border-radius: var(--r-pill); font-size: .72rem; font-weight: 600; background: var(--surface-3); color: var(--text); border: 1px solid var(--border); }
.tag-admin { background: var(--accent-weak); color: var(--accent-700); border-color: transparent; }
.tag-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.tag-danger { background: var(--err-bg); color: var(--err-ink); border-color: transparent; }
.dot { display: inline-block; width: .62rem; height: .62rem; border-radius: var(--r-pill); margin-right: var(--sp-1); vertical-align: middle; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot-off { background: #a79fb2; }

/* ---------- Auditoria ---------------------------------------------- */
.audit-filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin: var(--sp-4) 0; }
.audit-filters select, .audit-filters input { min-height: var(--control-h); padding: .5rem .7rem; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.audit-filters input { flex: 1 1 220px; }
.data-table tbody tr.row-warn { background: var(--warn-bg); }
.data-table tbody tr.row-warn:hover { background: var(--warn-bg); }
.pager { display: flex; gap: var(--sp-3); align-items: center; justify-content: center; margin-top: var(--sp-4); }

/* ---------- 2FA / claves ------------------------------------------- */
.qr-box { display: grid; place-items: center; padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin: var(--sp-4) 0; }
.qr-box img { width: 240px; height: 240px; image-rendering: pixelated; border-radius: var(--r-sm); }
.manual-key { margin-bottom: var(--sp-4); }
.manual-key summary { cursor: pointer; color: var(--text-muted); font-size: .9rem; }
.secret { display: inline-block; margin-top: var(--sp-2); padding: .4rem .6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); font-family: var(--mono); word-break: break-all; }
.ok-badge { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-bd); padding: .75rem .9rem; border-radius: var(--r-sm); }

/* ---------- Responsive: tablas -> tarjetas en moviles ------------- */
@media (max-width: 720px) {
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table { border: none; box-shadow: none; background: transparent; }
  .data-table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); margin-bottom: var(--sp-3); overflow: hidden; }
  .data-table tbody tr:hover { background: var(--surface); }
  .data-table td { border: none; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: var(--sp-4); align-items: center; }
  .data-table tr td:last-child { border-bottom: none; }
  .data-table td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); }
  .data-table td.actions { flex-wrap: wrap; justify-content: flex-start; }
  .data-table td.actions::before { width: 100%; }
  .rename-form { width: 100%; }
  .ellipsis, .url-cell { max-width: 60vw; }
}
