@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/plus-jakarta-sans.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #0d2a21;
  --ink-soft: #26443a;
  --muted: #61766d;
  --muted-2: #86978f;
  --line: #dce6df;
  --line-soft: #e9efeb;
  --bg: #f3f6f1;
  --card: #ffffff;
  --brand: #0d8a5f;
  --brand-dark: #075c40;
  --brand-deep: #0a2c22;
  --brand-soft: #e9f5ef;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --shadow: 0 1px 2px rgba(13, 42, 33, .05), 0 12px 32px -18px rgba(13, 42, 33, .25);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(13, 138, 95, .10), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.boot { padding: 80px 24px; text-align: center; color: var(--muted); }

/* ---------------- top bar ---------------- */
.topbar {
  background: var(--brand-deep);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 17px;
  color: inherit;
}
.brand-logo {
  width: 44px;
  height: 30px;
  object-fit: contain;
  display: block;
  flex: none;
}
.brand-lockup {
  height: 34px;
  width: auto;
  display: block;
  object-fit: contain;
}
.topbar .brand { align-items: flex-start; flex-direction: column; gap: 2px; }
.brand-sub {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
}
.auth-brand {
  display: grid;
  justify-items: start;
  gap: 4px;
  margin-bottom: 14px;
}
.auth-lockup { height: 52px; width: auto; display: block; }
.auth-slogan {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.auth-brand .brand-logo {
  width: 46px;
  height: 32px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(145deg, #22c78e, #0d8a5f);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #06281e;
  font-weight: 900;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.brand small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
  margin-top: -2px;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.user {
  font-size: 13px;
  color: rgba(255, 255, 255, .72);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .85);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ---------------- layout ---------------- */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.035em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1;
  text-decoration: none;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: #b9c9bf; background: #fbfdfb; }
.btn-ghost {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border-color: rgba(255, 255, 255, .16);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .14); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdca; }
.btn-small { padding: 7px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------------- cards & stats ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 18px 20px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-soft); background: #fbfcfa; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  color: var(--muted-2);
}
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.04em; margin-top: 5px; }
.stat-foot { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* ---------------- navegación del panel ---------------- */
.nav-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 20px;
  padding: 0 2px;
  overflow-x: auto;
}
.nav-tab {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* ---------------- cartera de suscripciones ---------------- */
.filters {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(140px, .7fr));
  gap: 10px;
  margin-bottom: 14px;
}
.filters .field { gap: 4px; }
.filters .field > label { font-size: 10px; }
.day-chip {
  display: inline-flex;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  background: #f2f5f3;
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.day-chip.warn { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.day-chip.danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdca; }
.day-chip.neutral { background: #f2f5f3; color: var(--muted); }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
#renovar-dialog { width: min(560px, calc(100vw - 32px)); }

/* ---------------- tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: #f8faf7;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdfb; }
.table .strong { font-weight: 700; }
.table .right { text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.activo, .badge.pagado { color: var(--ok); background: var(--ok-soft); border-color: #abefc6; }
.badge.prueba, .badge.pendiente { color: var(--warn); background: var(--warn-soft); border-color: #fedf89; }
.badge.suspendido, .badge.vencido, .badge.rechazado, .badge.cancelada, .badge.vencida { color: var(--danger); background: var(--danger-soft); border-color: #fecdca; }
.badge.neutral { color: var(--muted); background: #f2f5f3; border-color: var(--line); }

/* ---------------- forms ---------------- */
.field { display: grid; gap: 5px; }
.field > label, .label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #7cc9a7;
  box-shadow: 0 0 0 3px rgba(13, 138, 95, .12);
}
.field textarea { min-height: 74px; resize: vertical; }
.field .hint { font-size: 11.5px; color: var(--muted-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline input { flex: 1; min-width: 0; }
.field-inline .btn { flex: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.form-error { color: var(--danger); font-size: 12.5px; margin-top: 8px; min-height: 1em; }

/* ---------------- sections / detail ---------------- */
.section { padding: 20px; border-top: 1px solid var(--line-soft); }
.section:first-child { border-top: 0; }
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.section-title { font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.section-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.detail-title { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.detail-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- usage ---------------- */
.usage-list { display: grid; gap: 14px; }
.usage-row { display: grid; gap: 6px; }
.usage-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.usage-name { font-size: 12.5px; font-weight: 700; }
.usage-numbers { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 999px; background: #eef3ef; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #34c48d, #0d8a5f); }
.progress-bar.warn { background: linear-gradient(90deg, #fdb022, #dc6803); }
.progress-bar.danger { background: linear-gradient(90deg, #f97066, #b42318); }

/* ---------------- empty / links ---------------- */
.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfa;
}
.link-list { display: grid; gap: 10px; }
.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fbfcfa;
  text-decoration: none;
  color: var(--ink);
}
.link-item:hover { border-color: #b9c9bf; background: #fff; }
.link-item .link-label { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.link-item .link-value { font-size: 13px; font-weight: 600; word-break: break-all; }
.link-item .arrow { color: var(--brand); font-size: 16px; }

/* ---------------- auth ---------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}
.auth-card {
  width: 100%;
  display: none;
  max-width: 430px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 30px 28px 26px;
  box-shadow: 0 30px 80px -40px rgba(10, 44, 34, .45);
}
.auth-card:not([hidden]) { display: block; }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
}
.auth-brand { display: grid; justify-items: start; gap: 3px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.auth-card h1 { font-size: 25px; font-weight: 800; letter-spacing: -.04em; margin-top: 18px; }
.auth-card .auth-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; margin-bottom: 20px; }
.auth-form { display: grid; gap: 13px; }
.auth-form .btn { width: 100%; margin-top: 4px; }
.auth-note { font-size: 11.5px; color: var(--muted-2); margin-top: 18px; line-height: 1.55; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); margin-top: 18px; }

/* ---------------- dialogs ---------------- */
dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 40px 100px -30px rgba(10, 44, 34, .5);
  color: var(--ink);
}
dialog::backdrop { background: rgba(10, 44, 34, .38); backdrop-filter: blur(2px); }
dialog h2 { font-size: 18px; letter-spacing: -.03em; margin-bottom: 4px; }
dialog .dialog-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 16px);
  background: var(--brand-deep);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 100;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ---------------- misc ---------------- */
.hr { height: 1px; background: var(--line-soft); margin: 4px 0; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.notice {
  border: 1px solid #fedf89;
  background: var(--warn-soft);
  color: #7a2e0e;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.5;
}
.portal-hero {
  background: linear-gradient(135deg, #0a2c22, #0f5138 55%, #0d8a5f 130%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.portal-hero h1 { font-size: 25px; letter-spacing: -.04em; margin-top: 5px; }
.portal-hero p { color: rgba(255, 255, 255, .68); font-size: 13px; margin-top: 3px; }
.portal-hero .hero-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.portal-hero .chip { border-color: rgba(255, 255, 255, .22); }
.plan-name { font-size: 24px; font-weight: 800; letter-spacing: -.04em; }
.plan-price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .page { padding: 20px 14px 48px; }
  .topbar-inner { padding: 12px 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .page-title { font-size: 22px; }
  .card-body, .section { padding: 16px; }
  .card-head { padding: 15px 16px 0; }
  .topbar-actions { width: 100%; margin-left: 0; justify-content: space-between; }
  .user { max-width: 160px; }
}
@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 20px; }
  .auth-card { padding: 24px 18px; }
  .table th, .table td { padding: 10px; }
}
