/**
 * Sources Athenas - License Server
 * "The License Vault" — obsidian command console.
 *
 * TOKENS
 *  Color:  --bg #0A0910 obsidian page · --surface #15121F raised panel · --well #0D0B15 recessed input
 *          --purple #6C31A6 structure · --purple-light #A972E0 accent/focus · --gold #D4AF37 (MONEY ONLY)
 *          emerald #43B581 active · red #E05656 inactive · amber #E0913C expiring/expired
 *  Type:   display Space Grotesk (webfont) · body system-sans · data system-mono
 *  Depth:  panels sit ABOVE the page (lighter + top highlight); inputs sit RECESSED (darker + inset).
 *  Signature: "the gold seam" — gold is rationed to money (Extras pagos, Features.key button,
 *             Premium badge, brand seal). Everything else stays quiet purple-on-obsidian.
 */

:root {
  /* ---- surfaces / depth ---- */
  --bg:            #0A0910;
  --bg-deep:       #070609;
  --surface:       #15121F;   /* raised panels (cards, table, modal, bars) */
  --surface-2:     #1A1728;   /* modal / elevated */
  --surface-hover: #1E1A2D;   /* row + control hover */
  --well:          #0D0B15;   /* recessed inputs / mono chips */

  /* ---- brand ---- */
  --purple:        #6C31A6;
  --purple-deep:   #4C1F7A;
  --purple-light:  #A972E0;
  --purple-soft:   #C6A6EC;
  --rgb-purple:        108 49 166;
  --rgb-purple-light:  169 114 224;

  /* ---- gold (MONEY ONLY) ---- */
  --gold:          #D4AF37;
  --gold-bright:   #E8C65C;
  --gold-ink:      #2A1E05;   /* text on a gold fill */
  --rgb-gold:      212 175 55;

  /* ---- semantic (quiet) ---- */
  --emerald:       #43B581;
  --emerald-light: #6DD3A6;
  --rgb-emerald:   67 181 129;
  --red:           #E05656;
  --red-light:     #F08A8A;
  --rgb-red:       224 86 86;
  --amber:         #E0913C;
  --amber-light:   #F0B36B;
  --rgb-amber:     224 145 60;

  /* ---- text ---- */
  --text:          #E4E1EE;
  --text-strong:   #F6F4FC;
  --text-dim:      #A9A2BE;
  --text-faint:    #736C8A;

  /* ---- lines ---- */
  --hairline:       1px solid rgb(255 255 255 / 0.07);
  --hairline-purple:1px solid rgb(var(--rgb-purple-light) / 0.16);
  --hairline-gold:  1px solid rgb(var(--rgb-gold) / 0.30);

  /* ---- elevation ---- */
  --lift-top:      inset 0 1px 0 rgb(255 255 255 / 0.04);
  --shadow-panel:  0 1px 0 rgb(255 255 255 / 0.02) inset, 0 14px 34px -18px rgb(0 0 0 / 0.75);
  --shadow-raise:  0 22px 50px -24px rgb(0 0 0 / 0.85);
  --shadow-modal:  0 40px 90px -30px rgb(0 0 0 / 0.85), 0 0 0 1px rgb(var(--rgb-purple-light) / 0.10);
  --well-inset:    inset 0 1px 2px rgb(0 0 0 / 0.55), inset 0 0 0 1px rgb(255 255 255 / 0.015);

  /* ---- radii ---- */
  --r-sm: 8px;
  --r:    11px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* ---- type ---- */
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-sans:    system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', SFMono-Regular, 'Fira Code', Menlo, Consolas, monospace;
}

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

html { color-scheme: dark; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 620px at 78% -8%, rgb(var(--rgb-purple) / 0.16), transparent 60%),
    radial-gradient(900px 520px at 6% 4%,  rgb(var(--rgb-gold) / 0.035), transparent 55%),
    radial-gradient(1200px 900px at 50% 120%, rgb(var(--rgb-purple) / 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

/* faint obsidian grain — sits under content, never distracts */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(90deg, rgb(255 255 255 / 0.012) 1px, transparent 1px),
    linear-gradient(0deg,  rgb(255 255 255 / 0.012) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 85%);
}

button, input, select, textarea { font: inherit; color: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--purple-light);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--purple-soft); text-underline-offset: 2px; }
a:hover { color: var(--purple-light); }

