/* Astra — license key manager UI */

:root {
  --bg: #06021a;
  --bg-soft: #0a0326;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-solid: #0c0530;
  --border: rgba(196, 165, 245, 0.14);
  --border-strong: rgba(196, 165, 245, 0.28);
  --text: #efeafc;
  --muted: #9a8fbf;
  --brand-1: #c9a6f2;
  --brand-2: #7c3aed;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* guard against a single wide child shrinking the whole page on phones */
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.02rem; letter-spacing: -0.01em; }

.muted { color: var(--muted); font-size: 0.86rem; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------- background */

.aurora-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(124, 58, 237, 0.22), transparent 60%),
    radial-gradient(760px 520px at 88% 0%, rgba(182, 130, 226, 0.14), transparent 62%),
    radial-gradient(700px 460px at 50% 110%, rgba(104, 34, 200, 0.12), transparent 65%),
    linear-gradient(180deg, #06021a 0%, #04010f 100%);
}

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.62rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.btn:active { transform: translateY(1px); }

.btn:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(180deg, #8b4bf5, #6d28d9);
  color: #ffffff;
  box-shadow: 0 12px 30px -14px rgba(124, 58, 237, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.07);
}

.btn-block { width: 100%; margin-top: 0.4rem; }
.btn-xs { padding: 0.28rem 0.6rem; font-size: 0.76rem; border-radius: 8px; }

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-busy .btn-label { opacity: 0.5; }

/* --------------------------------------------------------------- fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 0;
  min-width: 0;
}

.field > span {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field em { font-style: normal; font-weight: 400; opacity: 0.7; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(6, 10, 20, 0.65);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.16s ease, background 0.16s ease;
}

input::placeholder { color: #5d6a86; }

input:hover, select:hover { border-color: var(--border-strong); }

input:focus, select:focus {
  border-color: var(--brand-1);
  background: rgba(6, 10, 20, 0.9);
  outline: none;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
  cursor: pointer;
}

.error {
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.09);
  color: #fca5a5;
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: min(420px, 100%);
  padding: 2.25rem 2rem 1.75rem;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card h1 { margin-top: 1rem; font-size: 1.35rem; }
.login-card > .muted { margin-top: 0.35rem; }
.login-card form { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.85rem; }

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(94, 234, 212, 0.28);
  background: radial-gradient(circle at 30% 20%, rgba(94, 234, 212, 0.22), rgba(34, 211, 238, 0.16));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; }

.login-logo {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  box-shadow: 0 16px 38px -16px rgba(124, 58, 237, 0.85), 0 0 0 1px rgba(201, 166, 242, 0.16);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 24px -12px rgba(124, 58, 237, 0.9), 0 0 0 1px rgba(201, 166, 242, 0.14);
}
.footnote {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

/* --------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(6, 2, 26, 0.82);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }

.brand-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.brand-text strong { font-size: 0.95rem; letter-spacing: -0.01em; }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.conn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.conn.checking .dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.conn.online .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }
.conn.offline .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16); }
.conn.online { color: #9ff0d2; }
.conn.offline { color: #fca5a5; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.topbar-actions { display: flex; gap: 0.5rem; }

/* --------------------------------------------------------------- layout */

.layout {
  padding: clamp(1.1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem) 3rem;
  max-width: 1440px;
  margin: 0 auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}

.stat {
  position: relative;
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 166, 242, 0.4), transparent);
  opacity: 0.75;
}

.stat-label {
  display: block;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-hint { display: block; font-size: 0.72rem; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}

.create-panel { padding: 1.15rem; position: sticky; top: 84px; }
.list-panel { overflow: hidden; min-width: 0; }

.panel-head { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 1rem; }
.list-head { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.15rem 1.15rem 0.85rem; margin-bottom: 0; }

.create-panel form { display: flex; flex-direction: column; gap: 0.8rem; }

.row { display: flex; gap: 0.7rem; }

/* -------------------------------------------------------------- presets */

.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  padding: 0.32rem 0.66rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.chip:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.07); }

.chip.is-active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(180deg, #8b4bf5, #6d28d9);
}

/* --------------------------------------------------------------- result */

.result {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 166, 242, 0.3);
  background: rgba(124, 58, 237, 0.1);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #d9c6fb;
}

.key-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 220px;
  overflow: auto;
}

