:root {
  --bg: #080A0F;
  --bg-2: #0E1118;
  --bg-3: #141823;
  --line: #1E2330;
  --line-2: #2A3144;
  --text: #E8ECF2;
  --text-dim: #8B93A7;
  --text-mute: #5A6178;
  --green: #00E5A0;
  --green-dim: rgba(0, 229, 160, 0.12);
  --blue: #0066FF;
  --blue-dim: rgba(0, 102, 255, 0.14);
  --red: #FF4858;
  --yellow: #FFB547;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(0, 229, 160, 0.06), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0, 102, 255, 0.08), transparent 45%),
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
}

button { cursor: pointer; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}
label { display: block; margin-bottom: 16px; }
label > span {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.view { display: none; min-height: 100vh; position: relative; z-index: 1; }
.view.active { display: flex; }
.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────────────── */
#login-view { align-items: center; justify-content: center; }
.login-card {
  width: 420px; max-width: calc(100vw - 32px);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(0, 229, 160, 0.08);
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--green); color: #002016;
  border-radius: 10px;
  font-size: 20px;
}
.logo h1, .logo h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 30px;
  color: var(--text);
}
.logo.small h2 { font-size: 22px; }
.tagline {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 28px;
  letter-spacing: .04em;
}

.btn-primary {
  width: 100%;
  background: var(--green);
  color: #002016;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .01em;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn-primary:hover { background: #20F2B0; box-shadow: 0 6px 18px var(--green-dim); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--line-2); color: var(--text); }

.login-error {
  margin-top: 12px;
  color: var(--red);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  min-height: 16px;
}

/* ── App shell ─────────────────────────────────────────────── */
#app-view { display: none; }
#app-view.active { display: flex; }

.sidebar {
  width: 240px;
  border-right: 1px solid var(--line);
  background: rgba(8, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  padding: 24px 18px;
  display: flex; flex-direction: column; gap: 24px;
  min-height: 100vh;
  position: sticky; top: 0;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-link .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--line-2);
}
.nav-link:hover { background: var(--bg-2); color: var(--text); }
.nav-link.active {
  background: var(--green-dim);
  color: var(--green);
}
.nav-link.active .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
}
.user-name { font-size: 13px; color: var(--text); font-weight: 600; }
.user-role {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.content {
  flex: 1;
  padding: 40px 48px;
  max-width: 1200px;
}

.route-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.route-header h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -.02em;
}
.badge {
  display: inline-flex;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid rgba(0, 229, 160, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.blue { color: var(--blue); background: var(--blue-dim); border-color: rgba(0, 102, 255, 0.3); }

/* metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.metric {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
}
.metric-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.metric-value {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 32px;
  letter-spacing: -.02em;
  margin-top: 6px;
}
.metric-value.green { color: var(--green); }
.metric-value.blue { color: var(--blue); }

/* cards */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 18px;
}
.subtle {
  color: var(--text-mute);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: .06em;
}

/* tenants list */
.tenants-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.tenant-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-2);
  align-items: center;
  font-size: 14px;
}
.tenant-row.head {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.pill.activo { color: var(--green); background: var(--green-dim); }
.pill.pausado { color: var(--yellow); background: rgba(255, 181, 71, 0.12); }
.pill.cancelado { color: var(--red); background: rgba(255, 72, 88, 0.12); }

/* nodes grid */
.nodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.node-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s;
}
.node-card:hover { border-color: var(--line-2); }
.node-card h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 18px;
}
.node-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.node-meta .tag {
  border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px;
}
.qr-thumb {
  background: white;
  padding: 12px;
  border-radius: 10px;
  align-self: flex-start;
}
.qr-thumb img { display: block; width: 120px; height: 120px; }
.node-actions { display: flex; gap: 8px; margin-top: auto; }
.node-actions a, .node-actions button {
  flex: 1;
  font-size: 12px;
  text-align: center;
  text-decoration: none;
}

/* builder */
.builder-card { max-width: 720px; }
.stepper {
  display: flex; gap: 6px;
  list-style: none;
  margin-bottom: 24px;
}
.stepper li {
  flex: 1;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 8px;
  border-bottom: 2px solid var(--line);
  transition: color .2s, border-color .2s;
}
.stepper li.active { color: var(--green); border-color: var(--green); }
.stepper li.done { color: var(--text-dim); border-color: var(--text-dim); }

.builder-step { display: none; }
.builder-step.active { display: block; }
.hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 4px;
}
.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.radio {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  margin-bottom: 0;
  transition: border-color .15s, background .15s;
}
.radio input { position: absolute; opacity: 0; }
.radio span {
  display: block;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}
.radio em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-mute);
}
.radio:has(input:checked) {
  border-color: var(--green);
  background: var(--green-dim);
}

.builder-actions {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.builder-actions .btn-primary { width: auto; min-width: 140px; }

.builder-result {
  margin-top: 24px;
  padding: 20px;
  background: var(--green-dim);
  border: 1px solid rgba(0, 229, 160, 0.3);
  border-radius: 12px;
}
.builder-result h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--green);
}
.builder-result .qr-final {
  background: white; padding: 14px; border-radius: 10px;
  display: inline-block;
}
.builder-result .qr-final img { display: block; width: 180px; height: 180px; }
.builder-result code {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
}

/* modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-card {
  width: 480px; max-width: calc(100vw - 32px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.modal-card header h3 {
  font-family: 'Syne', sans-serif;
  margin-bottom: 18px;
}
.modal-card header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-card header h3 { margin: 0; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 16px;
}
.modal-actions .btn-primary { width: auto; }
.modal-actions .btn-ghost { text-decoration: none; }

.tenant-step { display: none; }
.tenant-step.active { display: block; }

.checkout-success {
  text-align: center;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.success-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0, 229, 160, 0.4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  font-weight: 700;
}
.checkout-success h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
}

.copy-row {
  display: flex; gap: 8px;
}
.copy-row input {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  flex: 1;
}
.copy-row .copy-btn { width: auto; padding: 10px 18px; }
.copy-row .copy-btn.copied {
  background: var(--blue);
  color: white;
}

/* state */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-mute);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: .06em;
}

/* toast */
.toast {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 200;
  padding: 14px 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  letter-spacing: .02em;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  transition: opacity .25s;
}
.toast.tone-green { border-color: var(--green); color: var(--green); }
.toast.tone-yellow { border-color: var(--yellow); color: var(--yellow); }

@media (max-width: 860px) {
  .sidebar { width: 200px; padding: 18px 12px; }
  .content { padding: 24px 18px; }
  .radio-group { grid-template-columns: 1fr; }
  .tenant-row { grid-template-columns: 1.5fr 1fr 1fr; }
  .tenant-row .col-hide { display: none; }
}