::selection { background: rgb(var(--rgb-purple) / 0.42); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: rgb(var(--rgb-purple) / 0.4);
  border: 2px solid var(--bg-deep);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgb(var(--rgb-purple-light) / 0.55); }

/* ================================
   AMBIENT PARTICLES (deliberately faint)
   ================================ */
.magic-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.35;
  filter: saturate(0.75);
}

@keyframes particleFloat {
  0%, 100% { transform: translateY(0) translateX(0); opacity: 0.18; }
  50%      { transform: translateY(-34px) translateX(6px); opacity: 0.30; }
}

.particle { will-change: transform, opacity; }

/* ================================
   LAYOUT
   ================================ */
.container {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---- header / brand ---- */
header {
  text-align: left;
  padding: 20px 0 26px;
  margin-bottom: 26px;
  border-bottom: var(--hairline);
  position: relative;
}
/* the gold seam under the header is the one place gold touches the frame */
header::after {
  content: '';
  position: absolute;
  left: 0; bottom: -1px;
  width: 116px; height: 2px;
  background: linear-gradient(90deg, var(--gold), rgb(var(--rgb-gold) / 0));
  border-radius: 2px;
}

.header-content,
.admin-header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
  text-align: left;
}
.header-left h1,
.header-left .subtitle { text-align: left; }

/* premium brand seal — the licensed product IS keys, so the mark is gold */
.brand-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--surface-2), var(--well));
  border: 1px solid rgb(var(--rgb-gold) / 0.42);
  box-shadow: var(--lift-top), 0 0 20px -6px rgb(var(--rgb-gold) / 0.35);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--gold-bright);
  user-select: none;
}

.brand-lines { min-width: 0; }

.brand-kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 3px;
}

header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.4vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--text-strong);
}

.subtitle {
  color: var(--text-dim);
  margin-top: 2px;
  font-size: 0.9rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.admin-header-actions .btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

/* ================================
   BUTTONS
   ================================ */
.btn {
  --btn-bg: var(--surface-2);
  padding: 11px 20px;
  border: var(--hairline-purple);
  border-radius: var(--r);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 40px;
  color: var(--text);
  background: var(--btn-bg);
}
.btn:active { transform: translateY(1px); }

/* subtle sheen only on the raised (primary/gold) buttons */
.btn-primary::before,
.btn-key::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 -130%;
  width: 90%;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.14), transparent);
  transition: left 0.55s ease;
  transform: skewX(-12deg);
}
.btn-primary:hover::before,
.btn-key:hover::before { left: 130%; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  border: 1px solid rgb(var(--rgb-purple-light) / 0.5);
  box-shadow: var(--lift-top), 0 10px 24px -12px rgb(var(--rgb-purple) / 0.85);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--lift-top), 0 14px 30px -12px rgb(var(--rgb-purple) / 0.95);
  border-color: rgb(var(--rgb-purple-light) / 0.7);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: var(--hairline-purple);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: rgb(var(--rgb-purple-light) / 0.4);
  color: var(--text-strong);
}

.btn-danger {
  background: transparent;
  color: var(--red-light);
  border: 1px solid rgb(var(--rgb-red) / 0.4);
}
.btn-danger:hover {
  background: rgb(var(--rgb-red) / 0.14);
  border-color: rgb(var(--rgb-red) / 0.62);
  color: var(--red-light);
}

