:root {
  --bg: #0b0f1a;
  --bg-glow-1: #22d3ee;
  --bg-glow-2: #a78bfa;
  --surface: #131826;
  --surface-2: #1a2030;
  --border: #262d40;
  --text: #e8ecf7;
  --text-dim: #94a1c4;
  --accent: #22d3ee;
  --accent-2: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.5);
  --radius: 16px;
}

[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-glow-1: #22d3ee;
  --bg-glow-2: #a78bfa;
  --surface: #ffffff;
  --surface-2: #f7f8fd;
  --border: #e2e6f2;
  --text: #1a2030;
  --text-dim: #5b6484;
  --accent: #0ea5c7;
  --accent-2: #7c5cd6;
  --ok: #0ea86a;
  --warn: #b4790a;
  --bad: #d6395a;
  --shadow: 0 10px 30px -14px rgba(30,40,80,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  transition: background .35s ease, color .35s ease;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px circle at 10% -10%, color-mix(in srgb, var(--bg-glow-1) 18%, transparent), transparent 60%),
    radial-gradient(700px circle at 100% 0%, color-mix(in srgb, var(--bg-glow-2) 14%, transparent), transparent 60%);
  transition: background .35s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}
.brand h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .2px; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.hostname { font-size: 12px; color: var(--text-dim); font-family: 'Cascadia Code', monospace; }
.updated { font-size: 12px; color: var(--text-dim); }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text);
  transition: transform .2s ease, background .3s ease, border-color .3s ease;
}
.theme-toggle:hover { transform: scale(1.08); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  animation: rise .5s ease forwards;
  transition: border-color .3s ease, background .35s ease, transform .2s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card { min-width: 0; }
.card.wide { grid-column: span 2; }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; margin: 0; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); font-weight: 700; }

.prose p { margin: 0 0 8px; line-height: 1.55; font-size: 13.5px; color: var(--text); }
.prose p:last-child { margin-bottom: 0; }
.prose ul { margin: 0 0 8px; padding-left: 18px; }
.prose li { margin-bottom: 6px; line-height: 1.5; font-size: 13.5px; }
.prose code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.prose b { color: var(--accent-2); }

.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.status-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 70%, transparent); animation: pulse 2.4s ease-in-out infinite; }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px color-mix(in srgb, var(--bad) 70%, transparent); }
.dot.off { background: var(--text-dim); }
.status-row .label { flex: 1; font-size: 13.5px; }
.status-row .meta { font-size: 11.5px; color: var(--text-dim); font-family: 'Cascadia Code', monospace; }

.meters { display: flex; flex-direction: column; gap: 14px; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-label { width: 46px; font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.meter-track { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.meter-fill { display: block; min-width: 4px; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease; }
.meter-val { width: 42px; text-align: right; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.uptime { margin-top: 14px; font-size: 12px; color: var(--text-dim); }

.proyectos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.proyecto-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  transition: transform .18s ease, border-color .2s ease;
}
.proyecto-item:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.proyecto-item .pname { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.proyecto-item .psummary { font-size: 12px; color: var(--text-dim); line-height: 1.4; }

.meter-fill.warn { background: linear-gradient(90deg, var(--warn), var(--accent-2)); }
.meter-fill.bad { background: linear-gradient(90deg, var(--bad), var(--warn)); }
.dim { color: var(--text-dim); font-size: 11.5px; }

.cuentas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cuenta { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; transition: transform .18s ease, border-color .2s ease; }
.cuenta:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.cuenta.err { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.cuenta-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.cuenta-val { font-size: 22px; font-weight: 700; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cbar-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; color: var(--text-dim); }
.cbar-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.cbar .meter-track { display: block; }

.sitios-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.sitio-link { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-decoration: none; transition: transform .18s ease, border-color .2s ease, background .2s ease; }
.sitio-link:hover, .sitio-link:active { transform: translateX(3px); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.sitio-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sitio-txt b { font-size: 14px; }
.sitio-txt small { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitio-go { width: 18px; height: 18px; color: var(--accent); transition: transform .18s ease; }
.sitio-go svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sitio-link:hover .sitio-go { transform: translate(2px, -2px); }

a.cuenta { color: var(--text); text-decoration: none; cursor: pointer; }
a.cuenta:hover, a.cuenta:active { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 8px 22px -12px color-mix(in srgb, var(--accent) 55%, transparent); }
a.cuenta:active { transform: translateY(0) scale(.985); }
.cuenta .sitio-go { margin-left: 6px; opacity: .55; transition: opacity .2s, transform .18s; }
a.cuenta:hover .sitio-go { opacity: 1; transform: translate(2px, -2px); }
.mini { font-size: 11.5px; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.mini .sitio-go { width: 13px; height: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 12px; border: 1px solid transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06101c; font-weight: 600; font-size: 13.5px; font-family: inherit; text-decoration: none; cursor: pointer; transition: transform .18s ease, filter .2s ease, opacity .2s; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.disabled { background: var(--surface-2); color: var(--text-dim); border: 1px dashed var(--border); cursor: default; pointer-events: none; }

.agente-btn { color: var(--text); text-decoration: none; cursor: pointer; transition: transform .18s ease, border-color .2s ease, background .2s ease; }
.agente-btn:hover, .agente-btn:active { transform: translateX(3px); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.agente-btn:active { transform: scale(.985); }
.chev { width: 16px; height: 16px; color: var(--accent); }
.chev svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.detalle { max-width: 760px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; animation: slide .35s ease both; }
.detalle[hidden], .grid[hidden], .modal[hidden] { display: none; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 600; width: fit-content; transition: transform .18s; }
.back:hover { transform: translateX(-3px); }
.back svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#agenteBody { display: flex; flex-direction: column; gap: 16px; }
.ag-head { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.ag-title { display: flex; align-items: center; gap: 10px; }
.ag-title h2 { margin: 0; font-size: 18px; }
.ag-estado { font-size: 28px; font-weight: 700; }
.ag-estado.ok { color: var(--ok); } .ag-estado.bad { color: var(--bad); } .ag-estado.off { color: var(--text-dim); }
.ag-hechos { display: flex; gap: 22px; flex-wrap: wrap; }
.ag-hechos div { display: flex; flex-direction: column; gap: 2px; }
.lista { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.5; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5,8,16,.6); backdrop-filter: blur(6px); animation: fade .25s ease both; }
.modal-box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; animation: pop .3s cubic-bezier(.2,.9,.3,1.2) both; }
.modal-box h3 { margin: 0; font-size: 16px; }
.code { font: 700 30px 'Cascadia Code', monospace; letter-spacing: 3px; text-align: center; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--accent); color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.login-ok { font-size: 20px; font-weight: 700; color: var(--ok); }
.pulso { animation: pulse 1.6s ease-in-out infinite; }

@keyframes slide { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 14px; }
  .card.wide { grid-column: span 1; }
  .topbar { padding: 14px 16px; }
  .detalle { padding: 14px; }
  .hostname { display: none; }
}
