:root {
  --ink: #14231c;
  --muted: #5a6b62;
  --panel: rgba(255, 255, 255, 0.82);
  --line: rgba(20, 35, 28, 0.12);
  --sea: #1f6f5b;
  --sea-deep: #0e3d32;
  --sun: #e2a93b;
  --danger: #9a3b2f;
  --ok: #1b6b4a;
  --sidebar: #0c2f27;
  --sidebar-text: #d7ebe3;
  --radius: 16px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
/* display:* en componentes anula el atributo HTML hidden; forzar siempre */
[hidden] {
  display: none !important;
}
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: #eef5f0;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 45% at 10% -10%, rgba(226, 169, 59, 0.2), transparent 55%),
    radial-gradient(ellipse 55% 40% at 100% 0%, rgba(31, 111, 91, 0.16), transparent 50%),
    linear-gradient(165deg, #eef6f1, #f6f3ea 48%, #e8f1ec);
}

.brand {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sea);
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--sea-deep);
  margin: 0;
}

.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.error {
  color: var(--danger);
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 8%, #fff);
  font-size: 0.92rem;
}
.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Auth */
.auth-shell,
.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  width: 100%;
}
.auth-card {
  width: min(440px, 100%);
  max-width: 100%;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(14, 61, 50, 0.1);
}
.auth-card .brand { color: var(--sea); }
.auth-card h1 {
  margin-top: 0.45rem;
  font-size: clamp(1.55rem, 5vw, 2rem);
  line-height: 1.15;
}
.lede { color: var(--muted); margin: 0.55rem 0 1.2rem; }
.stack,
.auth-form {
  display: grid;
  gap: 0.85rem;
  width: 100%;
}
.stack label,
.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.auth-actions {
  margin-top: 0.25rem;
}
.auth-actions .btn {
  flex: 1 1 auto;
  min-width: 8rem;
  text-align: center;
  justify-content: center;
}
input, select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: #fff;
  width: 100%;
  max-width: 100%;
}

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: var(--sea-deep);
  color: #f7fbf8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--sea); }
.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid var(--line);
}
.btn.small { padding: 0.45rem 0.85rem; font-size: 0.88rem; }
.btn.full { width: 100%; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font: inherit;
}
.only-mobile { display: none; }

/* Layout */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem 0.9rem;
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 30;
}
.sidebar .brand { color: #8fd0b8; }
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem 0.2rem;
}
.sidebar-tenant {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
}
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 0.55rem;
  padding: 0.4rem;
}
.sidebar-foot .muted { color: rgba(215, 235, 227, 0.7); }
.sidebar-foot .btn.ghost {
  border-color: rgba(255,255,255,0.18);
  color: #fff;
}

.nav { display: grid; gap: 0.2rem; padding: 0.2rem; }
.nav-label {
  margin: 0.85rem 0 0.25rem;
  padding: 0 0.55rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(215, 235, 227, 0.55);
  font-weight: 700;
}
.nav-label:first-child { margin-top: 0.2rem; }
.nav-item {
  appearance: none;
  border: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  background: transparent;
  color: var(--sidebar-text);
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.is-active {
  background: rgba(143, 208, 184, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 #8fd0b8;
}
.nav-ico {
  width: 1.1rem;
  opacity: 0.85;
  font-size: 0.95rem;
}

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--line);
  background: rgba(238, 245, 240, 0.86);
  backdrop-filter: blur(10px);
}
.topbar-text { flex: 1; min-width: 0; }
.topbar h1 { font-size: 1.45rem; }
.status { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }

.main { padding: 1.25rem 1.35rem 2.5rem; }
.panel { display: grid; gap: 1rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px rgba(14, 61, 50, 0.05);
}
.card.wide { grid-column: 1 / -1; }
.card h2 { font-size: 1rem; margin-bottom: 0.45rem; }
.card > p { margin: 0; font-size: 1.2rem; font-weight: 700; }
.lede.tight { margin: 0.35rem 0 1rem; color: var(--muted); font-weight: 500; font-size: 0.95rem; }

.membership-lock {
  border-color: rgba(14, 61, 50, 0.25);
  background: linear-gradient(135deg, rgba(143, 208, 184, 0.2), rgba(255,255,255,0.7));
}
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.85rem;
}
.plan-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(255,255,255,0.65);
  display: grid;
  gap: 0.55rem;
}
.plan-card h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--sea-deep);
}
.plan-price { margin: 0; font-size: 1.15rem; }
.plan-price s { font-size: 0.9rem; margin-right: 0.35rem; }
.plan-meta {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge.active { background: #d1fae5; color: #065f46; }
.badge.expired, .badge.cancelled { background: #fee2e2; color: #991b1b; }
.nav-item.is-locked { opacity: 0.45; }

.table-wrap { overflow-x: auto; margin-top: 0.75rem; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td {
  text-align: left;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--line);
}
th {
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.rate {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--sea-deep);
}
.up { color: var(--danger); }
.down { color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 1.2rem; }

.new-key {
  margin: 0.85rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(226, 169, 59, 0.16);
  border: 1px solid rgba(226, 169, 59, 0.35);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
}

.keys-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.85rem;
}
.key-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, canvastext 12%, transparent);
  background: color-mix(in srgb, canvas 94%, var(--sea-deep, #0f3d2e));
}
.key-row code {
  font-size: 0.92rem;
}
.mem-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.docs h3 { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }
.docs p { color: var(--muted); }
.docs-base {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: color-mix(in srgb, canvas 92%, var(--accent, #1a7f4b));
  border: 1px solid color-mix(in srgb, canvastext 10%, transparent);
}
.docs-steps {
  margin: 0 0 1.1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  display: grid;
  gap: 0.55rem;
}
.docs-steps strong { color: inherit; }
.docs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin-bottom: 0.65rem;
}
.docs-lang {
  display: grid;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.docs-lang select {
  min-width: 10rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, canvastext 14%, transparent);
  background: canvas;
  color: canvastext;
}
.docs code, .card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
}
.docs pre {
  background: var(--sea-deep);
  color: #e8f5ef;
  padding: 1rem;
  border-radius: 12px;
  overflow-x: auto;
}
.docs pre#docs-snippet { margin-top: 0; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 16, 0.45);
  z-index: 25;
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .cards { grid-template-columns: 1fr; }
  .status { display: none; }
  .auth-shell,
  .auth-view { padding: 1rem; align-content: center; }
  .auth-actions { flex-direction: column; align-items: stretch; }
  .auth-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
  .auth-card { padding: 1.1rem; border-radius: 14px; }
  .auth-card h1 { font-size: 1.45rem; }
  .lede { font-size: 0.92rem; }
}
