/* Panel de administracion de Sehcontrol.
 *
 * Solo presentacion: ningun selector cambia de nombre y no se agrega ni se
 * quita ninguno, para que el JS que arma el HTML siga funcionando igual.
 *
 * El panel se usa desde el telefono para revisar equipos fuera de la oficina y
 * no tenia una sola media query: la barra lateral fija de 220px se comia media
 * pantalla, las tablas desbordaban el ancho y el boton de cerrar sesion,
 * posicionado en absoluto, quedaba encima del contenido. Todo eso se resuelve
 * al final, en la capa responsive.
 */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --border: #e3e5e8;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #d64545;
  --success: #1e9e5a;
  --warn: #b8860b;
  /* Agregadas para que el espaciado y la profundidad sean consistentes en
   * lugar de un valor distinto en cada regla. */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
  --hover: rgba(47, 111, 237, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --panel: #1e2129;
    --text: #e8e9ec;
    --muted: #9aa0aa;
    --border: #2c303a;
    --accent: #4c8dff;
    --accent-text: #0b0d10;
    --danger: #e5686a;
    --success: #3ecb82;
    --warn: #e0b34e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    --hover: rgba(76, 141, 255, 0.12);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-card { width: 340px; max-width: 100%; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-top: 0; }
label { display: block; font-size: 13px; margin: 12px 0 4px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  /* 16px evita que iOS haga zoom al enfocar un campo, que descoloca toda la
   * pagina y obliga a alejar a mano despues de cada escritura. */
  font-size: 16px;
  font-family: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--hover);
}
textarea { resize: vertical; min-height: 88px; }
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  background: var(--accent);
  color: var(--accent-text);
  transition: filter 120ms ease, background 120ms ease, border-color 120ms ease;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { filter: brightness(0.95); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.secondary:hover:not(:disabled) { background: var(--hover); border-color: var(--accent); filter: none; }
button.danger { background: var(--danger); color: #fff; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }
.msg-ok { color: var(--success); font-size: 13px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex-shrink: 0;
  /* La navegacion acompana el scroll del contenido en pantallas largas. */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar h2 { font-size: 15px; padding: 0 8px; margin-bottom: 20px; }
.sidebar nav { flex: 1; }
.sidebar nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  margin-bottom: 4px;
  padding: 9px 10px;
  font-weight: 400;
}
.sidebar nav button:hover:not(.active) { background: var(--hover); filter: none; }
.sidebar nav button.active { background: var(--accent); color: var(--accent-text); font-weight: 500; }
/* Sin position:absolute: en el flex column queda abajo por si solo, y ya no
 * depende de un ancho fijo que se desalineaba al cambiar la barra. */
.sidebar .logout { width: 100%; margin-top: auto; }
/* min-width:0 permite que el area se encoja dentro del flex; sin eso una
 * tabla ancha estira el contenedor y empuja la barra lateral fuera de la
 * pantalla. overflow-x se conserva como estaba. */
.main { flex: 1; padding: 28px 32px; min-width: 0; overflow-x: auto; }
.main h1 { margin-top: 0; font-size: 22px; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 140px;
  flex: 1 1 140px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 600; }
.stat .label { font-size: 12px; color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
tbody tr:hover td { background: var(--hover); }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.active { background: rgba(30,158,90,0.15); color: var(--success); }
.badge.suspended { background: rgba(214,69,69,0.15); color: var(--danger); }
.badge.warn { background: rgba(184,134,11,0.15); color: var(--warn); }
.badge.admin { background: rgba(47,111,237,0.15); color: var(--accent); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.account-card {
  padding: 0;
  margin-bottom: 12px;
  transition: border-color 120ms ease;
}
.account-card[open] { border-color: var(--accent); }
.account-card summary {
  cursor: pointer;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  border-radius: var(--radius);
}
.account-card summary:hover { background: var(--hover); }
.account-card[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
.account-card summary::-webkit-details-marker { display: none; }
.account-card summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 12px;
  flex-shrink: 0;
  border-style: solid;
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent var(--muted);
  transition: transform 0.15s ease;
}
.account-card[open] summary::before { transform: rotate(90deg); }
.account-summary-info { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.account-summary-info .label { font-size: 12px; color: var(--muted); }
.account-body { padding: 0 20px 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 16px;
  overflow-y: auto;
}
.modal {
  width: 380px;
  max-width: 100%;
  /* Un formulario largo en una pantalla baja quedaba con los botones fuera de
   * la vista y sin forma de llegar a ellos. */
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin-top: 0; font-size: 17px; }
.row-actions button { margin-right: 6px; margin-bottom: 4px; padding: 5px 10px; font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  margin: 0;
  flex-shrink: 0;
}
.switch input { width: 1px; height: 1px; opacity: 0; position: absolute; }
.switch span {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border-radius: 11px;
  background: var(--border);
  transition: background 150ms ease;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 150ms ease;
}
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + span { cursor: wait; opacity: 0.6; }
.check-label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check-label input { width: auto; margin: 0; }
.settings-help { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.danger-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: rgba(214,69,69,0.08);
  color: var(--text);
  font-size: 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet: se achica el respiro lateral, que a este ancho es lo que mas
   espacio util roba. */
@media (max-width: 1024px) {
  .sidebar { width: 190px; }
  .main { padding: 24px 20px; }
}

/* Telefono: la barra lateral pasa a ser una fila de pestanas arriba. Se
   mantiene visible -no se esconde tras un boton- porque cambiar de seccion es
   lo que mas se hace en este panel, y un menu oculto agrega un toque a cada
   navegacion. */
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  /* Dos filas: titulo y "cerrar sesion" arriba, las pestanas debajo ocupando
     el ancho completo.
     En una sola fila la navegacion quedaba con 104px utiles de 790px de
     pestanas -- siete de las ocho eran inalcanzables sin arrastrar a ciegas,
     porque el titulo y el boton de salir se comian la fila. En su propia fila
     pasa a 351px visibles en un telefono de 375px. */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
    box-shadow: var(--shadow);
  }
  .sidebar h2 {
    margin: 0;
    padding: 0;
    font-size: 13px;
    white-space: nowrap;
    flex: 1 1 auto;
  }
  /* flex-basis 100% es lo que fuerza la segunda fila. */
  .sidebar nav {
    flex: 1 0 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav button {
    width: auto;
    margin-bottom: 0;
    white-space: nowrap;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .sidebar .logout {
    width: auto;
    margin-top: 0;
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 13px;
  }

  .main { padding: 18px 14px; }
  .main h1 { font-size: 19px; }

  .stat-row { gap: 10px; margin-bottom: 18px; }
  /* Dos por fila. El descuento es mayor que la mitad del gap a proposito: con
     el valor exacto (50% - 5px) el par entra justo y el redondeo subpixel
     hacia que envolvieran a una sola columna. */
  .stat { padding: 13px 15px; min-width: 0; flex: 1 1 calc(50% - 7px); }
  .stat .num { font-size: 21px; }

  /* La tabla conserva su ancho natural y se desplaza dentro de si misma, en
     vez de comprimir las columnas hasta volverlas ilegibles. display:block es
     lo que le da scroll propio sin necesitar un div envolvente, que obligaria
     a tocar el JS que arma cada tabla. */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  th, td { padding: 9px 10px; white-space: nowrap; }
  /* El encabezado pegajoso pierde sentido cuando quien scrollea es la caja y
     no la pagina, y ademas se superpone con la barra de pestanas. */
  th { position: static; }

  .account-card summary { padding: 12px 14px; }
  .account-body { padding: 14px 14px 16px; }
  .account-summary-info { gap: 10px; }

  .toolbar { align-items: stretch; }
  .toolbar button { width: 100%; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  /* Anclada abajo: en un telefono es donde llega el pulgar, y evita que el
     teclado virtual tape los campos al abrirse. */
  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }

  /* Objetivos tactiles: por debajo de ~40px de alto los botones de accion en
     fila se vuelven dificiles de acertar. */
  .row-actions button { padding: 8px 12px; font-size: 12px; }
  button { padding: 10px 16px; }
}

/* Una sola columna solo en pantallas realmente angostas. El corte va por
   debajo de 360px a proposito: los telefonos comunes (360, 375, 390) entran
   con dos tarjetas de ~169px, que alcanzan de sobra para "S/220 PEN" y su
   etiqueta. Con nueve indicadores, forzar una columna en esos anchos convertia
   el panel en un scroll largo sin necesidad. */
@media (max-width: 339px) {
  .stat { flex: 1 1 100%; }
}

/* Respeta a quien pidio menos animacion en su sistema. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ==========================================================================
   Panel administrativo 2026
   La capa se limita a .admin-page para no alterar el acceso ni el portal del
   cliente, que comparten esta hoja de estilos.
   ========================================================================== */
.admin-page {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #6d7890;
  --border: #e5eaf2;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #eaf1ff;
  --nav: #101c2e;
  --nav-soft: #1a2a42;
  --nav-text: #d7e0ee;
  --nav-muted: #8290a7;
  --success: #0f9f6e;
  --danger: #dc4c64;
  --warn: #d28a13;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 32, 51, 0.03), 0 8px 24px rgba(16, 32, 51, 0.045);
  --shadow-lg: 0 24px 70px rgba(16, 32, 51, 0.2);
  background:
    radial-gradient(circle at 88% 0%, rgba(37, 99, 235, 0.055), transparent 28rem),
    var(--bg);
}

.admin-page .layout { min-height: 100dvh; }
.admin-page .mobile-header,
.admin-page .sidebar-backdrop,
.admin-page .sidebar-close { display: none; }

.admin-page .sidebar {
  width: 260px;
  padding: 26px 16px 18px;
  border: 0;
  color: var(--nav-text);
  background: var(--nav);
  box-shadow: 12px 0 40px rgba(13, 27, 46, 0.07);
}
.admin-page .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 9px 26px;
}
.admin-page .brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  border-radius: 11px;
  background: linear-gradient(145deg, #4f8cff, #2359d9);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.34);
}
.admin-page .brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: .01em; }
.admin-page .brand small { display: block; margin-top: 2px; color: var(--nav-muted); font-size: 11px; }
.admin-page .nav-label {
  padding: 0 12px 8px;
  color: var(--nav-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.admin-page .sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.admin-page .sidebar nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 43px;
  margin: 0;
  padding: 8px 10px;
  color: var(--nav-text);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 10px;
  opacity: .82;
}
.admin-page .sidebar nav button::before {
  content: "•";
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  color: #9aabc2;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  background: rgba(255,255,255,.055);
}
.admin-page .sidebar nav button[data-tab="dashboard"]::before { content: "⌂"; }
.admin-page .sidebar nav button[data-tab="users"]::before { content: "U"; font-size: 11px; }
.admin-page .sidebar nav button[data-tab="plans"]::before { content: "M"; font-size: 11px; }
.admin-page .sidebar nav button[data-tab="devices"]::before { content: "▣"; }
.admin-page .sidebar nav button[data-tab="payments"]::before { content: "$"; }
.admin-page .sidebar nav button[data-tab="alerts"]::before { content: "!"; }
.admin-page .sidebar nav button[data-tab="activity"]::before { content: "↗"; }
.admin-page .sidebar nav button[data-tab="settings"]::before { content: "⚙"; }
.admin-page .sidebar nav button:hover:not(.active) { color: #fff; background: rgba(255,255,255,.065); opacity: 1; }
.admin-page .sidebar nav button.active {
  color: #fff;
  background: linear-gradient(110deg, #2563eb, #3477f4);
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 9px 18px rgba(10, 69, 194, .25);
  opacity: 1;
}
.admin-page .sidebar nav button.active::before { color: #fff; background: rgba(255,255,255,.15); }
.admin-page .sidebar-footer {
  display: grid;
  grid-template-columns: 8px 1fr;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 15px 9px 0;
  color: var(--nav-muted);
  font-size: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.admin-page .session-dot { width: 7px; height: 7px; border-radius: 50%; background: #35d39a; box-shadow: 0 0 0 4px rgba(53,211,154,.1); }
.admin-page .sidebar .logout {
  grid-column: 1 / -1;
  min-height: 39px;
  margin-top: 10px;
  color: var(--nav-text);
  border-color: rgba(255,255,255,.12);
  background: rgba(255,255,255,.035);
}
.admin-page .sidebar .logout:hover:not(:disabled) { color: #fff; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.08); }

.admin-page .main {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 38px clamp(26px, 3.2vw, 54px) 54px;
  overflow-x: hidden;
}
.admin-page .main h1 { margin: 0; color: var(--text); font-size: clamp(23px, 2vw, 30px); line-height: 1.2; letter-spacing: -.025em; }
.admin-page .main h2 { margin: 2px 0 0; font-size: 18px; letter-spacing: -.015em; }
.admin-page .page-heading,
.admin-page .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.admin-page .page-heading { margin-bottom: 25px; }
.admin-page .page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.admin-page .eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.admin-page .live-pill,
.admin-page .section-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.7);
}
.admin-page .live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(15,159,110,.1); }
.admin-page .section-heading { margin: 30px 0 13px; }

.admin-page .stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.admin-page .stat {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 105px;
  padding: 18px;
  border: 1px solid rgba(219,226,237,.9);
  border-radius: var(--radius);
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.admin-page .stat:hover { transform: translateY(-2px); border-color: #d4deef; box-shadow: 0 14px 30px rgba(16,32,51,.075); }
.admin-page .stat-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  border-radius: 12px;
  background: var(--accent-soft);
}
.admin-page .stat-revenue .stat-icon { color: #087a5b; background: #e3f8f0; }
.admin-page .stat-users .stat-icon { color: #6b46c1; background: #f0eafe; }
.admin-page .stat-devices .stat-icon { color: #1764c0; background: #e7f2ff; }
.admin-page .stat-warning .stat-icon { color: #a36508; background: #fff3d9; }
.admin-page .stat-danger .stat-icon { color: #c43b52; background: #ffe9ed; }
.admin-page .stat .label { margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .015em; }
.admin-page .stat .num { overflow: hidden; color: var(--text); font-size: clamp(20px, 1.75vw, 27px); font-weight: 750; line-height: 1.15; text-overflow: ellipsis; }

.admin-page table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.admin-page th { height: 45px; padding: 11px 15px; color: #748097; font-size: 10px; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; background: #f9fafc; }
.admin-page td { height: 50px; padding: 12px 15px; font-size: 12px; }
.admin-page tbody tr { transition: background 120ms ease; }
.admin-page tbody tr:hover td { background: #f8faff; }
.admin-page .toolbar { margin-bottom: 22px; }
.admin-page .toolbar::after { content: ""; flex-basis: 100%; height: 0; order: 3; }
.admin-page .toolbar h1 { flex: 1; }
.admin-page button { min-height: 38px; border-radius: 9px; font-weight: 650; box-shadow: 0 5px 12px rgba(37,99,235,.12); }
.admin-page button.secondary { box-shadow: none; }
.admin-page button.danger { box-shadow: 0 5px 12px rgba(220,76,100,.11); }
.admin-page input,
.admin-page select,
.admin-page textarea { min-height: 41px; border-color: #dce3ed; background: #fbfcfe; }
.admin-page .card { border-color: var(--border); }
.admin-page .account-card { overflow: hidden; }
.admin-page .account-card summary { min-height: 60px; }
.admin-page .badge { padding: 4px 9px; font-weight: 700; }
.admin-page .sc-cell {
  width: 380px;
  min-width: 260px;
  max-width: 380px;
  white-space: normal;
}
.admin-page .sc-error {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.admin-page .modal-backdrop { backdrop-filter: blur(5px); background: rgba(10,20,36,.58); }
.admin-page .modal { border: 0; }

@media (prefers-color-scheme: dark) {
  .admin-page {
    --bg: #101620;
    --panel: #17202d;
    --text: #edf2f8;
    --muted: #9aa7b9;
    --border: #293446;
    --accent-soft: #1d315a;
    background: var(--bg);
  }
  .admin-page .stat { background: #17202d; border-color: #293446; }
  .admin-page .live-pill,
  .admin-page .section-count { background: #17202d; }
  .admin-page th { background: #1b2533; }
  .admin-page tbody tr:hover td { background: #1b2738; }
  .admin-page input,
  .admin-page select,
  .admin-page textarea { background: #121b27; border-color: #344055; }
}

@media (max-width: 1100px) and (min-width: 721px) {
  .admin-page .sidebar { width: 226px; }
  .admin-page .main { padding: 32px 26px 46px; }
  .admin-page .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .admin-page { padding-top: calc(64px + env(safe-area-inset-top)); }
  .admin-page.sidebar-open { overflow: hidden; }
  .admin-page .layout { display: block; }
  .admin-page .mobile-header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 11px;
    height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: 0 6px 20px rgba(16,32,51,.05);
    backdrop-filter: blur(14px);
  }
  .admin-page .menu-toggle {
    display: grid;
    align-content: center;
    gap: 4px;
    width: 39px;
    min-height: 39px;
    padding: 9px;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: none;
  }
  .admin-page .menu-toggle span { display: block; width: 18px; height: 2px; margin: auto; border-radius: 2px; background: currentColor; }
  .admin-page .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 14px; }
  .admin-page .mobile-brand .brand-mark { width: 29px; height: 29px; flex-basis: 29px; border-radius: 8px; font-size: 13px; }
  .admin-page .mobile-context { margin-left: auto; padding: 5px 8px; color: var(--accent); font-size: 10px; font-weight: 750; border-radius: 7px; background: var(--accent-soft); }
  .admin-page .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    width: min(86vw, 310px);
    height: 100dvh;
    padding: calc(22px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-103%);
    transition: transform 220ms ease;
    box-shadow: 18px 0 55px rgba(4,12,24,.28);
  }
  .admin-page.sidebar-open .sidebar { transform: translateX(0); }
  .admin-page .sidebar .brand { flex: none; width: 100%; padding-bottom: 20px; }
  .admin-page .sidebar-close {
    display: grid;
    place-items: center;
    width: 34px;
    min-height: 34px;
    margin-left: auto;
    padding: 0;
    color: var(--nav-text);
    font-size: 24px;
    font-weight: 300;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.04);
    box-shadow: none;
  }
  .admin-page .sidebar nav { flex: 1; width: 100%; overflow: visible; }
  .admin-page .sidebar nav button { width: 100%; flex: 0 0 auto; border-radius: 10px; }
  .admin-page .sidebar-footer { width: 100%; }
  .admin-page .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    visibility: hidden;
    opacity: 0;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    background: rgba(5,12,23,.52);
    box-shadow: none;
    backdrop-filter: blur(2px);
    transition: opacity 180ms ease, visibility 180ms ease;
  }
  .admin-page.sidebar-open .sidebar-backdrop { visibility: visible; opacity: 1; }
  .admin-page .main { padding: 23px 14px 40px; overflow-x: hidden; }
  .admin-page .page-heading { align-items: flex-end; margin-bottom: 19px; }
  .admin-page .page-heading p { max-width: 210px; }
  .admin-page .live-pill { padding: 6px 9px; font-size: 10px; }
  .admin-page .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .admin-page .stat { display: block; min-height: 132px; padding: 14px; }
  .admin-page .stat-icon { width: 34px; height: 34px; margin-bottom: 14px; border-radius: 10px; }
  .admin-page .stat .num { font-size: 20px; white-space: nowrap; }
  .admin-page .stat .label { min-height: 27px; line-height: 1.25; }
  .admin-page .section-heading { margin-top: 25px; }
  .admin-page table { width: 100%; border-radius: 12px; }
  .admin-page th,
  .admin-page td { height: auto; padding: 11px 12px; }
  .admin-page .toolbar { align-items: center; gap: 12px; }
  .admin-page .toolbar h1 { width: 100%; flex-basis: 100%; }
  .admin-page .toolbar button { width: 100%; }
  .admin-page .account-card summary { align-items: flex-start; }
  .admin-page .account-summary-info { display: grid; gap: 5px; min-width: 0; }
  .admin-page .account-summary-info strong { overflow-wrap: anywhere; }
  .admin-page .account-body { overflow-x: hidden; }
  .admin-page .sc-cell {
    width: min(310px, calc(100vw - 52px));
    min-width: min(260px, calc(100vw - 52px));
    max-width: min(310px, calc(100vw - 52px));
  }
  .admin-page .modal { padding: 22px 16px calc(20px + env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .admin-page .stat-row { grid-template-columns: 1fr; }
  .admin-page .stat { display: flex; min-height: 94px; }
  .admin-page .stat-icon { margin-bottom: 0; }
  .admin-page .stat .label { min-height: 0; }
  .admin-page .live-pill { display: none; }
}
