
:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #16181d;
  --text-muted: #61666f;
  --accent: #b3242c;
  --accent-text: #ffffff;
  --accent-soft: #fdeaea;
  --ok: #17795e;
  --ok-soft: #e3f5ef;
  --warn: #9a6100;
  --warn-soft: #fdf1de;
  --danger: #b3242c;
  --danger-soft: #fdeaea;
  --info: #1f5fa8;
  --info-soft: #e6f0fb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 18, 24, .06), 0 4px 16px rgba(16, 18, 24, .05);
  --font: "Vazirmatn", "IRANSans", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23262d;
    --border: #333842;
    --text: #eceef2;
    --text-muted: #99a0ac;
    --accent: #e4646a;
    --accent-text: #1a0c0d;
    --accent-soft: #2e1d1f;
    --ok: #4fd1a5;
    --ok-soft: #16302a;
    --warn: #e3b062;
    --warn-soft: #322718;
    --danger: #f08a8f;
    --danger-soft: #331c1e;
    --info: #7ab4f0;
    --info-soft: #17242f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

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

h1, h2, h3 { line-height: 1.35; margin: 0 0 .6rem; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }

code, .mono { font-family: var(--mono); font-size: .85em; direction: ltr; unicode-bidi: embed; }

/* ─── Checkout ──────────────────────────────────────────────────────────── */

.checkout {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__head {
  padding: 1.4rem 1.5rem 1.1rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.card__logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  object-fit: cover;
  margin-bottom: .6rem;
  border: 1px solid var(--border);
}
.card__brand { font-size: .78rem; color: var(--text-muted); letter-spacing: .02em; }
.card__title { font-size: 1.2rem; margin: .15rem 0 0; }
.card__body { padding: 1.25rem 1.5rem 1.5rem; }

.rows { display: grid; gap: .1rem; margin-bottom: 1.1rem; }
.row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .62rem 0;
  border-bottom: 1px dashed var(--border);
}
.row:last-child { border-bottom: 0; }
.row__label { color: var(--text-muted); font-size: .87rem; flex-shrink: 0; }
.row__value { font-weight: 600; text-align: left; overflow-wrap: anywhere; }

.amount {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: .9rem 1rem;
  margin-bottom: 1.1rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.amount__label { color: var(--text-muted); font-size: .87rem; }
.amount__value { font-size: 1.35rem; font-weight: 700; }

.uid {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .1rem .4rem;
  font-size: .85em;
  direction: ltr;
  display: inline-block;
}

.btn {
  display: block; width: 100%;
  padding: .8rem 1rem;
  border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 700; font-size: 1rem;
  cursor: pointer;
  text-align: center;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn--sm { width: auto; display: inline-block; padding: .38rem .8rem; font-size: .85rem; }
.btn--danger { background: var(--danger); color: #fff; }

.note { font-size: .8rem; color: var(--text-muted); text-align: center; margin: .85rem 0 0; }

.result { text-align: center; }
.result__icon {
  width: 64px; height: 64px; margin: 0 auto .8rem;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2rem;
}
.result__icon--ok { background: var(--ok-soft); color: var(--ok); }
.result__icon--bad { background: var(--danger-soft); color: var(--danger); }
.result__icon--wait { background: var(--warn-soft); color: var(--warn); }

/* ─── Badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--muted { background: var(--surface-2); color: var(--text-muted); }

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

.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: 1.1rem .85rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.sidebar__brand {
  font-weight: 800; font-size: 1.05rem;
  padding: .3rem .6rem 1rem;
  display: flex; align-items: center; gap: .4rem;
}
.sidebar a {
  display: block;
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .92rem;
}
.sidebar a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar__spacer { flex: 1; }
.sidebar__user {
  border-top: 1px solid var(--border);
  padding-top: .7rem; margin-top: .7rem;
  font-size: .82rem; color: var(--text-muted);
}

.main { flex: 1; min-width: 0; padding: 1.5rem 1.75rem 3rem; }
.main__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto; flex-direction: row; flex-wrap: wrap;
    border-inline-start: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar__brand { width: 100%; padding-bottom: .5rem; }
  .sidebar__spacer { display: none; }
  .sidebar__user { width: 100%; }
  .main { padding: 1.1rem; }
}

/* ─── Panels, tables, forms ─────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.panel__head {
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
}
.panel__head h2, .panel__head h3 { margin: 0; }
.panel__body { padding: 1.1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .95rem 1.1rem;
}
.stat__label { font-size: .82rem; color: var(--text-muted); }
.stat__value { font-size: 1.45rem; font-weight: 700; margin-top: .1rem; }
.stat__sub { font-size: .78rem; color: var(--text-muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { padding: .6rem .8rem; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-weight: 600; font-size: .82rem; color: var(--text-muted); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; }
.table-empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); }

form.stack { display: grid; gap: .85rem; }
.field { display: grid; gap: .3rem; }
.field > label { font-size: .85rem; font-weight: 600; }
.field__hint { font-size: .78rem; color: var(--text-muted); }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], input[type=search], select, textarea {
  width: 100%;
  padding: .52rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: .92rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info); outline-offset: -1px; }
textarea { min-height: 88px; resize: vertical; font-family: var(--mono); direction: ltr; }
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: .45rem; font-size: .9rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; align-items: end; }

.alert {
  padding: .7rem .95rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .9rem;
  border: 1px solid transparent;
}
.alert--ok { background: var(--ok-soft); color: var(--ok); border-color: currentColor; }
.alert--error { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.alert--info { background: var(--info-soft); color: var(--info); border-color: currentColor; }
.alert code { background: rgba(127,127,127,.15); padding: .1rem .35rem; border-radius: 4px; user-select: all; }

.pager { display: flex; gap: .4rem; align-items: center; justify-content: center; padding: .9rem; flex-wrap: wrap; }
.pager a, .pager span {
  padding: .3rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text);
}
.pager .is-active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.pager .is-disabled { opacity: .45; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 1.2rem .95rem 0;
  border-inline-start: 2px solid var(--border);
  margin-inline-start: .35rem;
}
.timeline li::before {
  content: "";
  position: absolute; inset-inline-start: -6px; top: .55rem;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border);
}
.timeline li:last-child { border-inline-start-color: transparent; }
.timeline__type { font-weight: 600; font-size: .88rem; }
.timeline__meta { font-size: .78rem; color: var(--text-muted); }
.timeline__data {
  font-family: var(--mono); font-size: .76rem; direction: ltr;
  background: var(--surface-2); border-radius: 6px;
  padding: .35rem .55rem; margin-top: .3rem;
  white-space: pre-wrap; word-break: break-all;
}

.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 1.25rem;
}
.auth .card { max-width: 380px; }

.secret-box {
  font-family: var(--mono); font-size: .82rem; direction: ltr;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem;
  margin: .4rem 0;
  word-break: break-all;
  user-select: all;
}
