:root {
  color-scheme: light;
  --bg: #eef2f8;
  --panel: #ffffff;
  --panel-2: #f5f7fb;
  --text: #17202b;
  --muted: #5b6878;
  --border: #d9e0ea;
  --brand: #0b4fbf;
  --brand-ink: #0b4fbf;
  --brand-deep: #0b2a6f;
  --on-brand: #ffffff;
  --ok: #157f3b;
  --ok-bg: rgba(21, 127, 59, 0.1);
  --warn: #9a5b00;
  --warn-bg: rgba(214, 140, 0, 0.14);
  --bad: #c4232d;
  --bad-bg: rgba(196, 35, 45, 0.1);
  --shadow: 0 1px 2px rgba(23, 32, 43, 0.06), 0 8px 24px rgba(23, 32, 43, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1117;
    --panel: #161b22;
    --panel-2: #1c232d;
    --text: #e6edf3;
    --muted: #9aa7b6;
    --border: #2b3440;
    --brand: #2f6fe0;
    --brand-ink: #7fb0ff;
    --ok: #4ccf7a;
    --ok-bg: rgba(76, 207, 122, 0.12);
    --warn: #f0b44c;
    --warn-bg: rgba(240, 180, 76, 0.14);
    --bad: #ff6b6b;
    --bad-bg: rgba(255, 107, 107, 0.12);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
a { color: var(--brand-ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); font-weight: 600; min-height: 1em; margin: 8px 0 0; }
.error:empty { display: none; }
.spacer { flex: 1; }

/* Botones y campos */
.btn { appearance: none; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 10px; padding: 0 16px; min-height: 42px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-danger { color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
input, select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 42px; width: 100%; }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check input { width: 18px; height: 18px; min-height: 0; }

/* Inicio de sesión y páginas simples */
.center-card { max-width: 400px; margin: 6vh auto 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); text-align: left; }
.center-card h1 { font-size: 20px; margin: 12px 0 6px; text-align: center; }
.center-card p { text-align: center; }
.logo-big { display: block; margin: 0 auto 16px; width: 100%; max-width: 340px; height: auto; object-fit: contain; background: #fff; border-radius: 12px; padding: 8px; }
.by { text-align: center; margin: 16px 0 0; }

/* Estructura */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--muted); font-weight: 700; }
.brand img { height: 32px; background: #fff; border-radius: 8px; padding: 2px 6px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--brand); }
.who { color: var(--muted); font-size: 14px; }
.view { max-width: 1100px; margin: 0 auto; padding: 20px 16px 32px; }
.view h1 { font-size: 22px; margin: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.foot { text-align: center; padding: 16px; }

/* Equipos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.plain::before { display: none; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.meta { font-size: 13px; color: var(--muted); }
.card .actions { margin-top: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty { background: var(--panel); border: 1px dashed var(--border); border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

/* Diálogo y aviso */
.modal { position: fixed; inset: 0; background: rgba(10, 15, 25, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; width: min(520px, 100%); max-height: 92vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 12px; font-size: 19px; }
.modal-card .actions { margin-top: 16px; }
.pair-code { font: 700 38px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.14em; text-align: center; padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); margin: 8px 0; user-select: all; }
.steps { padding-left: 20px; margin: 8px 0; line-height: 1.6; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 30; max-width: calc(100% - 32px); }
.devlist { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; }

@media (max-width: 640px) {
  .top { padding: 8px 12px; }
  .who { display: none; }
  .nav a { padding: 8px; }
}

/* Lista de equipos */
.dev-table td { vertical-align: top; }
.dev-table .dev-name { font-size: 16px; }
.dev-table .facts { gap: 4px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }
.dev-table tbody tr:hover { background: var(--panel-2); }
.warn-box { background: var(--bad-bg); color: var(--text); border: 1px solid var(--bad); border-radius: 10px; padding: 10px 12px; }
/* En el celular cada equipo se muestra como un bloque con etiquetas. */
@media (max-width: 760px) {
  .dev-table thead { display: none; }
  .dev-table, .dev-table tbody, .dev-table tr, .dev-table td { display: block; width: 100%; }
  .dev-table tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .dev-table td { border: 0; padding: 4px 0; }
  .dev-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
  .dev-table td[data-label="Equipo"]::before { display: none; }
  .row-actions { text-align: left; white-space: normal; padding-top: 8px !important; }
  .row-actions .btn { margin: 4px 4px 0 0; }
}

/* Compartir */
.share-table { width: 100%; margin-bottom: 8px; }
.share-table td { padding: 8px 6px; }
.share-table select, .sh-add select { min-height: 36px; padding: 6px 8px; }
.sh-title { font-size: 15px; margin: 14px 0 8px; }
.sh-add { display: grid; grid-template-columns: 1fr 140px auto; gap: 8px; align-items: end; }
.sh-add .field { margin: 0; }
.sh-help { margin: 10px 0 0; padding-left: 18px; }
@media (max-width: 520px) { .sh-add { grid-template-columns: 1fr; } }

/* Cuentas: registro y recuperación */
.center-card.wide { max-width: 460px; }
.logo-small { display: block; margin: 0 auto 4px; height: 72px; max-width: 100%; object-fit: contain; background: #fff; border-radius: 12px; padding: 6px; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; }
.auth-links a { font-weight: 600; }
#l-resend { margin: 0 auto 10px; display: flex; }
textarea { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; resize: vertical; }
textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.account-grid .card h2 { font-size: 16px; }
.contact { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }

/* Pestañas Entrar / Crear cuenta */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; margin: 0 0 16px; }
.auth-tabs button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; min-height: 40px; border-radius: 9px; cursor: pointer; }
.auth-tabs button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); cursor: default; }
.auth-tabs button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.mail-box { margin-bottom: 14px; }
.mail-box .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.mail-box .row .field { flex: 1 1 240px; margin: 0; }

/* Equipos autorizados (licencias) */
.nav-badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; align-items: center; justify-content: center; margin-left: 4px; vertical-align: 1px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; font-size: 13px; min-height: 34px; padding: 0 10px; border-radius: 9px; cursor: pointer; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.warn-text { color: var(--warn); font-weight: 700; }
.lic-table td { vertical-align: top; }
.lic-table td:nth-child(2) { max-width: 260px; }
