/* Voltrix — gold on charcoal / gold on ivory */
:root, [data-theme="dark"] {
  --bg: #0C0C0E; --side: #111114; --card: #16161A; --card2: #1E1E23; --line: #2A2A31;
  --text: #F3EFE7; --muted: #A8A196; --gold: #D6B06A; --track: #26262C; --on-gold: #17120A;
  --ok-bg: rgba(110,200,150,.14); --ok: #86D9AE; --warn-bg: rgba(240,180,80,.11); --warn: #F2C26B; --warn-line: rgba(240,180,80,.35);
  --bad-bg: rgba(240,110,110,.13); --bad: #F5A3A3; --info-bg: rgba(214,176,106,.10); --wm: .035;
  --grad: linear-gradient(135deg, #F0D9A6 0%, #D2AE68 50%, #B08A47 100%);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F7F4ED; --side: #FFFFFF; --card: #FFFFFF; --card2: #F4EFE5; --line: #E6DECD;
  --text: #1D1A15; --muted: #655E51; --gold: #86662B; --track: #ECE5D7; --on-gold: #1D1A15;
  --ok-bg: #E2F3E9; --ok: #1E6E45; --warn-bg: #FCF3DF; --warn: #83560A; --warn-line: #EBD3A0;
  --bad-bg: #FBE5E5; --bad: #9E2A2A; --info-bg: #F6EEDD; --wm: .05;
  --shadow: 0 10px 30px rgba(60,45,20,.10);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --bg: #F7F4ED; --side: #FFFFFF; --card: #FFFFFF; --card2: #F4EFE5; --line: #E6DECD;
    --text: #1D1A15; --muted: #655E51; --gold: #86662B; --track: #ECE5D7; --on-gold: #1D1A15;
    --ok-bg: #E2F3E9; --ok: #1E6E45; --warn-bg: #FCF3DF; --warn: #83560A; --warn-line: #EBD3A0;
    --bad-bg: #FBE5E5; --bad: #9E2A2A; --info-bg: #F6EEDD; --wm: .05;
    --shadow: 0 10px 30px rgba(60,45,20,.10);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
  font-family: 'Tajawal', 'Inter', system-ui, sans-serif;
}
html[lang="en"] body { font-family: 'Inter', 'Tajawal', system-ui, sans-serif; }
a { color: var(--gold); }
a:hover { opacity: .85; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.num { font-family: 'Josefin Sans', 'Inter', sans-serif; font-weight: 600; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.gold-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- layout ---------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; position: relative; }
.side {
  flex: 1 1 248px; max-width: 100%; background: var(--side); border-inline-end: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 22px;
}
.side .brand img { width: 168px; height: auto; display: block; }
.side .brand span { display: block; font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; min-height: 44px;
  color: var(--muted); text-decoration: none;
}
.nav a:hover { background: var(--card2); color: var(--text); opacity: 1; }
.nav a[aria-current="page"] { background: var(--card2); color: var(--gold); font-weight: 700; }
.nav .group { font-size: 11px; letter-spacing: 1.5px; color: var(--muted); padding: 14px 12px 4px; text-transform: uppercase; }
.nav .badge, .badge {
  margin-inline-start: auto; font-size: 12px; font-weight: 700; background: var(--grad); color: var(--on-gold);
  border-radius: 999px; padding: 1px 8px; line-height: 1.6;
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-foot .row { display: flex; gap: 8px; }
.side-foot form { margin: 0; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--grad); color: var(--on-gold);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.userbox .who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.userbox .who b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 22px; position: relative; }
.side .menu-btn { display: none; }
@media (max-width: 860px) {
  .stat .v { font-size: 24px; }
  .watermark { grid-template-columns: repeat(2, 1fr); font-size: 15px; }
  .side { padding: 12px 14px; gap: 12px; flex-direction: row; flex-wrap: wrap; align-items: center; position: sticky; top: 0; z-index: 20; }
  .side .brand img { width: 128px; }
  .side .brand span { display: none; }
  .side .menu-btn { display: inline-flex; margin-inline-start: auto; }
  .side .nav, .side .side-foot { display: none; width: 100%; }
  .side.open .nav, .side.open .side-foot { display: flex; }
  .main { padding: 18px 14px 48px; }
}

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.topbar .title { flex: 1 1 240px; display: flex; flex-direction: column; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; }
.sub { background: var(--card2); border-radius: 12px; padding: 12px 14px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min, 300px)), 1fr)); align-items: start; }
.grid.fill { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 300px)), 1fr)); }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.stat .v { font-family: 'Josefin Sans', 'Inter', sans-serif; font-size: 30px; font-weight: 600; line-height: 1.2; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.alert .v { color: var(--warn); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 14px; background: var(--card2); border-radius: 12px; }
.item .grow { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 11px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); opacity: 1; }
.btn-gold { background: var(--grad); color: var(--on-gold); border: 0; font-weight: 800; }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 44px; padding: 0; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: inline; margin: 0; }

