/* Maghzeto admin panel.
   Palette is lifted from Maghzeto/docs/design-v4-editorial-CURRENT.md so the
   panel reads as the same brand, but the SPACING is not: the public site is
   editorial and airy, an admin panel is a dense instrument. Same colors,
   tighter rhythm, smaller type.

   Layout: sidebar pinned RIGHT, content flows LEFT (RTL, and the user's own
   explicit request). Fonts are self-hosted Vazirmatn -- no Google CDN,
   per the project's font convention. */

@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/vazirmatn-arabic.woff2') format('woff2');
}
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/vazirmatn-latin.woff2') format('woff2');
}

:root {
  --bg: #FAFAFB;
  --panel: #FFFFFF;
  --surface: #F2F2F3;
  --ink: #17191C;
  --muted: #777B86;
  --faint: #979799;
  --placeholder: #A3A6AF;
  --border: #ECECEC;

  --accent-bg: #FBE1D1;
  --accent-ink: #5D2A1A;
  --mint-bg: #DFF5E3;
  --mint-ink: #14532D;
  --danger-bg: #FBEAE6;
  --danger-ink: #A1402F;

  --sidebar-w: 244px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow-soft: 0 1px 2px rgba(23, 25, 28, .04), 0 8px 24px rgba(23, 25, 28, .05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

/* Sidebar is written first in the DOM but sits right via flex order in RTL --
   no absolute positioning, so it stays a normal scrollable column. */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar__brand b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.sidebar__brand span { display: block; font-size: 11.5px; color: rgba(255, 255, 255, .45); margin-top: 2px; }

.sidebar__nav { padding: 12px 10px; flex: 1; overflow-y: auto; }

.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: rgba(255, 255, 255, .66);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.navitem:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.navitem--active { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; }
.navitem__icon { font-size: 13px; opacity: .8; width: 16px; text-align: center; }
.navitem__phase {
  margin-inline-start: auto;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .5);
}

.sidebar__foot {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12.5px;
  color: rgba(255, 255, 255, .5);
}
.sidebar__foot b { display: block; color: #fff; font-size: 13.5px; font-weight: 600; }
.sidebar__foot a { color: rgba(255, 255, 255, .55); }
.sidebar__foot a:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 13px; }

.content { padding: 24px 28px 56px; }

/* ---------------------------------------------------------------- primitives */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.card__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.card__head h2 { font-size: 14.5px; margin: 0; font-weight: 700; }
.card__head .hint { font-size: 12px; color: var(--faint); }

.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
/* Three compact stats side by side inside a card -- grid--kpi's 190px
   minimum collapses to one column at card width, which is why this exists. */
.grid--triple { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat__label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.stat__value { font-size: 23px; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; }
@media (max-width: 1080px) { .grid--2 { grid-template-columns: 1fr; } }

.section { margin-bottom: 16px; }

/* KPI tile */
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.kpi__label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.kpi__value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.kpi__value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-inline-start: 3px; }
.kpi__meta { font-size: 12px; color: var(--faint); margin-top: 4px; }
.kpi--accent { background: var(--accent-bg); border-color: transparent; color: var(--accent-ink); }
.kpi--accent .kpi__label, .kpi--accent .kpi__meta { color: rgba(93, 42, 26, .68); }

.delta { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: var(--r-pill); }
.delta--up { background: var(--mint-bg); color: var(--mint-ink); }
.delta--down { background: var(--danger-bg); color: var(--danger-ink); }
.delta--flat { background: var(--surface); color: var(--muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--faint); font-size: 11.5px; font-weight: 700; letter-spacing: .01em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FCFCFD; }
td.num, th.num { font-variant-numeric: tabular-nums; }
td.ltr { direction: ltr; text-align: left; font-size: 12.5px; color: var(--muted); }

.tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}
.tag--paid { background: var(--mint-bg); color: var(--mint-ink); }
.tag--pending { background: var(--accent-bg); color: var(--accent-ink); }
.tag--failed { background: var(--danger-bg); color: var(--danger-ink); }

.empty { color: var(--muted); font-size: 13.5px; padding: 26px 0; text-align: center; }

/* Bar list (revenue by test) — CSS bars, no chart library, no CDN. */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar__top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar__top b { font-weight: 600; }
.bar__top span { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar__track { height: 7px; background: var(--surface); border-radius: var(--r-pill); overflow: hidden; }
.bar__fill { height: 100%; background: var(--ink); border-radius: var(--r-pill); }

/* Health strip */
.health { display: flex; flex-wrap: wrap; gap: 8px; }
.health__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }

/* A connected source pulses; a broken one sits still and red. The motion is
   the signal -- a static green dot and a stale page look identical, a
   pulsing one says the page is live. */
.dot--ok {
  background: #22C55E;
  animation: dot-pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;
}
.dot--bad { background: #E0483A; box-shadow: 0 0 0 3px rgba(224, 72, 58, .16); }

@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Someone who has asked their OS to reduce motion gets the colour without
   the animation -- the dot still reads as connected. */
@media (prefers-reduced-motion: reduce) {
  .dot--ok { animation: none; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
}

.note {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 12px;
}
.note b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 78% -12%, #FBE1D1 0%, rgba(251, 225, 209, 0) 62%),
    var(--bg);
}
.login {
  width: 100%;
  max-width: 384px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 30px;
  box-shadow: var(--shadow-soft);
}
.login__brand { font-size: 19px; font-weight: 800; margin-bottom: 3px; }
.login__sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.field { margin-bottom: 14px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=tel] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 14.5px;
  background: var(--panel);
  color: var(--ink);
}
input::placeholder { color: var(--placeholder); }
input:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: transparent; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
.btn:hover { opacity: .9; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--ink); }

.error, .success {
  border-radius: var(--r-md);
  padding: 10px 13px;
  font-size: 13px;
  margin-bottom: 16px;
}
.error { background: var(--danger-bg); color: var(--danger-ink); }
.success { background: var(--mint-bg); color: var(--mint-ink); }

.otp-input {
  text-align: center;
  letter-spacing: .45em;
  font-size: 20px !important;
  font-weight: 700;
  padding-inline-start: .45em !important;
}

.pager { display: flex; gap: 8px; margin-top: 16px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar__nav { display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
  .navitem { white-space: nowrap; margin: 0; }
  .navitem__phase { display: none; }
  .sidebar__foot { display: flex; justify-content: space-between; align-items: center; }
  .content, .topbar { padding-inline: 16px; }
}
