/* ==========================================================================
   Deliveries Control System — tema visual base
   Punto de partida para CUALQUIER hoja de estilos nueva de este proyecto.
   Copia lo que necesites; no inventes tokens nuevos (colores, radios,
   sombras) — si falta un componente, constrúyelo con estas mismas variables.
   ========================================================================== */

:root {
  color-scheme: light only;
  --bg:         #f5f6f8;
  --surface:    #ffffff;
  --border:     #e2e5eb;
  --border2:    #d0d5df;
  --accent:     #0073ea;
  --accent-lt:  #e8f1ff;
  --success:    #00c875;
  --success-lt: #e6faf2;
  --warning:    #ffcb00;
  --warning-lt: #fff9e0;
  --warning-text: #c49000; /* texto sobre fondos claros -- --warning es muy claro para texto */
  --danger:     #e2445c;
  --danger-lt:  #fdedf0;
  --purple:     #a358df;
  --purple-lt:  #f4ecfd;
  --alert:      #e07000; /* naranja de alerta, distinto de warning (ej. "sobre-límite") */
  --text:       #1f2633;
  --text2:      #676879;
  --text3:      #adb2c0;
  --radius:     10px;
  --radius-lg:  16px; /* cards grandes / modales / login */
  --shadow:     0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);

  /* Partner (SpeedIt) -- uso restringido, ver SKILL.md "Color de partner".
     Nunca reemplaza --accent como color primario de la plataforma. */
  --partner-blue:  #1a4d8f;
  --partner-green: #8dc63f;

  /* Animación -- ver SKILL.md "Animaciones". */
  --ease-out:      cubic-bezier(.16, 1, .3, 1);
  --duration-fast: 150ms;
  --duration-base: 300ms;
  --duration-slow: 600ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* Cualquier valor NUMERICO/DE DATOS (montos, conteos, IDs, códigos) va en
   JetBrains Mono, nunca en Inter. Aplica esta clase a esos elementos. */
.mono { font-family: 'JetBrains Mono', monospace; }

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none; /* .btn se usa tanto en <button> como en <a> */
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; padding: 12px 20px; }
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-success { background: var(--success); color: #fff; padding: 12px 20px; }
.btn-success:hover { opacity: .9; }
.btn-success:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-danger { background: var(--danger); color: #fff; padding: 12px 20px; }
.btn-danger:hover { opacity: .9; }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--text2);
  padding: 7px 14px;
  font-size: 13px;
}
.btn-ghost:hover { border-color: var(--text2); color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: 13px; }

/* Botón de texto plano para acciones secundarias (ej. logout, volver al menú) */
.btn-text-action {
  display: inline-block;
  text-decoration: none; /* también se usa en <a> */
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  background: transparent;
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  font-family: 'Inter', sans-serif;
}
.btn-text-action:hover { color: var(--danger); border-color: var(--danger); }

/* Botón cuadrado solo-icono */
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border2);
  background: transparent;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text2);
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   FORMULARIOS
   ========================================================================== */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,115,234,.12);
}
/* Inputs de valores numéricos (cantidades, montos) -- usar mono + centrado */
input.mono { font-family: 'JetBrains Mono', monospace; text-align: center; font-weight: 600; }

/* ==========================================================================
   CHIPS / PILLS -- para estados, conteos, badges
   ========================================================================== */
