/* ==========================================================================
   Pupi — hoja de estilos única
   Tokens tomados tal cual del Dashboard Domótico (home.martinmarufo.com.ar)
   para que las dos aplicaciones se vean hermanas. Sin dependencias.
   ========================================================================== */

:root {
  --bg: #060a10;
  --bg-elevated: #0b1220;
  --sidebar-bg: #0b1220;
  --surface: #0e1728;
  --surface-2: #131f36;
  --border: #1b2a40;
  --text: #e7ecf7;
  --muted: #8493ac;
  --muted-2: #6f7d98;
  --accent: #5a6eff;
  --accent-soft: rgba(90, 110, 255, 0.14);
  --amber: #f2b93d;
  --amber-soft: rgba(242, 185, 61, 0.14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --gray: #566078;
  --blue2: #8fb4ff;
  --violet: #8f6bff;
  --lilac: #c9a6ff;
  --cyan: #58e0ff;
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  font-size: 16px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 620px at 10% -10%, rgba(90, 110, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 800px 700px at 105% 4%, rgba(201, 166, 255, 0.13), transparent 55%),
    radial-gradient(ellipse 1000px 850px at 50% 115%, rgba(88, 224, 255, 0.09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue2); text-decoration: none; }
a:hover { color: var(--cyan); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

p { line-height: 1.55; }

::selection { background: rgba(90, 110, 255, 0.35); color: #fff; }

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

/* --- Botones -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover { background: #182642; border-color: #274063; color: var(--text); }

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--violet));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 26px rgba(90, 110, 255, 0.28);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(90, 110, 255, 0.42);
  color: #fff;
}

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.38);
  color: #ffb4b4;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); border-color: rgba(239, 68, 68, 0.6); color: #fff; }

.btn-sm { padding: 7px 11px; font-size: 0.8rem; border-radius: 8px; }

.btn[disabled], .btn[aria-disabled='true'] {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-block { width: 100%; }

/* --- Formularios ---------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

.field > label,
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.input,
input[type='text'],
input[type='email'],
input[type='password'],
input[type='tel'],
input[type='search'],
input[type='number'],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

.input:hover, input:hover, select:hover, textarea:hover { border-color: #26405f; }

.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #16233b;
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

input[readonly] { color: var(--muted); cursor: default; background: #101a2c; }

select option { background: var(--surface-2); color: var(--text); }

.hint { font-size: 0.78rem; color: var(--muted-2); line-height: 1.45; }

.error-text { font-size: 0.78rem; color: #ff9b9b; }

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* Campo de contraseña con botón de ver */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 62px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface); }

/* --- Avisos --------------------------------------------------------------- */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.86rem;
  line-height: 1.5;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.alert-ok { background: var(--green-soft); color: #a7f3c4; border-color: rgba(34, 197, 94, 0.3); }
.alert-error { background: var(--red-soft); color: #ffb4b4; border-color: rgba(239, 68, 68, 0.32); }
.alert-info { background: var(--accent-soft); color: #c3ccff; border-color: rgba(90, 110, 255, 0.32); }
.alert-warn { background: var(--amber-soft); color: #ffd98a; border-color: rgba(242, 185, 61, 0.3); }

.form-error {
  background: var(--red-soft);
  color: #ffb4b4;
  border: 1px solid rgba(239, 68, 68, 0.32);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  line-height: 1.45;
}

/* --- Badges --------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-ok { background: var(--green-soft); color: #86efac; border-color: rgba(34, 197, 94, 0.28); }
.badge-off { background: rgba(86, 96, 120, 0.24); color: var(--muted); border-color: rgba(86, 96, 120, 0.4); }
.badge-super { background: rgba(201, 166, 255, 0.16); color: var(--lilac); border-color: rgba(201, 166, 255, 0.3); }
.badge-familiar { background: var(--accent-soft); color: var(--blue2); border-color: rgba(90, 110, 255, 0.3); }
.badge-lectura { background: rgba(88, 224, 255, 0.12); color: var(--cyan); border-color: rgba(88, 224, 255, 0.28); }
.badge-warn { background: var(--amber-soft); color: var(--amber); border-color: rgba(242, 185, 61, 0.3); }

/* --- Login ---------------------------------------------------------------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border: 1px solid rgba(90, 110, 255, 0.24);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 16px;
}

.login-logo img, .login-logo svg { width: 74px; height: 74px; }

.login-heading { text-align: center; margin-bottom: 4px; font-size: 1.32rem; }

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.45;
}

.login-form { display: flex; flex-direction: column; }

.login-form .field { margin-bottom: 12px; }

.login-form button[type='submit'] {
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 13px;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.login-form button[type='submit']:hover {
  background: #4c5fe8;
  box-shadow: 0 10px 26px rgba(90, 110, 255, 0.32);
  transform: translateY(-1px);
}

.login-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}

.login-foot a { color: var(--blue2); font-weight: 600; }

.login-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* --- Shell ---------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.nav-toggle-input { display: none; }

.nav-scrim { display: none; }

.sidebar {
  width: 246px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 18px 14px 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #1e2e46 transparent;
  z-index: 30;
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #1e2e46; border-radius: 4px; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
  color: var(--text);
}

.brand:hover { color: var(--text); }

.brand-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.brand-icon svg { width: 30px; height: 30px; }

.brand-name {
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--blue2), var(--lilac) 45%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-top: 1px;
}

.nav { display: flex; flex-direction: column; }

.nav-group-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  margin: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.13s ease, color 0.13s ease;
}

.nav-item-main { display: flex; align-items: center; gap: 11px; min-width: 0; }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.72; }

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active {
  background: linear-gradient(90deg, rgba(90, 110, 255, 0.18), rgba(143, 107, 255, 0.1));
  color: var(--cyan);
  box-shadow: inset 2px 0 0 var(--cyan);
  font-weight: 600;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-foot {
  margin-top: 24px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.5;
}

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}

.hamburger {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.hamburger:hover { color: var(--text); border-color: #274063; }

.crumbs { color: var(--muted); font-size: 0.85rem; flex: 1; min-width: 0; }
.crumbs strong { color: var(--text); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.status-chip { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; color: var(--muted); }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 5px rgba(34, 197, 94, 0.7);
}
.status-dot.off { background: var(--gray); box-shadow: none; }

.topbar-user {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  color: var(--blue2);
  flex-shrink: 0;
}

.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 0.82rem; color: var(--muted); }
.user-name strong { color: var(--text); font-weight: 600; }

.content { padding: 22px 26px 64px; max-width: 1240px; width: 100%; }

.page-head { margin-bottom: 22px; }
.page-title { font-size: 1.5rem; margin: 0 0 4px; }
.page-subtitle { color: var(--muted); font-size: 0.92rem; margin: 0; line-height: 1.5; }

.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* --- Tarjetas ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 10px 24px -14px rgba(0, 0, 0, 0.55);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-title { font-size: 0.98rem; font-weight: 700; }
.card-sub { font-size: 0.78rem; color: var(--muted-2); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 17px 18px 15px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 10px 24px -14px rgba(0, 0, 0, 0.55);
}

.stat-label {
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.stat-value { font-size: 1.85rem; font-weight: 700; display: flex; align-items: baseline; gap: 8px; line-height: 1.1; }
.stat-value small { font-size: 0.78rem; font-weight: 500; color: var(--muted); }
.stat-detail { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: stretch; }
.grid-2 > .card { margin-bottom: 0; display: flex; flex-direction: column; }
.grid-2 > .card > .card-body { flex: 1; display: flex; flex-direction: column; }
.grid-2 > .card > .card-body > .empty { flex: 1; }

/* --- Estados vacíos ------------------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 34px 20px;
  gap: 10px;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  margin-bottom: 2px;
}

.empty-title { font-size: 0.92rem; font-weight: 600; color: var(--text); }
.empty-text { font-size: 0.82rem; color: var(--muted); max-width: 42ch; line-height: 1.55; }

/* --- Tablas --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }

.table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(19, 31, 54, 0.5);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(27, 42, 64, 0.7);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(19, 31, 54, 0.55); }

.table .num { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }
.table .strong { font-weight: 600; color: var(--text); }
.table .sub { display: block; font-size: 0.76rem; color: var(--muted-2); margin-top: 2px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 6px; }

.row-target { cursor: pointer; }

/* --- Filtros y paginación ------------------------------------------------- */

.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.5);
}

.filters .field { margin-bottom: 0; }
.filters .field label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.filters input, .filters select { padding: 9px 12px; font-size: 0.85rem; }
.filters .grow { flex: 1; min-width: 190px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.pagination-controls { display: flex; gap: 6px; }

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 12px;
}

/* --- Listas de detalle ---------------------------------------------------- */

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 18px; font-size: 0.87rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); }

.help-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.85rem; line-height: 1.7; }
.help-list li { margin-bottom: 2px; }

.code-box {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: var(--cyan);
  background: var(--surface-2);
  border: 1px dashed rgba(88, 224, 255, 0.4);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  text-align: center;
  user-select: all;
}

.mono { font-family: var(--font-mono); font-size: 0.82rem; }
.muted { color: var(--muted); }
.tiny { font-size: 0.76rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.divider { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

.inline-form { display: inline; }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    width: 268px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }

  #nav-toggle:checked ~ .app-shell .sidebar { transform: none; }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 11, 0.68);
    backdrop-filter: blur(2px);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  #nav-toggle:checked ~ .nav-scrim { opacity: 1; pointer-events: auto; }

  .content { padding: 18px 16px 56px; }
  .topbar { padding: 11px 14px; gap: 10px; }
  .user-name { display: none; }
}

@media (max-width: 620px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.5rem; }
  .form-grid { grid-template-columns: 1fr; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .filters { padding: 12px 16px; }
  .page-title { font-size: 1.28rem; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 10px; }
  .code-box { font-size: 1.1rem; letter-spacing: 0.16em; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Pestañas ------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab {
  padding: 9px 14px;
  border-radius: 9px 9px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.13s ease, background 0.13s ease;
}

.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }

/* --- Tablas en pantallas chicas ------------------------------------------ */

@media (max-width: 620px) {
  .table-wrap.scrolled { overflow: visible; }

  .table.adaptable thead { display: none; }

  .table.adaptable tbody tr {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .table.adaptable tbody tr:hover { background: transparent; }
  .table.adaptable tbody tr:last-child { border-bottom: none; }

  .table.adaptable td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 0;
    border: 0;
    text-align: left;
  }

  .table.adaptable td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--muted-2);
    white-space: nowrap;
  }

  .table.adaptable td.principal {
    order: -1;
    display: block;
    padding-bottom: 8px;
    font-size: 0.95rem;
  }

  .table.adaptable td.principal::before { display: none; }

  .table.adaptable td.actions {
    justify-content: flex-end;
    padding-top: 10px;
  }

  .table.adaptable td.actions::before { display: none; }

  .table.adaptable .actions .btn { margin-left: 0; }
}