/* THE gold button — the money action (download Features.key) */
.btn-key {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--gold-ink);
  border: 1px solid rgb(var(--rgb-gold) / 0.7);
  font-weight: 700;
  box-shadow: var(--lift-top), 0 10px 26px -12px rgb(var(--rgb-gold) / 0.75);
}
.btn-key:hover {
  transform: translateY(-1px);
  box-shadow: var(--lift-top), 0 14px 32px -12px rgb(var(--rgb-gold) / 0.9);
}
.btn-key .key-glyph { margin-right: 7px; font-size: 0.95em; }

.btn-small {
  padding: 7px 12px;
  font-size: 0.8rem;
  min-height: 34px;
  border-radius: var(--r-sm);
}

/* per-row Customs quick-action — a quiet gold-tinted OUTLINE (the paid /
   entitlement axis). Full gold fill stays reserved for .btn-key (the money
   action), so this only tints the seam, not the whole button. */
.btn-customs {
  color: var(--gold-bright);
  background: rgb(var(--rgb-gold) / 0.06);
  border: 1px solid rgb(var(--rgb-gold) / 0.42);
}
.btn-customs:hover {
  color: var(--gold-bright);
  background: rgb(var(--rgb-gold) / 0.14);
  border-color: rgb(var(--rgb-gold) / 0.7);
}

/* ================================
   STATS
   ================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: var(--hairline);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-panel);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
/* per-card accent seam (top) — encodes the metric, not decoration */
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 2px;
  background: rgb(var(--rgb-purple-light) / 0.5);
}
.stat-card.active::before  { background: rgb(var(--rgb-emerald) / 0.7); }
.stat-card.online::before  { background: rgb(var(--rgb-purple-light) / 0.7); }

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgb(var(--rgb-purple-light) / 0.24);
  box-shadow: var(--shadow-panel), var(--shadow-raise);
}

.stat-label {
  display: block;
  order: -1;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-card.active .stat-number { color: var(--emerald-light); }

/* ================================
   ACTIONS / SEARCH / FILTERS / SORT
   ================================ */
.actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-container { position: relative; margin-bottom: 14px; }

.search-input {
  width: 100%;
  padding: 13px 18px 13px 46px;
  border: var(--hairline);
  border-radius: var(--r);
  background: var(--well);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--well-inset);
}
.search-input:focus {
  outline: none;
  border-color: rgb(var(--rgb-purple-light) / 0.55);
  box-shadow: var(--well-inset), 0 0 0 3px rgb(var(--rgb-purple) / 0.22);
}
.search-input::placeholder { color: var(--text-faint); }

.search-icon {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.95rem;
  opacity: 0.8;
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--surface);
  border: var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
}
.status-filter-label {
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-right: 6px;
}

.filter-chip {
  min-height: 40px;
  padding: 7px 15px;
  border-radius: 999px;
  border: var(--hairline);
  background: var(--well);
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.84rem;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.filter-chip:hover {
  color: var(--text-strong);
  border-color: rgb(var(--rgb-purple-light) / 0.35);
}
.filter-chip[aria-pressed="true"] {
  color: var(--text-strong);
  border-color: rgb(var(--rgb-purple-light) / 0.55);
  background: rgb(var(--rgb-purple) / 0.22);
  box-shadow: inset 0 0 0 1px rgb(var(--rgb-purple-light) / 0.2);
}

.mobile-sort-controls {
  display: none;
  background: var(--surface);
  border: var(--hairline);
  box-shadow: var(--shadow-panel);
}

/* ================================
   EXPIRING ALERT
   ================================ */
.expiring-alert {
  display: none;
  background: linear-gradient(180deg, rgb(var(--rgb-amber) / 0.07), transparent 70%), var(--surface);
  border: 1px solid rgb(var(--rgb-amber) / 0.3);
  border-left: 3px solid var(--amber);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-panel);
}
.expiring-alert h3 {
  color: var(--amber-light);
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.expiring-alert ul { margin: 0; padding-left: 20px; color: var(--text-dim); }
.expiring-alert li { margin: 4px 0; }
.expiring-alert strong { color: var(--text-strong); }

/* ================================
   TABLE (the license ledger)
   ================================ */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

thead {
  background: linear-gradient(180deg, rgb(var(--rgb-purple) / 0.14), rgb(var(--rgb-purple) / 0.02));
}
thead th {
  padding: 13px 14px;
  text-align: left;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  color: var(--purple-soft);
  border-bottom: 1px solid rgb(var(--rgb-purple-light) / 0.18);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.16s ease;
  border-bottom: 1px solid rgb(255 255 255 / 0.045);
  animation: rowAppear 0.28s ease forwards;
  opacity: 0;
}
tbody tr:nth-child(even) { background: rgb(255 255 255 / 0.014); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgb(var(--rgb-purple) / 0.09); }

tbody td {
  padding: 13px 14px;
  color: var(--text);
  vertical-align: middle;
  font-size: 0.9rem;
}
tbody td strong { color: var(--text-strong); font-weight: 600; }

th.sortable { cursor: pointer; user-select: none; transition: color 0.2s ease; }
th.sortable:hover { color: var(--gold-bright); }
th.sortable::after { content: ''; margin-left: 6px; opacity: 0.3; font-size: 0.8em; }
th.sortable.asc::after  { content: '\25B2'; opacity: 1; color: var(--purple-light); }
th.sortable.desc::after { content: '\25BC'; opacity: 1; color: var(--purple-light); }

.no-results {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-faint);
  font-style: italic;
}