.chip, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.chip-blue,   .pill-blue   { background: var(--accent-lt);  color: var(--accent); }
.chip-green,  .pill-green  { background: var(--success-lt); color: #007a48; }
.chip-yellow, .pill-yellow { background: var(--warning-lt); color: var(--warning-text); }
.chip-red,    .pill-red    { background: var(--danger-lt);  color: var(--danger); }
.chip-purple, .pill-purple { background: var(--purple-lt);  color: var(--purple); }
.pill-muted   { background: var(--bg); color: var(--text3); border: 1px solid var(--border); }

/* pastilla de conteo simple (ej. "42 resultados") */
.count-chip {
  background: var(--border);
  color: var(--text2);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================================================
   HEADER DE APP (sticky)
   ========================================================================== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-title { font-weight: 700; font-size: 15px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }

/* Aviso informativo (banner azul dentro del contenido) */
.notice {
  background: var(--accent-lt);
  border: 1px solid rgba(0,115,234,.2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #1a4a8a;
  line-height: 1.6;
}
.notice strong { font-weight: 600; }

/* ==========================================================================
   CARDS Y STATS GRID
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 600px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .stats-grid { grid-template-columns: repeat(6, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer; /* los stat-card suelen doblar como filtros clickeables */
  transition: box-shadow var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.10); transform: translateY(-2px); }
.stat-card.active-filter        { border-color: var(--accent);  box-shadow: 0 0 0 3px rgba(0,115,234,.12); }
.stat-card.active-filter-green  { border-color: var(--success);  box-shadow: 0 0 0 3px rgba(0,200,117,.12); }
.stat-card.active-filter-yellow { border-color: var(--warning-text); box-shadow: 0 0 0 3px rgba(196,144,0,.12); }
.stat-card.active-filter-red    { border-color: var(--danger);   box-shadow: 0 0 0 3px rgba(226,68,92,.12); }
.stat-card.active-filter-purple { border-color: var(--purple);   box-shadow: 0 0 0 3px rgba(163,88,223,.12); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text2);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}
.stat-value.blue   { color: var(--accent);  }
.stat-value.green  { color: var(--success); }
.stat-value.yellow { color: var(--warning-text); }
.stat-value.red    { color: var(--danger);  }
.stat-value.purple { color: var(--purple);  }

/* ==========================================================================
   BUSQUEDA
   ========================================================================== */
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none;
}
.search-input { padding-left: 38px; background: var(--surface); border: 1.5px solid var(--border2); }

/* Grupo de pills como filtro (ej. filtrar por categoría/persona) */
.pill-filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-filter {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  font-family: 'JetBrains Mono', monospace;
}
.pill-filter:hover { border-color: var(--accent); color: var(--accent); }
.pill-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ==========================================================================
   TABLA RESPONSIVE -- mobile: lista de cards / desktop (>=768px): tabla sticky
   ========================================================================== */
.mobile-list { display: flex; flex-direction: column; gap: 10px; }
.desktop-table-wrap { display: none; }

@media (min-width: 768px) {
  .mobile-list { display: none; }
  .desktop-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: auto;
    max-height: 70vh;
    display: block;
  }
}

table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f8f9fb;
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
tbody td { padding: 11px 14px; vertical-align: middle; font-size: 13px; }

.td-name  { font-weight: 600; }
.td-mono  { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.td-green { color: var(--success); font-weight: 600; }
.td-blue  { color: var(--accent);  font-weight: 600; }
.td-yellow{ color: var(--warning-text); font-weight: 600; }
.td-red   { color: var(--danger);  font-weight: 600; }
.td-purple{ color: var(--purple);  font-weight: 600; }

/* Card genérica para el modo mobile (ej. una fila de tabla convertida en card) */
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .15s;
}
.list-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.10); }

/* ==========================================================================
   ESTADOS: loading / vacío / última actualización
   ========================================================================== */
.loader-wrap {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 48px; color: var(--text2); font-size: 14px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); font-size: 14px; }
.last-update { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.modal-box-wide { max-width: 880px; }

.modal-header {
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 15px; color: var(--text); }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text2); line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 60vh; overflow-y: auto;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: #f8f9fb;
}
.btn-modal-cancel {
  background: transparent;
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  color: var(--text2);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-modal-cancel:hover { border-color: var(--danger); color: var(--danger); }
.btn-modal-confirm {
  background: var(--success);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 24px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-modal-confirm:hover { opacity: .9; }
.btn-modal-confirm:disabled { opacity: .5; cursor: not-allowed; }

/* ==========================================================================
   PANTALLA DE LOGIN / GATEWAY -- usar solo si esta app necesita su propio login
   ========================================================================== */
.gateway-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f0f4ff 0%, #f5f6f8 60%);
}
.gateway-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.10);
  text-align: center;
}
.gateway-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; text-align: left; }
.gateway-card p  { color: var(--text2); font-size: 13px; margin-bottom: 24px; line-height: 1.6; text-align: left; }