/* --- Niveles de alerta ---------------------------------------------------- */
/* El color no es decoración: es la única pista rápida de gravedad en la lista. */

.nivel { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap; }

.nivel::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.nivel-informativa { color: var(--blue2); background: rgba(143, 180, 255, 0.12); border-color: rgba(143, 180, 255, 0.3); }
.nivel-atencion { color: var(--amber); background: var(--amber-soft); border-color: rgba(242, 185, 61, 0.32); }
.nivel-importante { color: #ff9d6e; background: rgba(255, 138, 76, 0.14); border-color: rgba(255, 138, 76, 0.34); }
.nivel-urgente { color: #ff8f8f; background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.45); }
.nivel-urgente::before { box-shadow: 0 0 8px rgba(239, 68, 68, 0.8); }

.alerta-item { display: flex; gap: 14px; align-items: flex-start; padding: 14px 20px;
  border-bottom: 1px solid rgba(27, 42, 64, 0.7); }
.alerta-item:last-child { border-bottom: none; }
.alerta-item:hover { background: rgba(19, 31, 54, 0.45); }
.alerta-cuerpo { flex: 1; min-width: 0; }
.alerta-titulo { font-weight: 600; font-size: 0.92rem; color: var(--text); }
.alerta-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-top: 4px; font-size: 0.76rem; color: var(--muted-2); }
.alerta-detalle { margin-top: 6px; font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.alerta-acciones { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.contador-nivel { display: grid; gap: 2px; }
.contador-nivel strong { font-size: 1.5rem; line-height: 1; }
.contador-nivel span { font-size: 0.72rem; color: var(--muted); }

.tabla-destinatarios { width: 100%; border-collapse: collapse; }
.tabla-destinatarios td { padding: 7px 4px; vertical-align: middle; border: 0; }
.tabla-destinatarios tr + tr td { border-top: 1px solid rgba(27, 42, 64, 0.55); }

/* --- Selector de asistente en la barra superior -------------------------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.selector-asistente select {
  appearance: none;
  max-width: 260px;
  padding: 7px 30px 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238493ac' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>")
    no-repeat right 10px center;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-overflow: ellipsis;
}

.selector-asistente select:hover { border-color: var(--accent); }
.selector-asistente select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Tarjetas de asistente ------------------------------------------------ */

.asistente-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }

.asistente-card { display: flex; flex-direction: column; gap: 0;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

.asistente-card-head { padding: 16px 18px 12px; border-bottom: 1px solid rgba(27, 42, 64, 0.7); }
.asistente-card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.asistente-card-title h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.asistente-card-sub { margin-top: 4px; font-size: 0.78rem; color: var(--muted-2); }
.asistente-card-body { padding: 14px 18px; flex: 1; display: grid; gap: 10px; }
.asistente-dato { display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem; }
.asistente-dato span:first-child { color: var(--muted); }
.asistente-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-componente { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); }
.chip-componente.on { color: var(--cyan); border-color: rgba(88, 224, 255, 0.4); background: rgba(88, 224, 255, 0.1); }
.asistente-card-foot { padding: 12px 18px 16px; display: flex; gap: 8px; flex-wrap: wrap; }

.aviso-config { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--amber); }

/* --- Pestañas de configuración -------------------------------------------- */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 14px; border-radius: 10px 10px 0 0; font-size: 0.84rem; font-weight: 600;
  color: var(--muted); border: 1px solid transparent; border-bottom: none; }