/* ================================
   STATUS CHIPS / BADGES
   ================================ */
.status-active,
.status-inactive,
.status-pending,
.status-expired,
.badge-plan,
.badge-season,
.gs-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
  white-space: nowrap;
}

/* leading dot for state chips */
.status-active::before,
.status-inactive::before,
.status-pending::before,
.status-expired::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  color: var(--emerald-light);
  background: rgb(var(--rgb-emerald) / 0.12);
  border: 1px solid rgb(var(--rgb-emerald) / 0.32);
}
.status-inactive {
  color: var(--text-dim);
  background: rgb(255 255 255 / 0.03);
  border: 1px solid rgb(255 255 255 / 0.1);
}
.status-pending {
  color: var(--amber-light);
  background: rgb(var(--rgb-amber) / 0.1);
  border: 1px solid rgb(var(--rgb-amber) / 0.3);
}
.status-expired {
  color: var(--amber-light);
  background: rgb(var(--rgb-amber) / 0.16);
  border: 1px solid rgb(var(--rgb-amber) / 0.5);
}
.status-expired::before { background: var(--amber); }

/* SEASON — technical marker, mono, quiet purple */
.badge-season {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--purple-soft);
  border: 1px solid rgb(var(--rgb-purple-light) / 0.28);
  background: rgb(var(--rgb-purple) / 0.1);
}

/* PLAN — Basico quiet purple, Premium is GOLD (money) */
.badge-plan-basic {
  color: var(--text-dim);
  border: var(--hairline);
  background: rgb(255 255 255 / 0.03);
}
.badge-plan-premium {
  color: var(--gold-ink);
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border: 1px solid rgb(var(--rgb-gold) / 0.7);
  box-shadow: 0 0 16px -4px rgb(var(--rgb-gold) / 0.5);
  font-weight: 700;
}

.gs-indicator.gs-configured {
  color: var(--emerald-light);
  border: 1px solid rgb(var(--rgb-emerald) / 0.3);
  background: rgb(var(--rgb-emerald) / 0.1);
}
.gs-indicator.gs-missing {
  color: var(--text-faint);
  border: 1px dashed rgb(255 255 255 / 0.14);
  background: transparent;
}

/* ---- hardware id / mono data ---- */
.hardware-id,
.key-text,
#infoText { font-family: var(--font-mono); }

.path-hint {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--purple-light);
  background: var(--well);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.hardware-id {
  display: inline-block;
  white-space: nowrap;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  background: var(--well);
  padding: 5px 10px;
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: var(--r-sm);
  box-shadow: var(--well-inset);
}
.hardware-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hwid-copy-btn { min-width: 34px; padding-inline: 9px; }

