/* Otea Remote by IT Energy — Panel de administración
   Paleta Otea: azul #1E408A (principal), verde #3AB54A (acento / en línea / correcto),
   gris IT Energy #595A5C (texto secundario). En tema noche el azul pasa a #6F8FD6 (≥ 4,5:1 sobre los fondos). */
:root {
  --it-blue: #1E408A;
  --it-blue-hover: #183573;
  --it-green: #3AB54A;
  --it-gray: #595A5C;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1d1e20;
  --muted: var(--it-gray);
  --border: #dfe3e8;
  --primary: var(--it-blue);            /* enlaces, acentos, botón principal */
  --primary-hover: var(--it-blue-hover);
  --on-primary: #ffffff;                /* texto sobre el botón principal (9,7:1) */
  --primary-soft: #e7ecf6;
  --ok: #247a2d;                        /* verde Otea oscurecido para texto legible sobre fondo claro */
  --ok-soft: #e6f5e8;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info-soft: #e8eef8;
  --shadow: 0 1px 2px rgba(29, 30, 32, .06), 0 4px 16px rgba(29, 30, 32, .06);
  --radius: 10px;
  --sidebar: #ffffff;
  --sidebar-text: #3a3b3d;
  --sidebar-hover: #eef2f8;
  --sidebar-active: #e8eef8;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121315;
  --surface: #1b1c1f;
  --surface-2: #222326;
  --text: #eceef1;
  --muted: #a3a5a8;
  --border: #303236;
  --primary: #6F8FD6;
  --primary-hover: #8aa5e0;
  --on-primary: #0d0e10;               /* texto oscuro sobre #6F8FD6 (6:1) */
  --primary-soft: #1d2a3d;
  --ok: #5fcf69;
  --ok-soft: #16301a;
  --warn: #f2b84b;
  --warn-soft: #3a2c0c;
  --danger: #f28b82;
  --danger-soft: #3b1714;
  --info-soft: #1d2a3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
  --sidebar: #16171a;
  --sidebar-text: #d4d6d9;
  --sidebar-hover: #222326;
  --sidebar-active: #1d2a3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-msg { color: var(--muted); }

/* Logotipo según el tema: versión clara sobre fondo claro y versión noche sobre fondo oscuro. */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

/* ---------- Estructura ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: block; padding: 0 4px 6px; }
.brand img { width: 100%; max-width: 210px; height: auto; }
.brand-caption { font-size: 11px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; padding: 0 10px 12px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.user-chip .role { font-size: 11px; color: var(--muted); }
.content { padding: 24px; max-width: 1400px; width: 100%; }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat.accent { border-top: 3px solid var(--primary); }
.stat.online { border-top: 3px solid var(--it-green); }
.stat.alert { border-top: 3px solid var(--danger); }
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.nowrap { white-space: nowrap; }
.seat-line { font-size: 15px; margin-bottom: 6px; }
.seat-count { font-size: 24px; font-weight: 700; color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { padding: 6px 9px; }
.btn.menu-btn { display: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 12.5px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; margin-bottom: 12px; }
.checks .check { margin-bottom: 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--primary-soft); }
td.num, th.num { text-align: right; }
td code { white-space: nowrap; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--info-soft); color: var(--primary); white-space: nowrap; margin: 1px 2px 1px 0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #a3a5a8; margin-right: 6px; }
.dot.on { background: var(--it-green); box-shadow: 0 0 0 3px rgba(58, 181, 74, .22); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--text); border-color: var(--border); }

.secret-box {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px dashed var(--primary); border-radius: 8px; padding: 12px; margin-bottom: 12px;
}
.secret-box code { flex: 1; font-size: 16px; word-break: break-all; font-weight: 600; }
/* QR de la verificación en dos pasos: fondo blanco también en el tema noche para que el celular lo lea */
.qr-box { display: inline-block; background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 12px; }
.qr-box img { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
details { margin-bottom: 12px; }
details summary { cursor: pointer; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.kv .secret-box { margin-bottom: 0; }
.kv .secret-box code { font-size: 12.5px; font-weight: 500; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; align-items: center; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- Diálogos y avisos ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(620px, 94vw);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(10, 12, 16, .55); }
dialog.wide { width: min(1080px, 96vw); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 18px; max-height: 72vh; overflow-y: auto; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; border-left: 4px solid var(--it-green); }
.toast.error { background: var(--danger); color: #fff; border-left-color: #fff; }

.progress { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; width: 0; background: var(--it-green); transition: width .2s; }

/* ---------- Inicio de sesión ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #1E408A 0%, #13295a 100%); }
[data-theme="dark"] .login-wrap { background: linear-gradient(135deg, #121315 0%, #1d2a3d 100%); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); border-top: 4px solid var(--it-green); }
.login-brand { margin: 0 0 4px; }
.login-brand img { width: 100%; max-width: 280px; height: auto; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.login-card .btn { width: 100%; padding: 10px; margin-top: 4px; }
.login-card .btn.theme-btn, .login-card .btn.ghost { width: auto; padding: 6px 10px; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ---------- Página pública de descarga ---------- */
.download-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.download-card { width: min(720px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); border-top: 4px solid var(--it-green); }
.download-card h1 { margin-top: 8px; }
.download-card h2 { margin-top: 22px; }
.download-card ol { padding-left: 20px; }
.download-card li { margin-bottom: 6px; }
.btn.download-btn { font-size: 16px; padding: 12px 22px; }
.download-links { margin-top: 18px; }

/* ---------- Página pública de planes ---------- */
.download-card.plans-card { width: min(1100px, 100%); }
.access-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 8px; }
.access-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); border-top: 3px solid var(--primary); }
.access-card:nth-child(2) { border-top-color: var(--it-gray); }
.access-card:nth-child(3) { border-top-color: var(--it-green); }
.access-card h3 { margin-bottom: 6px; }
.access-card p { margin: 0 0 8px; }
.plans-table th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); background: var(--surface-2); white-space: normal; }
.plans-table thead th { font-size: 14px; color: var(--primary); text-transform: none; }
.plans-table td { vertical-align: top; }
.faq dt { font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }

/* ---------- Modelo híbrido (panel y portal) ---------- */
.usage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 14px; }
.usage-grid .seat-count { font-size: 20px; }
.device-picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 6px; }
.device-picker .check { margin-bottom: 6px; }
.check.inline { display: inline-flex; margin-bottom: 0; }
textarea[readonly] { background: var(--surface-2); font-family: var(--mono); font-size: 12.5px; }

/* ---------- Técnicos, solicitudes de prueba y avisos ---------- */
.nav-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: auto; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.notice-bar:empty { display: none; }
.notice-bar { padding: 0 24px; }
.notice-bar .alert { margin: 12px 0 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.notice-bar .alert .grow { flex: 1; }
.blocking-card { border: 2px solid var(--danger); }
.public-form textarea { width: 100%; }
.field-error { font-size: 12px; color: var(--danger); font-weight: 600; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.privacy-note { margin: 6px 0 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.privacy-note h2 { font-size: 14px; margin: 0 0 6px; }
.privacy-note p { margin: 0 0 10px; color: var(--muted); }
/* Campo trampa del formulario público: fuera de la vista y del lector de pantalla. */
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.dup-list { margin: 4px 0 0; padding-left: 18px; color: var(--warn); font-size: 12.5px; }

/* ---------- Adaptación a pantallas pequeñas ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .btn.menu-btn { display: inline-flex; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .grid-2, .form-grid, .access-grid, .usage-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1; }
}
