/* ═══════════════════════════════════════════════════════════
   ORVEX AI — Owner Admin Panel
   Dense, utilitarian. Black & white, one accent.
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:      #0a0a0a;
  --panel:   #101010;
  --surface: #161616;
  --surface-2: #1d1d1d;
  --text:    #f2f2f2;
  --muted:   #808080;
  --dim:     #5c5c5c;
  --border:  #242424;
  --border-2:#303030;
  --accent:  #0d9488;
  --accent-hi: #14b8a6;
  --ok:   #22c55e;
  --warn: #f59e0b;
  --bad:  #ef4444;
  --r: 8px;
  --sidebar: 208px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1rem; }
h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 650; }

.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: .01em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ── login gate ────────────────────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(13,148,136,.10), transparent 55%), var(--bg);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
}
.gate-card .logo { margin-bottom: 22px; }
.gate-card h1 { font-size: 1.1rem; margin-bottom: 6px; }
.gate-card .sub { color: var(--muted); font-size: .86rem; margin: 0 0 24px; }

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 13px;
  margin-bottom: 16px;
  font-size: .86rem;
}
.who .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 700;
  flex: none;
}
.who .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── logo ──────────────────────────────────────────────── */

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .86rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.logo span { color: var(--muted); font-weight: 500; }
.logo .tag {
  font-size: .58rem;
  letter-spacing: .1em;
  color: var(--accent-hi);
  border: 1px solid rgba(13,148,136,.4);
  background: rgba(13,148,136,.1);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 2px;
}

/* ── shell ─────────────────────────────────────────────── */

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

.side {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-head { padding: 18px 16px 20px; border-bottom: 1px solid var(--border); }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: .87rem;
  margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(13,148,136,.13); color: var(--accent-hi); font-weight: 600; }
.nav-item svg { flex: none; opacity: .8; }
.nav-item .count {
  margin-left: auto;
  background: var(--bad);
  color: #fff;
  font-size: .64rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
}