.action-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

.toggle-license { border-color: rgb(var(--rgb-emerald) / 0.34); }
.toggle-license.is-off { border-color: rgb(var(--rgb-amber) / 0.34); }

/* ================================
   MODAL + FORM
   ================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(6 5 10 / 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal.show { display: flex; opacity: 1; }

/* the compact Customs modal — just the entitlements editor, narrower */
.modal-compact .modal-content { max-width: 520px; }

.modal-content {
  position: relative;
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 34px 38px 30px;
  background: var(--surface-2);
  border: var(--hairline-purple);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  animation: modal-appear 0.3s ease-out;
}

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: var(--hairline);
}

.close {
  position: absolute;
  top: 18px; right: 20px;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: var(--hairline);
  border-radius: 9px;
  background: var(--well);
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}
.close:hover {
  color: var(--red-light);
  border-color: rgb(var(--rgb-red) / 0.5);
  background: rgb(var(--rgb-red) / 0.12);
}

.form-group { margin-bottom: 20px; }

.form-group > label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.86rem;
}

.form-group input,
.form-group select,
.form-group textarea,
.mobile-sort-row select {
  width: 100%;
  padding: 12px 14px;
  background: var(--well);
  border: var(--hairline);
  border-radius: var(--r);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--well-inset);
}
.form-group textarea { resize: vertical; min-height: 60px; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.mobile-sort-row select:focus {
  outline: none;
  border-color: rgb(var(--rgb-purple-light) / 0.6);
  box-shadow: var(--well-inset), 0 0 0 3px rgb(var(--rgb-purple) / 0.22);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-faint); }

/* mono treatment for technical fields */
#hardwareId, #gsUrl, #gsApiKey, #infoText, .key-text {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.form-group small,
.field-note {
  display: block;
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 0.8rem;
  line-height: 1.45;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- section dividers that mean something ---- */
.portal-divider {
  border: 0;
  border-top: var(--hairline);
  margin: 28px 0 18px;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.form-section-title::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--purple-light);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: var(--hairline);
}

/* ---- custom checkboxes ---- */
.form-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  background: var(--well);
  border: 1.5px solid rgb(var(--rgb-purple-light) / 0.45);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  margin-right: 10px;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--well-inset);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.form-group input[type="checkbox"]:hover { border-color: var(--purple-light); }
.form-group input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--purple-light), var(--purple));
  border-color: var(--purple-light);
}
.form-group input[type="checkbox"]:checked::after {
  content: '\2713';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* the standalone "Licencia Activa" toggle row */
.form-group > label:has(> #isActive) {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  margin: 0;
}

/* ================================
   CUSTOMS (FEATURES.KEY) — the entitlements manifest
   ================================ */
.features-block { margin-bottom: 14px; }

.features-empty {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.88rem;
  padding: 6px 0;
}

.features-group { margin-bottom: 16px; }
.features-group:last-child { margin-bottom: 0; }

.features-group-title {
  display: block;
  margin-bottom: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 18px;
}
.features-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

/* --- THE GOLD SEAM: the Extras (pagos) group is the paid manifest ---
   In the live app renderFeatures() always emits base first, extra second,
   so `.features-group + .features-group` targets the paid group. The preview
   marks it explicitly with .is-extra. Both get the gold treatment. */
.features-group + .features-group,
.features-group.is-extra {
  padding: 14px 16px;
  border: 1px solid rgb(var(--rgb-gold) / 0.28);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgb(var(--rgb-gold) / 0.06), rgb(var(--rgb-gold) / 0.015));
  box-shadow: inset 0 1px 0 rgb(var(--rgb-gold) / 0.1);
}
.features-group + .features-group .features-group-title,
.features-group.is-extra .features-group-title {
  color: var(--gold-bright);
}
.features-group + .features-group .features-group-title::before,
.features-group.is-extra .features-group-title::before {
  content: '\25C6'; /* gold gem = paid */
  margin-right: 7px;
  color: var(--gold);
}
/* paid features check in gold */
.features-group + .features-group input[type="checkbox"]:checked,
.features-group.is-extra input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border-color: var(--gold);
}
.features-group + .features-group input[type="checkbox"]:checked::after,
.features-group.is-extra input[type="checkbox"]:checked::after {
  color: var(--gold-ink);
}