.tab:hover { color: var(--text); background: rgba(19, 31, 54, 0.6); }
.tab.active { color: var(--text); background: var(--surface); border-color: var(--border); box-shadow: inset 0 2px 0 var(--cyan); }

.componente-fila { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid rgba(27, 42, 64, 0.55); }
.componente-fila:last-child { border-bottom: none; }
.componente-nombre { font-weight: 600; font-size: 0.9rem; }
.componente-desc { font-size: 0.76rem; color: var(--muted-2); margin-top: 2px; }
.componente-check { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--muted); }
.componente-check input { width: auto; }

@media (max-width: 620px) {
  .selector-asistente select { max-width: 150px; font-size: 0.72rem; }
  .asistente-grid { grid-template-columns: 1fr; }
  .componente-fila { grid-template-columns: 1fr auto; }
  .componente-check:last-child { grid-column: 1 / -1; }
}

/* --- Login con video --------------------------------------------------- */

.login-body {
  min-height: 100svh;
  padding: clamp(10px, 2.2vh, 20px) 24px;
}

.login-shell {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.8vh, 18px);
}

.login-hero {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* La altura manda: el ancho sale del 16:9 y se recorta en pantallas angostas,
   así el video y la tarjeta entran juntos en una sola pantalla. */
.login-video,
.login-video-embed {
  width: min(100%, calc(37svh * 16 / 9), 880px);
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #05070c;
  border: 1px solid var(--border);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
}

.login-video {
  position: relative;
  display: block;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.login-video:hover {
  border-color: rgba(90, 110, 255, 0.55);
  transform: translateY(-1px);
}

.login-video picture,
.login-video img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-video img {
  opacity: 0.9;
  transition: opacity 0.18s ease, transform 0.4s ease;
}

.login-video:hover img {
  opacity: 1;
  transform: scale(1.015);
}

.login-video-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.login-video-play::before {
  content: "";
  width: clamp(46px, 7vh, 74px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(10, 14, 24, 0.62);
  border: 1px solid rgba(231, 236, 247, 0.45);
  backdrop-filter: blur(2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.login-video-play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform: translate(-40%, -50%);
  border-left: clamp(16px, 2.6vh, 26px) solid var(--text);
  border-top: clamp(10px, 1.6vh, 16px) solid transparent;
  border-bottom: clamp(10px, 1.6vh, 16px) solid transparent;
}

.login-video-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-height: 760px) and (min-aspect-ratio: 4 / 3) {
  .login-video,
  .login-video-embed {
    width: min(100%, calc(31svh * 16 / 9), 700px);
  }
}

@media (max-width: 620px) {
  .login-card {
    padding: 24px 20px;
  }

  .login-video,
  .login-video-embed {
    width: min(100%, calc(28svh * 16 / 9));
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-video,
  .login-video img {
    transition: none;
  }

  .login-video:hover {
    transform: none;
  }
}


/* La tarjeta se aprieta cuando hay video arriba: todo tiene que entrar junto. */
.login-body-con-video .login-card {
  max-width: 360px;
  padding: 20px 24px;
}

.login-body-con-video .login-logo {
  margin-bottom: 6px;
}

.login-body-con-video .login-logo img,
.login-body-con-video .login-logo svg {
  width: 42px;
  height: 42px;
}

.login-body-con-video .login-heading {
  font-size: 1.12rem;
  margin-bottom: 2px;
}

.login-body-con-video .subtitle {
  font-size: 0.76rem;
  line-height: 1.35;
  margin-bottom: 12px;
}

.login-body-con-video .login-form .field {
  margin-bottom: 8px;
}

.login-body-con-video .login-form .field label {
  font-size: 0.74rem;
  margin-bottom: 4px;
}

.login-body-con-video .login-form input {
  padding-top: 9px;
  padding-bottom: 9px;
}

.login-body-con-video .login-form button[type='submit'] {
  margin-top: 10px;
  padding: 10px;
}

.login-body-con-video .login-foot {
  margin-top: 12px;
  font-size: 0.78rem;
}

.login-body-con-video .login-secure {
  margin-top: 14px;
  padding-top: 12px;
  font-size: 0.62rem;
}

.login-body-con-video .alert,
.login-body-con-video .form-error {
  font-size: 0.78rem;
  padding: 8px 10px;
  margin-bottom: 10px;
}
