:root {
  --bg: #0e0720;
  --bg2: #150b2e;
  --card: #1a0f36;
  --line: rgba(255, 215, 0, 0.55);
  --line-soft: rgba(255, 255, 255, 0.1);
  --gold: #ffd700;
  --gold2: #f5b301;
  --text: #f4f0ff;
  --muted: #a99fc6;
  --ok: #22c55e;
  --bad: #ef4444;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #2a1360 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}
[hidden] { display: none !important; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.card {
  background: linear-gradient(180deg, rgba(42, 22, 88, 0.55), rgba(20, 11, 46, 0.9));
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 18px;
}

input, select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 0, 0.35);
  background: #0f0824;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
select:disabled { opacity: 0.5; }
label { display: block; margin-bottom: 12px; font-weight: 600; }

button { font: inherit; cursor: pointer; border-radius: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.gold {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  font-weight: 800;
  color: #2a1700;
  background: linear-gradient(180deg, #ffe680, var(--gold2));
  box-shadow: 0 0 18px rgba(255, 199, 0, 0.35);
}
.ghost {
  padding: 8px 14px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.link { background: none; border: 0; color: var(--muted); margin-top: 8px; }

/* sign-in */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(420px, 100%); border-color: var(--line); }
.brand { font-size: 20px; color: var(--gold); }
.brand b { color: #fff; }
.brand.big { font-size: 22px; margin-bottom: 18px; text-align: center; }
.crown { margin-inline-end: 6px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  flex-wrap: wrap;
}
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.partner-chip {
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 8px 12px; background: rgba(255,255,255,0.04);
}
.ok { color: #fff; background: var(--ok); border-radius: 50%; padding: 0 5px; font-size: 12px; }
.shield { border: 1px solid var(--line); background: rgba(255, 215, 0, 0.12); padding: 7px 10px; }

/* KPIs */
.kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 24px;
}
.kpi { border-color: var(--line); box-shadow: 0 0 22px rgba(255, 199, 0, 0.12); text-align: center; }
.kpi-title { font-size: 16px; margin-bottom: 8px; }
.kpi-value { font-size: 30px; font-weight: 900; color: var(--gold); }
.kpi-pills { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px;
  background: rgba(255, 215, 0, 0.08); color: var(--gold);
}

/* main grid */
.grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; padding: 0 24px 24px; }
.recharge { border-color: var(--line); align-self: start; }
.member {
  display: flex; align-items: center; gap: 10px; margin: -4px 0 12px;
  border: 1px solid rgba(34, 197, 94, 0.6); background: rgba(34, 197, 94, 0.1);
  border-radius: 10px; padding: 8px 10px;
}
.member img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #2a1d4f; }
.member .verified { margin-inline-start: auto; color: var(--ok); border: 1px solid var(--ok); border-radius: 8px; padding: 1px 8px; font-size: 12px; }
.member.err { border-color: var(--bad); background: rgba(239, 68, 68, 0.1); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 4px; font-weight: 600; }
#vip-level, #item { margin: 0 0 12px; }
.switch { position: relative; width: 44px; height: 24px; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; margin: 0; }
.switch span {
  position: absolute; inset: 0; background: #3b3355; border-radius: 999px; transition: background 0.15s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch input:checked + span { background: var(--gold2); }
.switch input:checked + span::after { transform: translateX(-20px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); }

.ledger-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.filters input, .filters select { margin-top: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: start; color: var(--muted); font-weight: 600; background: rgba(255,255,255,0.05); padding: 12px; }
tbody td { padding: 14px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.done { color: var(--ok); }
.receipt-btn { background: none; border: 0; color: var(--gold); font-size: 18px; padding: 2px 6px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }

dialog { border: 1px solid var(--line); color: var(--text); max-width: min(440px, 92vw); width: 100%; }
dialog::backdrop { background: rgba(5, 2, 14, 0.7); }
dialog pre { white-space: pre-wrap; background: #0f0824; padding: 12px; border-radius: 10px; font-family: inherit; }
dialog form + form { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
dialog input { margin-bottom: 8px; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row > * { flex: 1; }

#toast {
  position: fixed; bottom: 20px; inset-inline: 16px; margin: auto; max-width: 420px;
  background: #241449; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; text-align: center;
  z-index: 10;
}
#toast.bad { border-color: var(--bad); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; padding: 16px; }
  .grid { padding: 0 16px 16px; }
  .topbar { padding: 12px 16px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 26px; }
}