.key-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: rgba(4, 8, 16, 0.55);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.key-list li > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.key-list button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}

.key-list button:hover { color: var(--text); border-color: var(--border-strong); }

/* -------------------------------------------------------------- filters */

.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search svg { position: absolute; left: 0.65rem; color: var(--muted); pointer-events: none; }

.search input { padding-left: 2rem; min-width: 210px; }

.filters select { width: auto; min-width: 130px; }

/* ---------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }

table.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.keys thead th {
  position: sticky;
  top: 0;
  padding: 0.55rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(9, 14, 26, 0.92);
  border-bottom: 1px solid var(--border);
}

table.keys tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

table.keys tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
table.keys tbody tr:last-child td { border-bottom: none; }

.key-cell { display: flex; align-items: center; gap: 0.45rem; }

.key-code {
  font-family: var(--mono);
  font-size: 0.83rem;
  letter-spacing: 0.03em;
  color: #e6d9fb;
  white-space: nowrap;
}

.owner { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.owner span { font-size: 0.82rem; }
.owner small { font-size: 0.7rem; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active { color: #6ee7b7; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.28); }
.badge-expired { color: #cbd5e1; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.25); }
.badge-paused { color: #fcd34d; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.28); }
.badge-blacklisted { color: #fca5a5; background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.3); }
.badge-unused { color: #c4b5fd; background: rgba(167, 139, 250, 0.12); border-color: rgba(167, 139, 250, 0.26); }

.expiry { display: flex; flex-direction: column; gap: 0.05rem; white-space: nowrap; }
.expiry small { font-size: 0.7rem; color: var(--muted); }
.expiry.soon small { color: var(--warn); }
.expiry.past small { color: var(--danger); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.08); }

.col-actions { width: 96px; text-align: right; }

.rowmenu { position: relative; display: inline-block; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 178px;
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #12063a;
  box-shadow: 0 22px 44px -18px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.menu button {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.menu button:hover { background: rgba(255, 255, 255, 0.07); }
.menu button.danger { color: #fca5a5; }
.menu hr { margin: 0.25rem 0; border: 0; border-top: 1px solid var(--border); }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); font-size: 0.86rem; }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 460px);
  padding: 0.6rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(14, 5, 45, 0.97);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

.toast.bad { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .create-panel { position: static; }
}

@media (max-width: 760px) {
  /* 16px controls stop iOS Safari from zooming the page when an input is focused */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select {
    font-size: 16px;
  }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .stat { padding: 0.8rem 0.9rem; }
  .stat strong { font-size: 1.45rem; }

  .topbar {
    padding: 0.6rem 0.9rem;
    padding-top: calc(0.6rem + env(safe-area-inset-top));
  }
  .topbar-actions { gap: 0.35rem; }
  .topbar-actions .btn { padding: 0.5rem 0.65rem; font-size: 0.8rem; }

  .layout { padding-left: 0.9rem; padding-right: 0.9rem; }
  .list-head { padding: 1rem 1rem 0.7rem; }

  /* Filters: search gets its own row so nothing spills off narrow screens */
  .filters { width: 100%; gap: 0.45rem; }
  .filters .search { flex: 1 1 100%; }
  .search input { min-width: 0; width: 100%; }
  .filters select { flex: 1 1 60%; min-width: 0; }
  #delete-all-btn { flex: 0 0 auto; }

  table.keys thead { display: none; }
  table.keys, table.keys tbody, table.keys tr, table.keys td { display: block; width: 100%; }
  table.keys tbody tr { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); }
  table.keys tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.14rem 0;
    border: 0;
    text-align: right;
  }
  table.keys tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
    text-align: left;
  }
  table.keys td.col-actions { width: auto; justify-content: flex-end; padding-top: 0.4rem; }
  table.keys td.col-actions::before { content: none; }
  .col-actions { text-align: left; }

  .key-cell { justify-content: flex-end; flex-wrap: wrap; min-width: 0; }
  .key-code { font-size: 0.82rem; overflow-wrap: anywhere; }

  /* Comfortable tap targets */
  .icon-btn { width: 38px; height: 38px; font-size: 1rem; }
  .chip { padding: 0.42rem 0.75rem; }
  .key-list button { padding: 0.35rem 0.6rem; font-size: 0.78rem; }
  .menu { min-width: 190px; }
  .menu button { padding: 0.6rem 0.65rem; font-size: 0.88rem; }

  .modal { max-height: 88dvh; overflow-y: auto; }
  .modal-actions .btn { flex: 1 1 auto; }

  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .login-card { padding: 1.75rem 1.25rem 1.5rem; }
}

