:root {
  --bg: #0a0b10;
  --card: #14161f;
  --card-2: #1b1e2b;
  --line: #262a3a;
  --text: #e8eaf2;
  --muted: #9aa0b5;
  --brand: #6c5ce7;
  --brand-2: #00d2a8;
  --danger: #ff5c7a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  position: relative;
  overflow-x: hidden;
}
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(600px 400px at 80% -5%, rgba(108,92,231,.25), transparent 60%),
    radial-gradient(500px 400px at 0% 100%, rgba(0,210,168,.18), transparent 60%);
}
.nav, .hero, .dash, .footer { position: relative; z-index: 1; }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 6vw; max-width: 1200px; margin: 0 auto;
}
.logo { font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; letter-spacing: .3px; }
.logo-mark { color: var(--brand-2); }
nav { display: flex; gap: 10px; align-items: center; }

.btn, .btn-ghost {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  padding: 10px 18px; text-decoration: none; border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
}
.btn {
  background: linear-gradient(135deg, var(--brand), #8b7bff);
  color: #fff; box-shadow: 0 8px 24px rgba(108,92,231,.35);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(108,92,231,.5); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--brand); }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 8px; }
.btn-big { padding: 16px; font-size: 1.05rem; }

.hero {
  max-width: 1200px; margin: 0 auto; padding: 5vh 6vw 8vh;
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; align-items: center;
}
.pill {
  display: inline-block; font-size: .8rem; font-weight: 600;
  color: var(--brand-2); background: rgba(0,210,168,.1);
  border: 1px solid rgba(0,210,168,.25); padding: 6px 14px; border-radius: 999px;
}
.pill-green { color: var(--brand-2); }
.hero-copy h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.1; margin: 18px 0; font-weight: 800; }
.grad { background: linear-gradient(135deg, var(--brand-2), var(--brand)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 1.15rem; max-width: 520px; }

.specs { list-style: none; display: flex; gap: 14px; margin: 28px 0; }
.specs li {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 20px; text-align: center; flex: 1;
}
.specs strong { display: block; font-size: 1.25rem; color: var(--text); }
.specs span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.bullets { list-style: none; color: var(--muted); display: grid; gap: 6px; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line); border-radius: 18px; padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
}
.auth { width: 100%; max-width: 420px; justify-self: end; }
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 5px; border-radius: 12px; margin-bottom: 22px; }
.tab { flex: 1; text-align: center; padding: 9px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tab.active { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 var(--line); }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
input {
  font: inherit; padding: 12px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
}
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108,92,231,.2); }
.hint { font-size: .8rem; color: var(--muted); text-align: center; }

.alert {
  background: rgba(255,92,122,.12); border: 1px solid rgba(255,92,122,.3);
  color: #ffb3c1; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem;
}

.dash { max-width: 720px; margin: 0 auto; padding: 6vh 6vw; }
.dash h1 { font-size: 2rem; margin-bottom: 24px; }
.dash .card h2 { margin-bottom: 10px; }
.dash .card p { color: var(--muted); margin-bottom: 18px; }
.server-specs { display: flex; gap: 22px; margin: 18px 0; color: var(--muted); }
.server-specs strong { color: var(--text); }
.server-ok { border-color: rgba(0,210,168,.3); }

.footer { text-align: center; color: var(--muted); padding: 40px 6vw; font-size: .85rem; border-top: 1px solid var(--line); margin-top: 40px; }

.alert-ok {
  background: rgba(0,210,168,.12); border-color: rgba(0,210,168,.35); color: #8ff0d8;
}

.conn { display: grid; gap: 10px; margin: 18px 0; }
.conn-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.conn-label { color: var(--muted); font-size: .85rem; }
.conn-val { color: var(--text); font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: .95rem; background: transparent; }

select {
  font: inherit; padding: 12px 14px; border-radius: 10px; width: 100%;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108,92,231,.2); }

.fork-box { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.fork-box summary { cursor: pointer; font-weight: 600; color: var(--text); }
.fork-form { display: flex; gap: 10px; align-items: stretch; margin-top: 10px; }
.fork-form select { flex: 1; }
.fork-form .btn { white-space: nowrap; }

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 36px; }
  .auth { justify-self: stretch; max-width: none; }
}

/* ---- Tickets / Soporte ---- */
textarea {
  font: inherit; padding: 12px 14px; border-radius: 10px; width: 100%; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
}
textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108,92,231,.2); }

.back-link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back-link:hover { color: var(--text); }

.ticket-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.ticket-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.ticket-list a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); flex: 1; }
.ticket-subject { font-weight: 600; }
.ticket-date { color: var(--muted); font-size: .8rem; white-space: nowrap; }