.feature-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 18px 0 8px;
  padding-top: 16px;
  border-top: var(--hairline);
}

.features-status {
  font-size: 0.84rem;
  color: var(--text-faint);
  font-weight: 500;
}
.features-status.is-success { color: var(--emerald-light); }
.features-status.is-error { color: var(--red-light); }

/* info modal textarea */
#infoText, .key-text {
  white-space: pre;
  line-height: 1.6;
}

/* ================================
   FLATPICKR (dark) OVERRIDES
   ================================ */
.flatpickr-calendar {
  background: var(--surface-2) !important;
  border: var(--hairline-purple) !important;
  box-shadow: var(--shadow-modal) !important;
  border-radius: var(--r) !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--purple) !important;
  border-color: var(--purple) !important;
}
.flatpickr-day:hover { background: rgb(var(--rgb-purple) / 0.28) !important; }
.flatpickr-months .flatpickr-month,
.flatpickr-current-month,
.flatpickr-weekday { color: var(--text) !important; fill: var(--text) !important; }

/* ================================
   ANIMATIONS
   ================================ */
@keyframes rowAppear {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modal-appear {
  from { opacity: 0; transform: scale(0.98) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ================================
   UTILITIES
   ================================ */
.admin-page { overflow-x: hidden; }
.admin-page .hardware-id { white-space: nowrap; }

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 1180px) {
  thead th, tbody td { padding-inline: 11px; }
  .btn-small { padding-inline: 10px; }

  .admin-page .container { width: 100%; padding: 18px 16px 48px; }
  .admin-page header { padding: 16px 0 20px; }

  .admin-header-content { align-items: flex-start; }

  .admin-page .stats { gap: 12px; margin-bottom: 20px; }
  .admin-page .stat-card { padding: 16px 16px; }
  .admin-page .stat-number { font-size: 2rem; }

  .admin-page .actions { gap: 8px; margin-bottom: 14px; }
  .admin-page .btn, .admin-page .filter-chip { min-height: 44px; }
  .admin-page .search-input { min-height: 48px; font-size: 1rem; }

  /* card-table on narrow screens */
  .admin-page #licensesTable,
  .admin-page #licensesTable tbody,
  .admin-page #licensesTable tr,
  .admin-page #licensesTable td { display: block; width: 100%; }

  .admin-page #licensesTable {
    border: 0; border-radius: 0; overflow: visible;
    background: transparent; box-shadow: none;
  }
  .admin-page #licensesTable thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%);
    white-space: nowrap; border: 0;
  }

  .admin-page .mobile-sort-controls {
    display: block; margin-bottom: 16px; padding: 12px; border-radius: var(--r-lg);
  }
  .admin-page .mobile-sort-controls > label {
    display: block; margin-bottom: 8px;
    color: var(--text-dim); font-size: 0.85rem; font-weight: 600;
  }
  .admin-page .mobile-sort-row {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, auto); gap: 8px;
  }
  .admin-page .mobile-sort-row select,
  .admin-page .mobile-sort-row .btn { width: 100%; min-height: 44px; }

  .admin-page #licensesTable tbody { display: grid; gap: 12px; }
  .admin-page #licensesTable tbody tr {
    opacity: 1;
    overflow: hidden;
    border: var(--hairline);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-panel);
  }
  .admin-page #licensesTable tbody tr:nth-child(even) { background: var(--surface); }
  .admin-page #licensesTable tbody td {
    display: grid;
    grid-template-columns: minmax(98px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid rgb(255 255 255 / 0.05);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
  }
  .admin-page #licensesTable tbody td::before {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    line-height: 1.5;
    text-transform: uppercase;
  }
  .admin-page #licensesTable tbody td:nth-child(1)::before { content: 'ID'; }
  .admin-page #licensesTable tbody td:nth-child(2)::before { content: 'Cliente'; }
  .admin-page #licensesTable tbody td:nth-child(3)::before { content: 'Hardware ID'; }
  .admin-page #licensesTable tbody td:nth-child(4)::before { content: 'Versión'; }
  .admin-page #licensesTable tbody td:nth-child(5)::before { content: 'Plan'; }
  .admin-page #licensesTable tbody td:nth-child(6)::before { content: 'Estado'; }
  .admin-page #licensesTable tbody td:nth-child(7)::before { content: 'Expiración'; }
  .admin-page #licensesTable tbody td:nth-child(8)::before { content: 'GameServer'; }
  .admin-page #licensesTable tbody td:nth-child(9)::before { content: 'Último online'; }
  .admin-page #licensesTable tbody td:nth-child(10)::before { content: 'Acciones'; }

  .admin-page #licensesTable tbody td:last-child { display: block; border-bottom: 0; }
  .admin-page #licensesTable tbody td:last-child::before { display: block; margin-bottom: 10px; }

  .admin-page .hardware-cell { align-items: flex-start; }
  .admin-page .action-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .admin-page .action-buttons .btn { width: 100%; min-height: 44px; padding: 10px 8px; }

  .admin-page .no-results { display: block !important; padding: 28px 16px !important; }
  .admin-page .no-results::before { content: none !important; }

  .admin-page .modal { padding: 12px; }
  .admin-page .modal-content { width: 100%; max-height: calc(100dvh - 24px); padding: 26px 22px; }
  .admin-page .close { width: 44px; height: 44px; top: 12px; right: 12px; }

  .admin-page .form-group input,
  .admin-page .form-group select,
  .admin-page .form-group textarea { min-height: 44px; font-size: 1rem; }
  .admin-page .form-group input[type="checkbox"] {
    width: 22px; min-width: 22px; height: 22px; min-height: 22px; padding: 0; flex: 0 0 22px;
  }
  .admin-page .form-group label:has(> input[type="checkbox"]) {
    min-height: 44px; display: inline-flex; align-items: center; cursor: pointer;
  }

  .form-row { grid-template-columns: 1fr; }
  .header-content { flex-direction: column; }
}