.side-foot { border-top: 1px solid var(--border); padding: 12px 14px; font-size: .74rem; }
.side-foot .em { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
.side-foot a { color: var(--dim); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: rgba(10,10,10,.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1rem; }
.topbar .spacer { flex: 1; }
.topbar .refresh {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: .76rem;
  font-family: inherit;
  cursor: pointer;
}
.topbar .refresh:hover { color: var(--text); border-color: var(--border-2); }

.view { padding: 22px; flex: 1; }
.view > .lead { color: var(--muted); font-size: .82rem; margin: 0 0 20px; }

/* ── stat cards ────────────────────────────────────────── */

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px 16px;
}
.stat .label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 7px;
}
.stat .num {
  font-size: 1.7rem;
  font-weight: 660;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat .num.sm { font-size: 1.2rem; }
.stat .hint { font-size: .7rem; color: var(--dim); margin-top: 3px; }
.stat[data-k="active"] .num  { color: var(--ok); }
.stat[data-k="expired"] .num { color: var(--warn); }
.stat[data-k="banned"] .num  { color: var(--bad); }
.stat[data-k="nokey"] .num   { color: #9ca3af; }
.stat[data-k="revenue"] .num { color: var(--accent-hi); }

/* ── table ─────────────────────────────────────────────── */

.tablewrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  text-align: left;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 650;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody td.em { color: var(--text); }
tbody td .sub { color: var(--dim); font-size: .72rem; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--dim);
  font-size: .85rem;
}

/* ── status ────────────────────────────────────────────── */

.st { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; white-space: nowrap; }
.st .d { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.st[data-s="active"]  .d { background: var(--ok);   box-shadow: 0 0 8px rgba(34,197,94,.6); }
.st[data-s="expired"] .d { background: var(--warn); box-shadow: 0 0 8px rgba(245,158,11,.6); }
.st[data-s="banned"]  .d { background: var(--bad);  box-shadow: 0 0 8px rgba(239,68,68,.6); }
.st[data-s="no_key"]  .d { background: #6b7280; }
.st[data-s="unused"]  .d { background: #7dd3fc; }
.st[data-s="pending"] .d { background: var(--warn); }
.st[data-s="approved"].d,
.st[data-s="approved"] .d { background: var(--ok); }
.st[data-s="rejected"] .d { background: var(--bad); }
.st[data-s="revoked"]  .d { background: var(--bad); }
.st span { color: var(--muted); }
.st[data-s="banned"] span, .st[data-s="rejected"] span { color: #fca5a5; }
.st[data-s="active"] span, .st[data-s="approved"] span { color: #86efac; }
.st[data-s="expired"] span, .st[data-s="pending"] span { color: #fcd34d; }

/* ── chips / buttons ───────────────────────────────────── */

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { color: var(--text); border-color: var(--border-2); }
.chip.active { background: rgba(13,148,136,.14); border-color: rgba(13,148,136,.5); color: var(--accent-hi); font-weight: 600; }
.chip .n { opacity: .55; margin-left: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  border: 1px solid transparent;
  color: #fff;
  border-radius: 6px;
  padding: 8px 15px;
  font-size: .82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hi); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: transparent; border-color: rgba(239,68,68,.4); color: #f87171; }
.btn--danger:hover { background: rgba(239,68,68,.12); }
.btn--sm { padding: 5px 11px; font-size: .76rem; }
.btn--block { width: 100%; }

/* ── forms ─────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 11px;
  color: var(--text);
  font-family: inherit;
  font-size: .85rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field .hint { font-size: .72rem; color: var(--dim); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
}
.card > h3 { margin-bottom: 14px; }

.cols { display: grid; gap: 16px; }
@media (min-width: 900px) { .cols--2 { grid-template-columns: 1fr 1fr; } .cols--3 { grid-template-columns: 2fr 1fr; } }

/* ── drawer ────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 94vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 61;
  transform: translateX(102%);
  transition: transform .2s cubic-bezier(.2,0,0,1);
  display: flex;
  flex-direction: column;
}
.drawer.on { transform: none; }

.drawer-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.drawer-head .t { flex: 1; min-width: 0; }
.drawer-head .t h2 { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; }
.drawer-head .t p { margin: 2px 0 0; font-size: .74rem; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.x {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.x:hover { color: var(--text); background: var(--surface-2); }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: .8rem; margin-bottom: 18px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.sect { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.sect:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.sect h3 { margin-bottom: 10px; }

/* ── modal ─────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0,0,0,.7);
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(0,0,0,.7);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { font-size: 1.05rem; margin-bottom: 6px; }
.modal-card .sub { color: var(--muted); font-size: .82rem; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

.keybox {
  background: var(--panel);
  border: 1px dashed rgba(13,148,136,.5);
  border-radius: var(--r);
  padding: 18px;
  text-align: center;
  margin: 4px 0 14px;
}
.keybox .k {
  font-family: var(--mono);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent-hi);
  word-break: break-all;
}
.keybox .s { font-size: .72rem; color: var(--dim); margin-top: 7px; }

.warnbox {
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.3);
  color: #fcd34d;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: .76rem;
  margin-bottom: 14px;
}

.shot {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
  cursor: zoom-in;
  background: #000;
}

/* ── toast ─────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--r);
  font-size: .82rem;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  box-shadow: 0 12px 34px rgba(0,0,0,.6);
  max-width: 88vw;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast[data-k="err"] { border-color: rgba(239,68,68,.5); color: #fca5a5; }

/* ── demo flag ─────────────────────────────────────────── */

.demo-flag {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 90;
  background: rgba(20,20,20,.94);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: .64rem;
  letter-spacing: .1em;
  color: var(--accent-hi);
  font-weight: 700;
}
.demo-flag span { color: var(--dim); letter-spacing: 0; font-weight: 400; margin-left: 5px; }

/* ── misc ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--muted);
}
.badge--dup { background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.45); color: #f87171; }
.badge--b { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #f87171; }

.thumb {
  width: 46px; height: 34px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-2);
  background: #000;
  cursor: zoom-in;
  display: block;
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-hi); border-bottom-color: var(--accent); font-weight: 600; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.switch:last-child { border-bottom: 0; }
.switch .lab { color: var(--muted); font-size: .78rem; }
.tgl {
  width: 38px; height: 21px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background .15s, border-color .15s;
}
.tgl::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform .15s, background .15s;
}
.tgl.on { background: rgba(13,148,136,.3); border-color: var(--accent); }
.tgl.on::after { transform: translateX(17px); background: var(--accent-hi); }

.activity { font-size: .8rem; }
.activity .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.activity .row:last-child { border-bottom: 0; }
.activity .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }
.activity .what { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity .when { color: var(--dim); font-size: .72rem; white-space: nowrap; }

.copybtn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--dim);
  border-radius: 4px;
  font-size: .64rem;
  padding: 1px 6px;
  cursor: pointer;
  font-family: inherit;
  vertical-align: middle;
  margin-left: 6px;
}
.copybtn:hover { color: var(--text); }
