/* Cristal Orbital — estilos compartidos (página del cliente + panel admin) */
:root {
  --bg: #0b0d17;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-2: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef0ff;
  --muted: #b3b8d6;
  --dim: #8d93b5;
  --accent: #8b7bff;
  --accent-hover: #a193ff;
  --accent-ink: #0b0d17;
  --teal: #3ee0c5;
  --danger: #ff8fb1;
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 8%, rgba(139, 123, 255, 0.26), transparent 42%),
    radial-gradient(circle at 12% 92%, rgba(62, 224, 197, 0.14), transparent 38%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: #c9c2ff; }
a:hover { color: #fff; }
h1, h2, h3 { font-family: 'Sora', sans-serif; margin: 0; }

.rings::before, .rings::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  border: 1px solid rgba(201, 194, 255, 0.14);
  pointer-events: none;
  z-index: -1;
}
.rings::before { width: 560px; height: 560px; right: -160px; top: 60px; }
.rings::after { width: 400px; height: 400px; right: -80px; top: 140px; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.orb {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 24px var(--accent);
}

.logo { height: 38px; width: auto; max-width: 160px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.sidebar .logo { height: 30px; max-width: 120px; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.input {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  background: rgba(11, 13, 23, 0.6);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
textarea.input { padding: 12px 16px; min-height: 180px; resize: vertical; }
select.input option { background: #151827; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.25); }
.input::placeholder { color: var(--dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border-radius: 14px; border: 1px solid transparent;
  font: 700 14px 'Sora', sans-serif;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, transform 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: var(--glass); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--glass-2); color: #fff; }
.btn-danger { background: rgba(255, 143, 177, 0.14); border-color: rgba(255, 143, 177, 0.4); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 143, 177, 0.24); color: #ffd0de; }
.btn-sm { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn-block { width: 100%; min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.alert { padding: 12px 16px; border-radius: 14px; font-size: 14px; }
.alert-error { background: rgba(255, 143, 177, 0.12); border: 1px solid rgba(255, 143, 177, 0.4); color: #ffc2d4; }
.alert-ok { background: rgba(62, 224, 197, 0.1); border: 1px solid rgba(62, 224, 197, 0.4); color: #a8f3e6; }
.alert-info { background: rgba(139, 123, 255, 0.12); border: 1px solid rgba(139, 123, 255, 0.4); color: #d6d0ff; }

.badge { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--glass-2); font-size: 13px; white-space: nowrap; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Página del cliente ---------- */
.site { min-height: 100vh; display: flex; flex-direction: column; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 48px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; font-family: 'Sora', sans-serif; font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; }
.pills { display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); }
.pills a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; text-decoration: none; font-size: 14px; }
.pills a:hover { background: var(--glass-2); }
.pills a.wa { background: rgba(62, 224, 197, 0.16); color: var(--teal); }

.site-main { flex-grow: 1; display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 32px 16px 48px; }
.hero { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.hero h1 { font-weight: 300; font-size: clamp(34px, 6vw, 52px); letter-spacing: -1px; line-height: 1.1; }
.hero h1 strong { font-weight: 700; color: var(--accent); }
.hero p { margin: 0; color: var(--muted); font-size: 17px; }

.code-card { width: 100%; max-width: 580px; padding: 32px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
fieldset.plain { margin: 0; padding: 0; border: none; }
fieldset.plain legend { padding: 0; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 0 10px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  color: #cfd3ee; font-weight: 600; font-size: 14px; cursor: pointer;
}
.chip span:hover { background: var(--glass-2); }
.chip input:checked + span { background: rgba(139, 123, 255, 0.22); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.result { width: 100%; max-width: 860px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-head h2 { font-size: 18px; font-weight: 500; }
.result-frame { width: 100%; height: 62vh; min-height: 420px; border: none; border-radius: 16px; background: #fff; }

.site-footer { padding: 20px; text-align: center; font-size: 13px; color: var(--dim); }

.loading .btn-block { opacity: 0.7; pointer-events: none; }

/* ---------- Login del panel ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; padding: 36px 32px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.login-card .brand { justify-content: center; }
.login-card h1 { text-align: center; font-weight: 500; font-size: 24px; }

/* ---------- Panel admin ---------- */
.admin { display: flex; gap: 20px; padding: 20px; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; position: sticky; top: 20px; height: calc(100vh - 40px); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.sidebar .brand { font-size: 17px; padding: 0 8px; }
.sidebar .orb { width: 28px; height: 28px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: 12px; text-decoration: none; color: #cfd3ee; font-size: 15px; }
.nav a:hover { background: var(--glass); color: #fff; }
.nav a.active { background: rgba(139, 123, 255, 0.25); color: #fff; }
.nav svg { flex-shrink: 0; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(62, 224, 197, 0.25); color: var(--teal); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.me-info { display: flex; flex-direction: column; min-width: 0; }
.me-info span { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.me-info a { font-size: 13px; text-decoration: none; }

.admin-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; padding: 8px 8px 24px 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-weight: 500; font-size: 28px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 20px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.stat span { font-size: 13px; color: var(--muted); }
.stat strong { font-family: 'Sora', sans-serif; font-size: 32px; font-weight: 700; }
.stat.hl { background: rgba(62, 224, 197, 0.12); border-color: rgba(62, 224, 197, 0.35); }
.stat.hl span { color: #a8f3e6; }
.stat.hl strong { color: var(--teal); }

.panel { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-weight: 500; font-size: 18px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .input { min-height: 42px; width: auto; min-width: 200px; }
.cols-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); padding: 10px 12px; }
.tbl td { padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); vertical-align: middle; }
.tbl tr:hover td { background: rgba(255, 255, 255, 0.03); }
.tbl .actions { display: flex; gap: 8px; justify-content: flex-end; }
.tbl input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.mail-cell { display: flex; align-items: center; gap: 12px; }
.initial { width: 32px; height: 32px; border-radius: 10px; background: rgba(139, 123, 255, 0.2); color: #c9c2ff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.code { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 14px; color: #d6d0ff; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.feed { display: flex; flex-direction: column; }
.feed-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 14px; }
.feed-row:first-child { border-top: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.dot.ok { background: var(--teal); }
.dot.bad { background: var(--danger); }
.dot.none { background: #ffd26b; }

.form-card { max-width: 620px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.form-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

dialog.modal { width: min(480px, calc(100vw - 32px)); padding: 28px; border-radius: 24px; border: 1px solid var(--line); background: #151827; color: var(--text); }
dialog.modal::backdrop { background: rgba(5, 6, 12, 0.7); backdrop-filter: blur(4px); }
dialog.modal form { display: flex; flex-direction: column; gap: 16px; }
dialog.modal h2 { font-weight: 500; font-size: 20px; }

.toast-box { position: fixed; top: 20px; right: 20px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { padding: 14px 18px; border-radius: 14px; font-size: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); transition: opacity 0.3s; }

/* ---------- Móvil ---------- */
@media (max-width: 960px) {
  .admin { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; gap: 12px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .me { margin-top: 0; }
  .admin-main { padding: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .site-header { padding: 16px; justify-content: center; }
  .code-card { padding: 22px 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result { padding: 16px; }
  .page-head h1 { font-size: 22px; }
  .rings::before, .rings::after { display: none; }
}