@media (max-width: 700px) {
  .admin-header-content { flex-direction: column; gap: 16px; }
  .admin-header-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px; }
  .admin-page .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-page .stats .stat-card:first-child { grid-column: 1 / -1; }
  .features-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .container, .admin-page .container { padding: 12px 12px 40px; }
  .admin-page header { padding: 14px 0 18px; }
  .admin-brand { gap: 12px; }
  .brand-mark { width: 40px; height: 40px; }

  .admin-header-actions,
  .admin-page .stats,
  .admin-page .actions,
  .admin-page .form-actions { grid-template-columns: 1fr; }
  .admin-page .stats .stat-card:first-child { grid-column: auto; }
  .admin-page .actions .btn { width: 100%; padding-inline: 10px; }
  .admin-page .mobile-sort-row { grid-template-columns: 1fr; }

  .status-filter { align-items: stretch; }
  .status-filter-label { width: 100%; }
  .filter-chip { flex: 1 1 calc(50% - 8px); }

  .admin-page #licensesTable tbody td { grid-template-columns: 92px minmax(0, 1fr); padding-inline: 12px; }

  .admin-page .modal-content { padding: 22px 16px; border-radius: var(--r-lg); }
  .admin-page .modal-content h2 { padding-right: 40px; }
  .admin-page .form-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-page .form-actions .btn { width: 100%; min-height: 44px; padding-inline: 10px; }
  .feature-actions { flex-direction: column; align-items: stretch; }
  .feature-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-page *,
  .admin-page *::before,
  .admin-page *::after,
  .magic-particles,
  .magic-particles::before,
  .particle {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
