:root {
  --bg: #0f1220;
  --bg2: #1a1f35;
  --bg3: #141829;
  --border: #2c3354;
  --text: #eceeff;
  --muted: #9aa3c7;
  --accent: #6366f1;
  --accent2: #818cf8;
  --accent-soft: #2a2f55;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}
.hidden { display: none !important; }

.logo { color: var(--accent2); }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; display: inline-flex; align-items: center; gap: 9px; }
.brand.small { font-size: 20px; gap: 7px; }
.logo-img { width: 1.05em; height: 1.05em; border-radius: 5px; display: block; }
.auth-card .brand { justify-content: center; }

/* Botones */
.btn {
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: #fff; background: var(--red); border-color: var(--red); }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Inputs */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
input:focus, select:focus { outline: none; border-color: var(--accent2); }
input:disabled { opacity: .7; }

.msg { min-height: 20px; font-size: 14px; margin: 14px 0 0; }
.msg.error { color: #fca5a5; }
.msg.ok { color: #86efac; }
.link { color: var(--accent2); cursor: pointer; font-size: 13px; text-decoration: underline; }
.center { text-align: center; }

/* Conexión */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 28px;
}
.auth-card .brand { text-align: center; }
.tagline { text-align: center; color: var(--muted); font-size: 14px; margin: 8px 0 6px; }
.email-locked { font-size: 13px; color: var(--muted); margin-top: 14px; }
.email-locked b { color: var(--text); }

/* Panel */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  position: sticky; top: 0; z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user { color: var(--muted); font-size: 14px; }
.container { max-width: 940px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; }

/* Lista de QR */
.qr-list { display: grid; gap: 16px; }
.qr-card {
  display: flex; gap: 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.qr-thumb {
  width: 96px; height: 96px; flex: none;
  background: #fff; border-radius: 10px; padding: 6px;
}
.qr-thumb img { width: 100%; height: 100%; display: block; }
.qr-info { flex: 1; min-width: 0; }
.qr-name { font-size: 17px; font-weight: 700; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.qr-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.qr-badge.on { background: rgba(34,197,94,.15); color: #86efac; }
.qr-badge.off { background: rgba(239,68,68,.15); color: #fca5a5; }
.qr-badge.wa { background: rgba(37,211,102,.18); color: #4ade80; }
.qr-badge.lock { background: rgba(99,102,241,.18); color: #a5b4fc; }
.qr-badge.exp { background: rgba(234,179,8,.16); color: #fde047; }

/* Selector de tipo (segmented) */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
  flex: 1 1 calc(50% - 4px); padding: 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer;
}
.seg-btn.active { background: var(--accent-soft); border-color: var(--accent2); color: var(--text); }

/* Selectores de color */
.color-row { display: flex; gap: 18px; align-items: center; }
.color-row span { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.color-row input[type=color] {
  width: 44px; height: 30px; padding: 0; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); cursor: pointer;
}
.qr-row { font-size: 13px; color: var(--muted); margin: 3px 0; word-break: break-all; }
.qr-row b { color: var(--text); font-weight: 600; }
.short-link { color: var(--accent2); }
.qr-stats { display: flex; gap: 18px; margin: 8px 0; }
.qr-stats .num { font-size: 20px; font-weight: 800; }
.qr-stats .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.qr-actions { margin-top: 10px; }

.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* Modal */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5,7,15,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  position: relative;
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px;
}
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--muted);
  font-size: 26px; cursor: pointer; line-height: 1;
}

/* Estadísticas */
.stat-total { display: flex; gap: 24px; margin: 4px 0 18px; }
.stat-total .num { font-size: 30px; font-weight: 800; }
.stat-total .lbl { font-size: 12px; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin: 8px 0 4px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.breakdown { margin-top: 16px; }
.breakdown h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); }
.bar-line { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; }
.bar-line .name { width: 90px; flex: none; }
.bar-line .track { flex: 1; background: var(--bg); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-line .fill { background: var(--accent2); height: 100%; }
.bar-line .val { width: 36px; text-align: right; color: var(--muted); }

.section-sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.qr-big { background: #fff; border-radius: 12px; padding: 14px; width: 220px; margin: 14px auto; }
.qr-big img { width: 100%; display: block; }

@media (max-width: 560px) {
  .qr-card { flex-direction: column; }
  .qr-thumb { width: 80px; height: 80px; }
}
