:root {
  --bg: #070b16;
  --panel: #0d1324;
  --panel2: #111a30;
  --line: #202b46;
  --text: #f4f7ff;
  --muted: #8f9ab5;
  --blue: #4f7cff;
  --violet: #845cff;
  --cyan: #31d4c3;
  --green: #36d399;
  --amber: #f8b84e;
  --red: #ff6376;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; 
  min-height: 100%;
  background: radial-gradient(circle at 80% 0, #111a3b 0, transparent 34%), var(--bg);
  color: var(--text); 
  font-family: Inter, system-ui, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ========================================================
   1. PÁGINA DE LOGIN Y AUTENTICACIÓN (REPARADA)
======================================================== */
.login-body, .install-body { 
  min-height: 100vh; 
  display: grid; 
  place-items: center; 
  padding: 30px; 
}

.login-shell { 
  width: min(980px, 100%); 
  display: grid; 
  grid-template-columns: 1.15fr 0.85fr; 
  border: 1px solid #253150; 
  border-radius: 26px; 
  overflow: hidden; 
  background: #0a1020; 
  box-shadow: 0 40px 100px rgba(0,0,0,0.45); 
}

.login-brand { 
  padding: 58px; 
  background: radial-gradient(circle at 20% 10%, rgba(79,124,255,0.22), transparent 36%), linear-gradient(145deg, #0e1730, #17143a); 
  display: flex; 
  align-items: center; 
  gap: 22px; 
}

.login-brand h1, .install-logo h1 { font-size: 42px; margin: 6px 0; }
.login-brand p { color: #a1acc8; line-height: 1.6; max-width: 420px; }

.login-card { 
  padding: 50px 44px; 
  background: #0a1020;
}

.login-card h2 { font-size: 28px; margin: 30px 0 5px; color: #fff; }

.login-card form { 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
  margin-top: 24px; 
}

.login-card label { 
  font-size: 11px; 
  color: #a4aec7; 
  font-weight: 700; 
  margin-top: 5px; 
}

.login-card input { 
  background: #080e1c; 
  border: 1px solid #263151; 
  color: #fff; 
  border-radius: 11px; 
  padding: 13px; 
  width: 100%;
  outline: none;
}

.login-card input:focus {
  border-color: var(--blue);
}

.login-foot { text-align: center; color: #58647f; font-size: 10px; margin-top: 20px; }
.mobile-brand { display: none; }


/* ========================================================
   2. LAYOUT PRINCIPAL DEL PANEL
======================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; 
  background: rgba(9,14,28,.96); 
  border-right: 1px solid var(--line);
  padding: 18px 14px; 
  position: fixed; 
  inset: 0 auto 0 0; 
  display: flex; 
  flex-direction: column; 
  z-index: 20; 
  overflow-y: auto;
}

.logo { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 18px; padding: 4px 8px 16px; }
.logo b, .login-brand h1 span, .install-logo h1 span { color: #8f74ff; }

.brand-mark {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px;
  background: linear-gradient(135deg, var(--blue), var(--violet)); box-shadow: 0 12px 30px rgba(95,79,255,.35);
  font-weight: 800; font-size: 28px; color: #fff;
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 12px; font-size: 16px; }

.sidebar nav { display: grid; gap: 4px; flex-shrink: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #9da8c3; font-weight: 600; font-size: 13px; }
.nav-item:hover { background: #111b31; color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(79,124,255,.2), rgba(132,92,255,.12)); color: #fff; border: 1px solid rgba(110,111,255,.28); }
.nav-icon { width: 22px; text-align: center; font-size: 16px; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 6px 4px; flex-shrink: 0; }
.mini-user { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.mini-user div:last-child { min-width: 0; }
.mini-user strong, .mini-user small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-user small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: #1d2946; color: #cbd7ff; font-weight: 800; }
.avatar.big { width: 42px; height: 42px; border: 1px solid #2a395e; }

.link-btn { background: none; border: 0; color: #ff8c9a; padding: 5px 0; font-weight: 700; font-size: 12px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.main { margin-left: 260px; min-width: 0; flex: 1; }

.topbar { 
  height: 88px; display: flex; align-items: center; justify-content: space-between; 
  padding: 0 34px; border-bottom: 1px solid rgba(32,43,70,.7); background: rgba(7,11,22,.65); 
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; 
}

.topbar > div:first-of-type { flex: 1; }
.topbar h1 { margin: 2px 0 0; font-size: 22px; }
.eyebrow { font-size: 10px; letter-spacing: .18em; font-weight: 800; color: #7180a4; }

.top-actions { display: flex; align-items: center; gap: 12px; }
.credit-chip { display: flex; gap: 12px; align-items: center; background: #10182a; border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; }
.credit-chip span { font-size: 11px; color: var(--muted); }
.credit-chip strong { font-size: 14px; color: #fff; }
.menu-btn { display: none; background: #111b31; border: 1px solid var(--line); color: #fff; border-radius: 10px; width: 40px; height: 40px; }


/* ========================================================
   3. CONTENEDOR REDUCIDO (Ancho Elegante)
======================================================== */
.content { padding: 28px 34px 60px; width: 100%; max-width: 1310px; margin-left: auto; margin-right: auto; }
.footer { padding: 0 34px 24px; color: #5f6b89; font-size: 12px; width: 100%; max-width: 1310px; margin-left: auto; margin-right: auto; }


/* ========================================================
   4. COMPONENTES Y ELEMENTOS
======================================================== */
.hero { display: flex; justify-content: space-between; align-items: center; padding: 26px 28px; border: 1px solid #283254; border-radius: 22px; background: linear-gradient(120deg, rgba(79,124,255,.13), rgba(132,92,255,.12) 45%, rgba(13,19,36,.8)); box-shadow: var(--shadow); margin-bottom: 22px; }
.hero h2 { font-size: 28px; margin: 5px 0 6px; }
.hero p { margin: 0; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; padding: 19px; }
.stat-card small, .stat-card strong { display: block; }
.stat-card small { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.stat-card strong { font-size: 24px; }
.stat-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 13px; background: rgba(132,92,255,.15); color: #a992ff; font-size: 20px; }
.stat-icon.amber { background: rgba(248,184,78,.13); color: var(--amber); }
.stat-icon.blue { background: rgba(79,124,255,.14); color: #7ea0ff; }
.stat-icon.green { background: rgba(54,211,153,.13); color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.card { background: linear-gradient(180deg, rgba(14,21,39,.96), rgba(11,17,32,.96)); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 10px 35px rgba(0,0,0,.16); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 18px; }
.card-head.wrap { flex-wrap: wrap; }
.card h3, .card-head h3 { margin: 0 0 5px; font-size: 17px; }
.card p, .card-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.text-link { font-size: 12px; color: #97adff; font-weight: 700; }

.table-wrap { overflow: auto; margin: 0 -8px; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table-wrap th { text-align: left; color: #6f7b98; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table-wrap td { padding: 13px 12px; border-bottom: 1px solid rgba(32,43,70,.7); font-size: 12px; vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td strong, .table-wrap td small { display: block; }
.table-wrap td small { font-size: 10px; color: var(--muted); margin-top: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.success { background: rgba(54,211,153,.12); color: #66e4b4; }
.badge.warning { background: rgba(248,184,78,.13); color: #ffc966; }
.badge.info { background: rgba(79,124,255,.14); color: #8aa8ff; }
.badge.danger { background: rgba(255,99,118,.14); color: #ff8c9a; }
.badge.muted { background: #182033; color: #8c97b1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 11px 16px; font-weight: 700; font-size: 13px; color: #fff; }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--violet)); box-shadow: 0 9px 24px rgba(82,86,255,.24); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.large { padding: 14px 18px; font-size: 14px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.tiny-btn { background: #15203a; border: 1px solid #2a385d; color: #aebadd; border-radius: 8px; padding: 5px 8px; font-size: 9px; }
.tiny-btn.danger { color: #ff9aa5; border-color: #60313b; background: #24141c; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: grid; gap: 7px; }
.span-2 { grid-column: span 2; }
.field label { font-size: 11px; font-weight: 700; color: #a5afc8; }
.field small { color: #65718e; font-size: 10px; }
.field input, .field select, .field textarea { width: 100%; background: #090f1f; border: 1px solid #263150; color: #f6f8ff; border-radius: 11px; padding: 12px 13px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #5d7dff; box-shadow: 0 0 0 3px rgba(79,124,255,.10); }
.field textarea { resize: vertical; }
.mac-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px !important; letter-spacing: .08em; }

.cost-box { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: #0a1121; border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.cost-box div { display: flex; justify-content: space-between; gap: 10px; }
.cost-box span { font-size: 11px; color: var(--muted); }
.cost-box strong { font-size: 12px; }

.alert { border-radius: 11px; padding: 11px 13px; margin-bottom: 14px; font-size: 12px; }
.alert.success { background: rgba(54,211,153,.1); border: 1px solid rgba(54,211,153,.24); color: #80e7bd; }
.alert.error { background: rgba(255,99,118,.1); border: 1px solid rgba(255,99,118,.24); color: #ff98a4; }
.alert.info { background: rgba(79,124,255,.1); border: 1px solid rgba(79,124,255,.22); color: #a4b8ff; }
.empty { text-align: center !important; color: #65708c !important; padding: 30px !important; }
.subtle { color: var(--muted) !important; }
.error-text { color: #ff8d9a !important; }


/* ========================================================
   5. RESPONSIVE
======================================================== */
@media(max-width:1100px){
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media(max-width:760px){
  .sidebar { transform: translateX(-100%); transition: .22s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { height: 76px; padding: 0 16px; gap: 12px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 18px; }
  .credit-chip span { display: none; }
  .content { padding: 18px 14px 45px; }
  
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { padding: 32px 24px; }
  .mobile-brand { display: flex; align-items: center; gap: 10px; }
  
  .hero { padding: 20px; align-items: flex-start; gap: 18px; flex-direction: column; }
  .hero h2 { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

@media(max-width:430px){
  .stats-grid { grid-template-columns: 1fr; }
  .top-actions .avatar { display: none; }
}