@media (max-width: 380px) {
  .brand-text strong { font-size: 0.86rem; }
  .conn { font-size: 0.68rem; }
  .topbar-actions .btn { padding: 0.45rem 0.55rem; font-size: 0.74rem; }
  .stat strong { font-size: 1.25rem; }
  .login-wrap { padding: 1.25rem 0.9rem; }
}

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

/* ------------------------------------------------------------ scrollbars */

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------ danger zone */

.btn-danger {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 12px 28px -14px rgba(220, 38, 38, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-danger:hover { filter: brightness(1.06); }

.btn-danger:disabled {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
  box-shadow: none;
  opacity: 0.65;
}

.btn-danger-ghost {
  border-color: rgba(248, 113, 113, 0.32);
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.06);
}

.btn-danger-ghost:hover {
  border-color: rgba(248, 113, 113, 0.6);
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
}

/* ---------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(3, 1, 12, 0.74);
  backdrop-filter: blur(7px);
  animation: fade-in 0.16s ease-out;
}

.modal {
  width: min(460px, 100%);
  padding: 1.4rem;
  border-radius: 18px;
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: linear-gradient(180deg, #180a36, #0d0424);
  box-shadow: var(--shadow);
}

.modal h2 { font-size: 1.12rem; }

.modal-text {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.65;
}

.modal-text strong { color: #fecaca; }

.modal .field { margin-top: 1rem; }

.modal .phrase {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  padding: 0.08rem 0.38rem;
  border-radius: 5px;
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.15rem;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ------------------------------------------------------- activation page */

.activate-card { max-width: 440px; }

.activate-result {
  margin-top: 1.1rem;
  padding: 1rem 1.05rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.activate-result.ok {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.activate-result.bad {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.result-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.activate-result.ok .result-title { color: #6ee7b7; }
.activate-result.bad .result-title { color: #fca5a5; }

.result-sub {
  margin-top: 0.25rem;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
}

.result-key {
  display: block;
  margin-top: 0.7rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: rgba(4, 8, 16, 0.55);
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-align: center;
  overflow-wrap: anywhere;
}

.result-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.75rem;
  margin: 0.8rem 0 0;
  font-size: 0.82rem;
}

.result-facts dt { color: var(--muted); }

.result-facts dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.switch-link {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  text-align: center;
}

.switch-link a {
  color: var(--brand-1);
  text-decoration: none;
}

.switch-link a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- client portal */

.portal {
  width: min(980px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
}

.portal-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.portal-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 0.9rem;
  align-items: start;
}

.portal-card {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.portal-card h2 { font-size: 0.95rem; }
.portal-card .btn-block { margin-top: 0.75rem; }

.portal-key {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  background: rgba(4, 8, 16, 0.55);
}

.portal-key code {
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.ip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.7rem;
  font-size: 0.82rem;
}

.ip-row code {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: #e6d9fb;
}

.ip-state {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
}

.ip-state.ok { color: #6ee7b7; }
.ip-state.bad { color: #fca5a5; }

.ip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.ip-actions .btn {
  flex: 1 1 auto;
  padding: 0.55rem 0.8rem;
  font-size: 0.84rem;
}

/* keep the tall portal anchored to the top instead of vertically centred */
.login-wrap.is-portal {
  place-items: start center;
  padding-top: 1.5rem;
}

@media (max-width: 900px) {
  .portal-grid { grid-template-columns: 1fr; }
  .portal { gap: 0.75rem; }
}

@media (max-width: 760px) {
  .portal-head { padding: 0.75rem 0.85rem; }
  .portal-card { padding: 0.95rem; }
}

/* ─────────────────────── sign-in card (portal entry) ─────────────────────── */

.activate-page { position: relative; }

.activate-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(520px 320px at 50% 18%, rgba(158, 91, 255, 0.18), transparent 70%),
    radial-gradient(680px 420px at 50% 100%, rgba(124, 58, 237, 0.12), transparent 72%);
}

.signin-card {
  position: relative;
  width: min(24rem, 100%);
  padding: 1.75rem 1.5rem 1.35rem;
  border-radius: 1.125rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, rgba(26, 13, 50, 0.92) 0%, rgba(8, 4, 20, 0.9) 100%);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px rgba(203, 170, 255, 0.06),
    0 0 60px -18px rgba(158, 91, 255, 0.45);
  overflow: hidden;
  animation: signin-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.signin-beam {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  animation: signin-beam 3.6s ease-in-out infinite;
}

.signin-head {
  text-align: center;
  margin-bottom: 1.4rem;
}

.signin-card h1 { margin-top: 0; }

.signin-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  background: linear-gradient(180deg, #ffffff, rgba(255, 255, 255, 0.72));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.signin-sub {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
}

.signin-card form { margin-top: 0; }

.signin-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.signin-field { position: relative; }

.signin-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.42);
  pointer-events: none;
}

.signin-field input {
  width: 100%;
  height: 2.9rem;
  padding: 0 0.9rem 0 2.55rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 16px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.signin-field input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.08em;
}

.signin-field input:focus {
  border-color: rgba(203, 170, 255, 0.55);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 3px rgba(158, 91, 255, 0.18);
}

.signin-submit {
  height: 2.9rem;
  border-radius: 0.8rem;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.signin-foot {
  margin-top: 1.1rem;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.4);
}

@keyframes signin-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes signin-beam {
  0% { left: -50%; opacity: 0.3; }
  45% { opacity: 0.9; }
  100% { left: 100%; opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .signin-card { animation: none; }
  .signin-beam { display: none; }
}

/* --------------------------------------------------------- glass panels */

.glass-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, rgba(26, 13, 50, 0.9) 0%, rgba(8, 4, 20, 0.88) 100%);
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(203, 170, 255, 0.05),
    0 0 50px -20px rgba(158, 91, 255, 0.4);
  backdrop-filter: blur(18px) saturate(140%);
}

.panel-head.center {
  text-align: center;
  align-items: center;
}

.panel-head.center .signin-title { font-size: 1.2rem; }
.panel-head.center .muted { margin-top: 0.2rem; }

/* -------------------------------------------------------------- user chip */

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
}

.user-chip strong { font-weight: 600; }

.role-badge {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.role-badge.owner {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
}

.role-badge.reseller {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
}

/* -------------------------------------------------------------- resellers */

.resellers-panel {
  margin-bottom: 1rem;
  padding: 1.2rem;
}

.reseller-form { display: flex; flex-direction: column; gap: 0.75rem; }

.reseller-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.reseller-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(4, 8, 16, 0.45);
  border: 1px solid var(--border);
}

.reseller-meta { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.reseller-meta small { font-size: 0.7rem; color: var(--muted); }
.reseller-actions { display: flex; gap: 0.35rem; }
.reseller-empty { padding: 0.8rem; text-align: center; color: var(--muted); font-size: 0.82rem; }

@media (max-width: 760px) {
  .reseller-row { flex-direction: column; align-items: stretch; }
  .reseller-actions { justify-content: flex-end; }
  .topbar-actions { flex-wrap: wrap; }
}

/* ------------------------------------------------ reseller screen */

.resellers-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.resellers-head h2 { font-size: 1.15rem; }
.resellers-head .muted { font-size: 0.82rem; }

.reseller-card {
  padding: 1.15rem;
  margin-bottom: 1rem;
}

.reseller-card .panel-head { margin-bottom: 0.9rem; }

/* --------------------------------------------------------- mobile polish */

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding: 0.55rem 0.8rem;
  }

  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-text strong { font-size: 0.9rem; }

  .topbar-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
    gap: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .user-chip { margin-right: auto; }

  .topbar-actions .btn {
    padding: 0.45rem 0.6rem;
    font-size: 0.78rem;
  }

  /* the row menu becomes a bottom sheet so it is never clipped by the table */
  .menu {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    top: auto;
    z-index: 95;
    min-width: 0;
    max-height: 60dvh;
    overflow-y: auto;
    padding: 0.4rem;
    border-radius: 14px;
  }

  .menu button {
    padding: 0.7rem 0.75rem;
    font-size: 0.92rem;
    text-align: center;
  }

  body.menu-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 94;
    background: rgba(3, 1, 12, 0.6);
    backdrop-filter: blur(2px);
  }
}