/* Lockup de dos logos lado a lado (empresa propia + partner/marca), si aplica */
.gateway-logos {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.gateway-logo-box { flex-shrink: 0; display: flex; align-items: center; }

.gateway-error {
  margin-top: 12px;
  background: var(--danger-lt);
  border: 1px solid rgba(226,68,92,.25);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  display: none;
}

/* ==========================================================================
   ANIMACIONES -- microinteracciones sutiles (ver SKILL.md "Animaciones").
   Tres patrones: entrada en cascada, barras que se llenan, números que
   cuentan hacia arriba (este último vía assets/animate.js -- CSS no puede
   interpolar contenido de texto). Todo se apaga limpio con reduced-motion.
   ========================================================================== */
.anim-enter {
  animation: anim-fade-up var(--duration-base) var(--ease-out) both;
  animation-delay: calc(var(--stagger-index, 0) * 45ms);
}
@keyframes anim-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Barras que se llenan -- el ancho lo anima directo assets/animate.js (JS,
   no transición CSS de flex-grow: poco confiable con varios segmentos
   hermanos animando a la vez desde 0, ver docblock de animate.js). */
.anim-bar-fill { flex: 0 0 auto; }

[data-count-to] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .anim-enter { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ==========================================================================
   DIVERSA INTRANET (nucleo) - piezas propias. Solo usan los tokens de arriba.
   ========================================================================== */
body { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; z-index: 2000; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
code, .mono-data { font-family: 'JetBrains Mono', monospace; background: var(--bg); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; word-break: break-all; font-size: .92em; }
.muted { color: var(--text2); font-size: 13px; }
.lead { color: var(--text2); }
[hidden] { display: none !important; }
svg.ico { flex: none; }

/* ---------- header ---------- */
.app-header { height: auto; min-height: 56px; flex-wrap: wrap; gap: 6px 16px; padding: 8px 20px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-logo { height: 36px; width: auto; display: block; }
.header-titles { display: flex; flex-direction: column; line-height: 1.2; padding-left: 12px; border-left: 1px solid var(--border); }
.header-app-name { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); }
.nav { display: flex; align-items: center; gap: 2px 4px; flex-wrap: wrap; }
.nav a { color: var(--text2); text-decoration: none; font-weight: 600; font-size: 13px; padding: 6px 12px; border-radius: 8px; transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); }
.nav a:hover { background: var(--accent-lt); color: var(--accent); }
.nav a[aria-current="page"] { background: var(--accent-lt); color: var(--accent); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager-page { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text3); }
.nav-sep { width: 1px; height: 18px; background: var(--border2); margin: 0 6px; }
.nav form { margin: 0; display: inline-flex; flex-direction: row; }
.nav .signout { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; }
.nav .email { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text3); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) { .app-header { padding: 8px 12px; } .nav { width: 100%; } .nav .email { max-width: 16ch; } .nav-sep { display: none; } }

main.page { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
main.page > h1 { font-size: 22px; font-weight: 700; }
@media (min-width: 768px) { main.page { padding: 24px 20px; } }

/* ---------- messages ---------- */
main > p[role=status], main > p[role=alert], .gateway-card > p[role=status], .gateway-card > p[role=alert] { padding: 11px 16px; border-radius: var(--radius); font-weight: 600; font-size: 13px; margin: 0; text-align: left; color: inherit; }
main > p[role=status], .gateway-card > p[role=status] { background: var(--success-lt); color: #007a48; border: 1px solid rgba(0,200,117,.3); }
main > p[role=alert], .gateway-card > p[role=alert] { background: var(--danger-lt); color: var(--danger); border: 1px solid rgba(226,68,92,.25); }
.notice { margin-bottom: 0; }

/* ---------- gateway (login y pasos de acceso) ---------- */
.gateway-card { max-width: 460px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; text-align: left; margin: 0; }
.gateway-card h1 { font-size: 22px; margin: 0; }
.gateway-card p { margin-bottom: 0; }
.gateway-card .card { border: 0; box-shadow: none; padding: 0; max-width: none; margin: 0; background: transparent; }
.gateway-logos { justify-content: flex-start; margin: 0; }
.gateway-logos img { height: 44px; width: auto; display: block; }
@media (max-width: 480px) { .gateway-screen { padding: 12px; } .gateway-card { padding: 24px 18px; } }

/* ---------- cards, forms ---------- */
.card { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card > h2 { font-size: 16px; font-weight: 700; }
.narrow { width: 100%; max-width: 440px; margin: 0 auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
h2 { font-size: 16px; font-weight: 700; }
form { margin: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.field { display: flex; flex-direction: column; min-width: 0; }
.hint { font-size: 12px; color: var(--text3); margin-top: 5px; text-transform: none; letter-spacing: 0; font-weight: 400; }
input[type="email"], input[type="search"] { width: 100%; border: 1.5px solid var(--border2); border-radius: var(--radius); padding: 11px 14px; font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
input[type="email"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,115,234,.12); }
input.mono-input, #code, input[name=expires_at], input[name=sort_order], input[name=user] { font-family: 'JetBrains Mono', monospace; }
textarea { resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 14px; color: var(--text); text-transform: none; letter-spacing: 0; margin: 0; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 599px) { .grid2 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
legend { font-weight: 700; font-size: 14px; padding: 0 8px; }
.btn.block { width: 100%; padding: 12px 20px; }
.btn-link { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: underline; cursor: pointer; text-align: left; }
.btn-link:hover { color: var(--text); }
[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; }
@media (max-width: 599px) { .btn, .btn-text-action { min-height: 42px; } }
.btn svg, .btn-text-action svg { flex: none; }
.tags, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13px; }
dl.kv dt { color: var(--text2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
dl.kv dd { min-width: 0; }
dl.kv dd.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
@media (max-width: 480px) { dl.kv { grid-template-columns: 1fr; gap: 0; } dl.kv dd { margin-bottom: 10px; } }

/* ---------- secreto de una sola vez ---------- */
.secret-once { border: 2px solid var(--warning-text); background: var(--warning-lt); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.secret-once .secret-title { font-weight: 700; color: var(--warning-text); }
.secret-once code { background: var(--surface); font-size: 1.05em; padding: 4px 9px; user-select: all; }

/* ---------- alta de 2FA ---------- */
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 20px; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 6px 12px; }
.steps > li::before { content: counter(step); grid-row: 1 / span 4; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-lt); color: var(--accent); font-weight: 700; font-family: 'JetBrains Mono', monospace; display: grid; place-items: center; font-size: 13px; }
.steps > li > * { grid-column: 2; min-width: 0; }
.qr-box { width: min(100%, 240px); aspect-ratio: 1; background: #fff; border: 1px solid var(--border2); border-radius: var(--radius); padding: 6px; display: flex; align-items: center; justify-content: center; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-box .qr-fallback { color: var(--text2); font-size: 12px; text-align: center; padding: 8px; }
.keyline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.keyline code { font-size: 1em; letter-spacing: .04em; }
details > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text2); }
details .uri { margin-top: 8px; font-size: 12px; }

/* ---------- codigos de recuperacion ---------- */
.codes { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.codes code { display: block; text-align: center; padding: 10px 6px; font-size: 14px; font-weight: 500; letter-spacing: .04em; }

/* ---------- portal ---------- */
.modules { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.module-card { display: flex; padding: 0; border-top-width: 4px; border-radius: var(--radius-lg); overflow: hidden;
  background: linear-gradient(180deg, var(--cat-card) 0%, var(--surface) 78%);
  box-shadow: 0 1px 3px rgba(20,30,60,.06), 0 6px 18px rgba(20,30,60,.05); }
.module-card form { width: 100%; display: flex; }
/* The whole card is one button: Diversa chevron tile + name + the full description. */
.module-link { all: unset; box-sizing: border-box; width: 100%; padding: 20px 22px 22px; display: flex; align-items: flex-start; gap: 16px; cursor: pointer; border-radius: inherit; font-family: 'Inter', sans-serif; color: var(--text); }
.module-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.module-link .cat-tile { width: 48px; height: 48px; border-radius: 14px; transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out); }
.module-link .cat-tile svg { width: 22px; height: 22px; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.module-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding-top: 2px; }
.module-name { font-size: 17px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; }
.module-desc { color: var(--text2); font-size: 13.5px; line-height: 1.5; }
/* Connected modules: the tile fills with the family colour on hover. */
.module-card:not(.is-off):hover .cat-tile { background: var(--cat-mid); color: #fff; transform: translateX(2px); }
/* Modules whose secret has not been generated yet: greyed out, not clickable, and they say why. */
.module-card.is-off { --cat-bg: #E9ECF0; --cat-card: #F4F5F7; --cat-ink: #99A0AE; --cat-mid: #CDD2DA; --cat-av: #DCDFE5; box-shadow: none; border-color: var(--border); }
.module-card.is-off .module-link { cursor: default; }
.module-card.is-off .module-name { color: var(--text2); }
.module-card.is-off .module-desc { color: var(--text3); }
.module-card.is-off:hover { transform: none; box-shadow: none; }
.module-status { align-self: flex-start; margin-top: 4px; padding: 2px 10px; border-radius: 999px; background: #E9ECF0; color: #7C8493; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
/* Phones: small tiles, centred, chevron + name only. */
@media (max-width: 600px) {
  .modules { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .module-card { width: calc((100% - 16px) / 3); max-width: 112px; }
  .module-card { border-top-width: 3px; border-radius: var(--radius); }
  .module-link { flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding: 10px 6px; text-align: center; }
  .module-link .cat-tile { width: 34px; height: 34px; border-radius: var(--radius); }
  .module-link .cat-tile svg { width: 18px; height: 18px; }
  .module-text { align-items: center; gap: 1px; padding-top: 0; }
  .module-name { font-size: 12px; font-weight: 600; letter-spacing: 0; }
  .module-desc, .module-status { display: none; }
}
.module-card:not(.is-off):hover { box-shadow: 0 10px 28px rgba(20,30,60,.12); transform: translateY(-3px); }
.cat-tile { font-weight: 700; font-size: 16px; }
.module-card h2 { font-size: 16px; }
.module-card p { color: var(--text2); font-size: 13px; flex: 1; }
.module-card:nth-child(1) { --stagger-index: 0; } .module-card:nth-child(2) { --stagger-index: 1; } .module-card:nth-child(3) { --stagger-index: 2; } .module-card:nth-child(4) { --stagger-index: 3; } .module-card:nth-child(5) { --stagger-index: 4; } .module-card:nth-child(6) { --stagger-index: 5; } .module-card:nth-child(7) { --stagger-index: 6; } .module-card:nth-child(n+8) { --stagger-index: 7; }
.empty { align-items: center; text-align: center; padding: 40px 24px; color: var(--text2); }
.continue { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; border-color: var(--accent); }
.continue form { flex-direction: row; flex-wrap: wrap; }

/* ---------- entrega al modulo ---------- */
.handoff { align-items: center; text-align: center; }
.handoff .spinner { width: 30px; height: 30px; border-width: 3px; }
#handoff-form { align-items: center; }
#handoff-form button { display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: var(--radius); font-family: 'Inter', sans-serif; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--accent); color: #fff; padding: 12px 20px; }
#handoff-form button:hover { opacity: .9; }

/* ---------- cuenta ---------- */
.devices { list-style: none; display: flex; flex-direction: column; }
.devices li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.devices li:first-child { border-top: 0; padding-top: 0; }
.device-info { min-width: 0; flex: 1 1 240px; }
.device-info strong { display: block; font-weight: 600; }
.device-info span { display: block; color: var(--text2); font-size: 12px; font-family: 'JetBrains Mono', monospace; }

/* ---------- administracion ---------- */
form.toolbar { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.toolbar .field { flex: 1 1 140px; max-width: 260px; }
.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
tbody td { overflow-wrap: anywhere; }
td:empty::after, td code.detail:empty::after { content: "\2014"; color: var(--text3); }
td code.detail { font-size: 11.5px; display: block; }
.td-mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
@media (max-width: 767px) {
  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .stack, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack tr { padding: 10px 4px; border-bottom: 1px solid var(--border); }
  .stack tbody tr:last-child { border-bottom: 0; }
  .stack td { border: 0; padding: 4px 12px; display: grid; grid-template-columns: 104px 1fr; gap: 10px; }
  .stack td::before { content: attr(data-label); color: var(--text2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
  .stack td > .chip { justify-self: start; }
}
.grant { gap: 12px; }
.grant form.remove { align-items: flex-start; }

/* ---------- impresion (codigos de recuperacion) ---------- */
@media print {
  body, html { background: #fff; color: #000; }
  .app-header, .skip, .no-print, main > p[role], .gateway-card > p[role], .actions, .gateway-logos { display: none !important; }
  .gateway-screen { background: none; padding: 0; min-height: 0; }
  .gateway-card, .card { border: 0; box-shadow: none; padding: 0; }
  .codes code { background: none; border: 1px solid #000; color: #000; }
}

/* ============================================================
   categories.css — familias de color de categoría (aditivo)
   Origen: paleta de Leave Tracker (diseño de Allan), traducida al
   lenguaje sobrio de este skill. Agregado 2026-11-12.

   REGLA: este archivo NO cambia ningún token existente de base-theme.css
   (--accent, --success, --warning, --danger, --purple siguen igual).
   Solo añade familias de color para distinguir CATEGORÍAS (módulo,
   grupo, tipo, rol) con un tinte suave: la tarjeta sigue siendo blanca
   y sobria; el color vive en un mosaico/chip/acento pequeño.

   Cada familia define 5 tonos:
     --cat-bg    fondo suave (mosaico, chip)
     --cat-card  fondo casi blanco (tarjeta con tinte opcional)
     --cat-ink   texto fuerte sobre --cat-bg (legible)
     --cat-mid   color de acento (borde superior, ícono, barra)
     --cat-av    avatar / relleno medio
   Uso:  <div class="card cat-card cat-blue"> ... </div>
   ============================================================ */

.cat-blue   { --cat-bg:#DCEAFA; --cat-card:#F2F7FD; --cat-ink:#0C447C; --cat-mid:#185FA5; --cat-av:#B5D4F4; }
.cat-indigo { --cat-bg:#E4E2FC; --cat-card:#F7F6FE; --cat-ink:#3C3489; --cat-mid:#534AB7; --cat-av:#CECBF6; }
.cat-rose   { --cat-bg:#F8DFE8; --cat-card:#FDF5F8; --cat-ink:#72243E; --cat-mid:#993556; --cat-av:#F4C0D1; }
.cat-stone  { --cat-bg:#EAE7DE; --cat-card:#F9F8F4; --cat-ink:#444441; --cat-mid:#5F5E5A; --cat-av:#D3D1C7; }
.cat-teal   { --cat-bg:#D6F2EE; --cat-card:#F0FAF8; --cat-ink:#0A6B60; --cat-mid:#0E9384; --cat-av:#A9E3DA; }
.cat-coral  { --cat-bg:#FCE2E0; --cat-card:#FEF5F4; --cat-ink:#9B2F29; --cat-mid:#E5534B; --cat-av:#F7C0BC; }
.cat-sun    { --cat-bg:#FDF0CC; --cat-card:#FEF9E8; --cat-ink:#7A5300; --cat-mid:#B07800; --cat-av:#F6DC92; }
.cat-lime   { --cat-bg:#E3F1CC; --cat-card:#F5FAEC; --cat-ink:#3A6112; --cat-mid:#5F9B1F; --cat-av:#C7E3A0; }
.cat-plum   { --cat-bg:#EBE2FA; --cat-card:#F8F4FD; --cat-ink:#4F2E91; --cat-mid:#7C4FD0; --cat-av:#D5C3F2; }

/* Mosaico de ícono/inicial: cuadro redondeado con el tinte de la familia */
.cat-tile {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--cat-bg); color: var(--cat-ink);
}
.cat-tile svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; }

/* Chip de categoría (no sustituye a .chip-* de estado; es para clasificar) */
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--cat-bg); color: var(--cat-ink);
}

/* Tarjeta con acento de categoría: sobria, borde superior de color */
.cat-card {
  background: var(--surface);
  border-top: 3px solid var(--cat-mid);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
a.cat-card:hover, .cat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cat-card .cat-sub { color: var(--text2); font-size: 13px; }
/* Variante con tinte muy suave de fondo (usar con moderación, 1 por pantalla como máximo) */
.cat-card.tinted { background: var(--cat-card); }

.cat-chip { border-radius: var(--radius); }
.module-card.anim-enter { animation-fill-mode: backwards; }
@media (max-width: 767px) { .stack td > .cat-chip { justify-self: start; } .stack td.td-mono::before { font-family: 'Inter', sans-serif; } }

/* ==========================================================================
   Cuentas de campo (F5): insignia de solicitudes, codigo de dispositivo, avisos.
   Solo tokens de arriba; nada nuevo en colores, radios ni sombras.
   ========================================================================== */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.pending-code-wrap { text-align: center; margin: 4px 0; }
.pending-code { display: inline-block; font-size: 32px; font-weight: 500; letter-spacing: .25em; padding: 12px 18px 12px 28px; background: var(--surface); border: 2px solid var(--accent); color: var(--accent); }
.field-notice p:first-child, .field-pending .lead { font-weight: 600; color: var(--text); }
.hint-inline { font-weight: 400; color: var(--text3); text-transform: none; letter-spacing: 0; font-size: 12px; }
.field-access h2 { margin-top: 6px; }
.grant h3 { font-size: 14px; font-weight: 700; }
td code { white-space: nowrap; word-break: normal; }
