:root {
  --bg: #0b0d12;
  --bg-elev: #14171f;
  --bg-elev-2: #1b1f2a;
  --border: #242938;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --primary: #6c8cff;
  --primary-strong: #4f72ff;
  --danger: #ff5d6a;
  --success: #3ddc97;
  --warn: #ffb44d;
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.error { color: var(--danger); margin-top: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-right {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.brand.small h2 { margin: 0; font-size: 18px; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: -0.5px; }

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--primary) 0%, #b388ff 100%);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  background: var(--bg);
  border-radius: 3px;
  background-image:
    linear-gradient(var(--text) 2px, transparent 2px),
    linear-gradient(90deg, var(--text) 2px, transparent 2px);
  background-size: 4px 4px;
  background-position: 0 0;
}

.brand.small .brand-mark {
  width: 22px;
  height: 22px;
}

/* ============ CONTAINERS ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.container h2 { margin-top: 0; }

/* ============ LOGIN ============ */
.view-login {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card .brand {
  justify-content: center;
  margin-bottom: 4px;
  cursor: default;
}
.login-card form {
  margin-top: 24px;
  text-align: left;
}

/* Botón oficial Hubmy — estilo de la documentación
   https://dev.hubmy.app/es/docs/login */
.hubmy-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #ffffff;
  color: #1c1c1c;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin-top: 24px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.hubmy-login-btn:hover {
  background: #f5f5f5;
  border-color: #c8c8c8;
  text-decoration: none;
}
.hubmy-login-btn:active {
  transform: scale(0.98);
}
.hubmy-login-btn img {
  height: 20px;
  width: auto;
  display: block;
}

/* ============ CARD ============ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 { margin-top: 0; }

/* ============ FORM ============ */
label {
  display: block;
  margin-bottom: 14px;
}
label span {
  display: block;
  font-size: 0.85em;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus {
  border-color: var(--primary);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #232838; }
.btn:active { transform: scale(0.98); }

.btn.primary {
  background: var(--primary);
  color: white;
}
.btn.primary:hover { background: var(--primary-strong); }

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255,93,106,0.3);
}
.btn.danger:hover { background: rgba(255,93,106,0.1); }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.btn.ghost:hover { background: var(--bg-elev-2); }

.btn.xs {
  padding: 3px 9px;
  font-size: 12px;
}

.back { margin-bottom: 16px; }

/* ============ LIST GRID ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.qr-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.08s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qr-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.qr-card .title {
  font-weight: 600;
  font-size: 16px;
}
.qr-card .target {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qr-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.qr-card .clicks {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.qr-card .clicks-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============ DETAIL ============ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.detail-grid .span-2 { grid-column: span 2; }

@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .span-2 { grid-column: span 1; }
}

.qr-preview {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 14px 0;
  display: flex;
  justify-content: center;
}
.qr-preview img {
  max-width: 220px;
  width: 100%;
  height: auto;
  display: block;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pill.active { background: rgba(61,220,151,0.18); color: var(--success); }
.pill.inactive { background: rgba(255,93,106,0.18); color: var(--danger); }

/* ============ BARS LIST ============ */
.bars {
  list-style: none;
  padding: 0;
  margin: 0;
}
.bars li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.bars li:last-child { border-bottom: none; }
.bars li .bar-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bars li .bar-count {
  font-weight: 600;
  color: var(--primary);
}

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.modal-card h3 { margin-top: 0; }
