:root {
  --night: #0f1226; --indigo: #1b2160; --blue: #3d5afe; --teal: #00b89c; --coral: #e5484d; --amber: #a8650f;
  --ink: #0f1226; --ink-2: #4a5078; --mute: #8a90b8; --line: #e6e8f3; --bg: #f3f5fb; --card: #fff; --soft: #f6f7fc;
  --grad: linear-gradient(135deg, #3d5afe, #00c9a7);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --shadow: 0 1px 2px rgba(15,18,38,.04), 0 8px 24px rgba(15,18,38,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 11px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--soft); }
.btn.primary { border: 0; background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(61,90,254,.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--coral); }
.btn.link { border: 0; background: none; color: var(--blue); height: auto; padding: 8px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

input, select, textarea {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: 15px var(--font); color: var(--ink); outline: none;
}
textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(61,90,254,.12); }
input:disabled { background: var(--soft); color: var(--ink-2); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; font-size: 14px; color: var(--ink); }
label.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.error { color: var(--coral); font-size: 14px; min-height: 20px; }

/* ---------- Acceso ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side {
  background: radial-gradient(90% 70% at 0% 0%, rgba(61,90,254,.55), transparent 60%), radial-gradient(70% 60% at 100% 100%, rgba(0,201,167,.3), transparent 60%), var(--night);
  color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.auth-side h1 { font-size: clamp(32px, 4vw, 46px); font-weight: 800; }
.auth-side p { color: #c6cbef; font-size: 17px; max-width: 460px; margin: 0; }
.auth-side ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; color: #dfe3ff; }
.auth-side li::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 10px; border-radius: 50%; background: rgba(0,201,167,.25); color: #5cf0d0; font-size: 12px; font-weight: 700; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 400px; max-width: 100%; background: #fff; border-radius: 20px; padding: 34px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.auth-card h2 { font-size: 24px; }
.auth-card p { margin: -6px 0 4px; }
.code { height: 60px; font: 700 30px var(--mono); letter-spacing: 12px; text-align: center; }
.mail-ic { width: 52px; height: 52px; border-radius: 14px; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 26px; }
.spinner { width: 40px; height: 40px; margin: 10px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand { display: inline-flex; align-items: center; gap: 10px; font: 800 21px var(--font); letter-spacing: -.5px; color: var(--ink); text-decoration: none !important; }
.brand img { width: 32px; height: 32px; }
.brand.light { color: #fff; margin-bottom: 30px; }

/* ---------- Estructura ---------- */
.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 28px; height: 68px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav a { padding: 8px 14px; border-radius: 10px; color: var(--ink-2); font-weight: 600; white-space: nowrap; text-decoration: none !important; }
nav a:hover { background: var(--soft); color: var(--ink); }
nav a.active { background: #eef1ff; color: var(--blue); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.main { padding-top: 30px; padding-bottom: 50px; min-height: calc(100vh - 68px - 70px); }
.foot { display: flex; gap: 12px; padding-top: 20px; padding-bottom: 30px; font-size: 13px; color: var(--mute); }
.foot .sp { flex: 1; }

.hero { border-radius: 22px; padding: 30px 34px; color: #fff; margin-bottom: 22px;
  background: radial-gradient(110% 130% at 0% 0%, #2a3590 0%, var(--night) 62%); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--grad); }
.hero h1 { font-size: clamp(24px, 3vw, 30px); font-weight: 800; }
.hero p { color: #c6cbef; margin: 8px 0 0; }

.page-title { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title h1 { font-size: 26px; flex: 1; min-width: 200px; }

.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; margin-bottom: 14px; }
.stat .l { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); font-weight: 700; }
.stat .v { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin: 6px 0 2px; }
.stat .s { font-size: 13px; color: var(--ink-2); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--soft); color: var(--ink-2); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: #ddf7f1; color: #00866f; }
.chip.warn { background: #fdf1dc; color: var(--amber); }
.chip.bad { background: #fde6ea; color: #c8243f; }
.chip.info { background: #e8ecff; color: var(--blue); }

/* Licencias */
.lic { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.lic-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lic-head h3 { font-size: 20px; }
.key { display: flex; align-items: center; gap: 8px; background: var(--soft); border: 1px dashed #c9cde3; border-radius: 12px; padding: 10px 12px; }
.key span { font: 600 16px var(--mono); flex: 1; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; margin-top: 16px; }
.facts div span { display: block; font-size: 12px; color: var(--mute); }
.facts div strong { font-size: 15px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--grad); }
.bar.warn i { background: #f0a43a; }
.bar.bad i { background: var(--coral); }
.devices { border-left: 1px solid var(--line); padding-left: 22px; }
.devices h4 { margin: 0 0 10px; font-size: 14px; }
.dev { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dev:last-child { border-bottom: 0; }
.dev .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; flex: none; }
.dev .ic svg { width: 17px; height: 17px; color: var(--ink-2); }
.dev .grow { flex: 1; min-width: 0; }
.dev .grow strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.dev.revoked { opacity: .55; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table-wrap { overflow-x: auto; margin: -6px -10px; }
.empty { padding: 30px; text-align: center; color: var(--mute); }

.dl { display: grid; grid-template-columns: 170px 1fr; gap: 10px 18px; margin: 0; }
.dl dt { color: var(--mute); font-size: 14px; }
.dl dd { margin: 0; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.pay { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 6px; font-size: 14px; }
.pay .row { display: flex; gap: 10px; align-items: center; }
.pay .row span:first-child { color: var(--mute); min-width: 110px; }
.pay .row strong { font-family: var(--mono); }

/* Modal y avisos */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,18,38,.5); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px; z-index: 50; overflow: auto; }
.modal { width: 480px; max-width: 100%; background: #fff; border-radius: 20px; padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 14px; }
.modal h3 { font-size: 20px; }
.modal .btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--night); color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .2s; z-index: 60; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--coral); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 24px; }
  .auth-side ul { display: none; }
  .g3, .g2, .lic, .form-grid { grid-template-columns: 1fr; }
  .devices { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
  .top-in { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 8px; gap: 10px; }
  nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .who span { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .hero { padding: 24px; }
}