.ticket-status { font-size: .75rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.status-open { background: rgba(255,92,122,.15); color: #ff8aa0; }
.status-answered { background: rgba(0,210,168,.15); color: var(--brand-2); }
.status-closed { background: rgba(154,160,181,.15); color: var(--muted); }

/* ---- Chat ---- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); }
.msg-head { font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.msg-user { align-self: flex-end; background: rgba(108,92,231,.14); }
.msg-admin { align-self: flex-start; background: var(--card-2); }

/* ---- Admin ---- */
.admin-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.chip { text-decoration: none; font-size: .82rem; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg); }
.chip-on { color: var(--text); border-color: var(--brand); background: rgba(108,92,231,.14); }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table tbody tr { cursor: pointer; }
.admin-table tbody tr:hover { background: var(--bg); }

.admin-cols { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.info-panel h3 { margin: 4px 0 10px; font-size: .95rem; }
.info-panel h3:not(:first-child) { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.info-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: .85rem; }
.info-row span { color: var(--muted); }
.info-row code { color: var(--text); font-size: .82rem; word-break: break-all; text-align: right; }

@media (max-width: 880px) {
  .admin-cols { grid-template-columns: 1fr; }
}

/* ---- Mejoras de layout admin/ticket ---- */
.dash-wide { max-width: 1180px; }
.dash > section, .dash > .card { margin-bottom: 20px; }
.card-title { font-size: 1rem; margin: 0 0 14px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-title-row .card-title { margin: 0; }

.ticket-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin: 10px 0 22px; flex-wrap: wrap; }
.ticket-header h1 { margin: 0; font-size: 1.6rem; }

.admin-cols { grid-template-columns: 1fr 360px; gap: 22px; }
.admin-side { display: grid; gap: 20px; align-content: start; }
.admin-side .card { margin: 0; }

/* Chat con más aire */
.chat { padding: 4px 0 6px; min-height: 120px; max-height: 460px; overflow-y: auto; }
.msg { max-width: 88%; padding: 12px 16px; }
.reply-form { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Botones auxiliares */
.btn-mini { font: inherit; font-size: .78rem; padding: 5px 10px; border-radius: 8px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.btn-mini:hover { color: var(--text); border-color: var(--brand); }
.btn-mini:disabled { opacity: .5; cursor: default; }

/* Diagnóstico */
.diag-state { font-weight: 700; font-size: .9rem; margin-bottom: 12px; }
.diag-running { color: var(--brand-2); }
.diag-offline { color: var(--muted); }
.diag-starting, .diag-stopping { color: #ffcc66; }
.diag-err { color: #ff8aa0; font-size: .85rem; }
.diag-metric { margin: 12px 0; }
.diag-metric-top { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 5px; }
.diag-bar { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.diag-bar i { display: block; height: 100%; background: var(--brand); }
.diag-bar i.bar-warn { background: #ffcc66; }
.diag-bar i.bar-hot { background: var(--danger); }

/* Controles de energía */
.power-row { display: flex; gap: 8px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.power-row form { flex: 1; margin: 0; }
.btn-power { width: 100%; font: inherit; font-size: .82rem; font-weight: 600; padding: 9px 6px; border-radius: 9px;
  cursor: pointer; border: 1px solid var(--line); color: var(--text); background: var(--bg); }
.btn-power-start:hover { border-color: var(--brand-2); color: var(--brand-2); }
.btn-power-restart:hover { border-color: #ffcc66; color: #ffcc66; }
.btn-power-stop:hover { border-color: var(--danger); color: var(--danger); }

/* Visor de logs */
.logbox { background: #06070b; border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: .76rem; line-height: 1.5;
  color: #c5cad8; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow-y: auto; margin: 0; }

@media (max-width: 980px) {
  .admin-cols { grid-template-columns: 1fr; }
}

/* ---- Soporte usuario: tarjetas de ticket mejoradas ---- */
.open-counter { font-size: .8rem; font-weight: 600; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; white-space: nowrap; }

.ticket-list li { display: block; padding: 0; background: transparent; border: 0; }
.ticket-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; transition: border-color .15s; }
.ticket-card:hover { border-color: var(--brand); }
.ticket-card-main { display: flex; align-items: center; gap: 10px; }
.ticket-card-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }

.ticket-id { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-weight: 700;
  color: var(--brand-2); background: rgba(0,210,168,.1); padding: 2px 8px; border-radius: 7px; font-size: .85rem; }
.ticket-id-lg { font-size: 1.1rem; padding: 3px 10px; }
.ticket-subject { font-weight: 600; font-size: 1rem; }
.ticket-flag { font-weight: 600; }