/* ---------- forms ---------- */
form.stack, .stack { display: flex; flex-direction: column; gap: 16px; }
.fields { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.field .err, .err { color: var(--bad); font-weight: 600; font-size: 12px; }
.input, select.input, textarea.input {
  min-height: 46px; width: 100%; padding: 0 14px; background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; font: inherit; font-size: 15px; font-weight: 400;
}
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input:focus { border-color: var(--gold); outline: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: #D2AE68; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0; }
legend { padding: 0 8px; font-weight: 700; font-size: 14px; color: var(--gold); }
.searchbox { flex: 1 1 320px; max-width: 480px; display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-height: 46px; color: var(--muted); }
.searchbox input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .field { min-width: 150px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
table.t th { text-align: start; font-weight: 500; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t a { text-decoration: none; font-weight: 700; color: var(--text); }
table.t a:hover { color: var(--gold); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.paid, .chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.pending, .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.refunded, .chip.chargeback, .chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.neutral { background: var(--card2); color: var(--muted); }
.chip.gold { background: var(--info-bg); color: var(--gold); }

/* ---------- alerts ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; font-size: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.info { background: var(--warn-bg); color: var(--text); border-color: var(--warn-line); }
.notice { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px 18px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); }
.diamond { width: 9px; height: 9px; transform: rotate(45deg); flex: none; display: inline-block; background: currentColor; }

/* ---------- progress ---------- */
.bar { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 48px 18px; position: relative; overflow: hidden; }
.auth::before, .auth::after { content: ""; position: absolute; top: 50%; left: 50%; border: 1px solid var(--line); transform: translate(-50%, -50%) rotate(45deg); pointer-events: none; }
.auth::before { width: min(760px, 120vw); height: min(760px, 120vw); }
.auth::after { width: min(700px, 110vw); height: min(700px, 110vw); opacity: .6; }
.auth-card { position: relative; z-index: 1; width: 100%; max-width: 430px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 36px 32px; display: flex; flex-direction: column; gap: 20px; box-shadow: var(--shadow); }
.auth-card .logo { width: 210px; align-self: center; }
.auth-tools { position: absolute; top: 18px; inset-inline-end: 18px; display: flex; gap: 8px; z-index: 2; }
.steps { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.steps i { width: 28px; height: 4px; border-radius: 999px; background: var(--track); }
.steps i.on { background: var(--grad); }
.code-input { text-align: center; letter-spacing: 10px; font-family: 'Josefin Sans', sans-serif; font-size: 26px; font-weight: 600; min-height: 58px; }
.secret { font-family: 'Inter', monospace; font-size: 17px; letter-spacing: 2px; text-align: center; padding: 12px; background: var(--card2); border-radius: 12px; overflow-wrap: anywhere; direction: ltr; }

/* ---------- employee protections ---------- */
.watermark {
  position: fixed; inset: -20%; pointer-events: none; z-index: 50; opacity: var(--wm);
  display: grid; grid-template-columns: repeat(4, 1fr); align-content: space-around; justify-items: center; gap: 110px;
  transform: rotate(-18deg); font-family: 'Josefin Sans', sans-serif; font-size: 20px; letter-spacing: 3px; color: var(--text);
  user-select: none; white-space: nowrap;
}
body.protect { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.protect input, body.protect textarea, body.protect select { -webkit-user-select: text; user-select: text; }
@media print { body.protect * { display: none !important; } }

/* ---------- dialog ---------- */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 24px; max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog .actions { justify-content: flex-end; margin-top: 18px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; }
.copy-btn[data-done="1"] { color: var(--ok); border-color: var(--ok); }
details.more > summary { cursor: pointer; color: var(--gold); font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
pre.payload { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: var(--card2); padding: 10px; border-radius: 10px; margin: 0; direction: ltr; text-align: left; }

/* ---------- phase 2 ---------- */
.span-wide { grid-column: span 2; min-width: 0; }
@media (max-width: 1100px) { .span-wide { grid-column: auto; } }
.money-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.money-row:last-child { border-bottom: 0; }
.money-row .v { font-family: 'Josefin Sans', 'Inter', sans-serif; font-weight: 600; font-size: 18px; direction: ltr; }
.delta { font-size: 12px; font-weight: 700; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) 80px; gap: 12px; align-items: center; font-size: 14px; }
.hbar .v { font-family: 'Josefin Sans', 'Inter', sans-serif; font-weight: 600; direction: ltr; text-align: end; }
input.mini { min-height: 40px; max-width: 160px; }
