:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --saman: #0ea5a4;
  --parsian: #b8860b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  direction: rtl;
  font-size: 14px;
  line-height: 1.6;
}

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

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--saman), var(--parsian));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.topbar-links { display: flex; gap: 4px; align-items: center; }
.topbar-links a {
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
}
.topbar-links a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.topbar-links a.active { color: #fff; background: rgba(255, 255, 255, 0.12); }

/* ---------- Layout ---------- */
.container { max-width: 1160px; margin: 24px auto; padding: 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin: 0 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.mono { font-family: Consolas, "Courier New", monospace; direction: ltr; font-size: 12px; }
code {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  direction: ltr;
  display: inline-block;
  font-size: 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat .stat-label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat.accent-success .stat-value { color: var(--success); }
.stat.accent-saman { border-top: 3px solid var(--saman); }
.stat.accent-parsian { border-top: 3px solid var(--parsian); }

/* ---------- Distribution bars ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 42px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.bar-label { color: var(--muted); text-align: left; }
.bar-track { background: #eef2f7; border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; min-width: 3px; }
.bar-count { font-weight: 600; text-align: left; }

/* ---------- Status badges ---------- */
.status {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-paid { background: #dbeafe; color: #1e40af; }
.status-verified, .status-confirmed { background: #d1fae5; color: #065f46; }
.status-reversed { background: #ede9fe; color: #5b21b6; }
.status-canceled, .status-expired { background: #e5e7eb; color: #374151; }
.status-failed { background: #fee2e2; color: #991b1b; }

/* bar colors */
.bar-fill.status-pending { background: #f59e0b; }
.bar-fill.status-paid { background: #3b82f6; }
.bar-fill.status-verified, .bar-fill.status-confirmed { background: #16a34a; }
.bar-fill.status-reversed { background: #8b5cf6; }
.bar-fill.status-canceled, .bar-fill.status-expired { background: #9ca3af; }
.bar-fill.status-failed { background: #ef4444; }

/* ---------- Buttons ---------- */
button, .button-link {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover, .button-link:hover { background: var(--primary-dark); text-decoration: none; }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
button.neutral { background: #64748b; }
button.neutral:hover { background: #475569; }
button.success { background: var(--success); }
button.success:hover { background: #15803d; }
button.small { padding: 5px 10px; font-size: 12px; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 52px; height: 28px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background .2s;
  cursor: pointer;
}
.switch .slider:before {
  content: "";
  position: absolute; height: 22px; width: 22px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider:before { transform: translateX(24px); }

/* ---------- Forms / filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters select, .filters input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}
.setting-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.setting-row .hint { font-size: 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.tx-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tx-table th, .tx-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.tx-table th { color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.tx-table tbody tr:hover { background: #f8fafc; }
.actions { display: flex; gap: 6px; }
.actions form { margin: 0; }
.actions button { padding: 5px 10px; font-size: 11px; background: #475569; }
.actions button:hover { background: #334155; }

/* ---------- Payment pages ---------- */
.gateway-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.gateway.saman { border-top: 4px solid var(--saman); }
.gateway.parsian { border-top: 4px solid var(--parsian); }
.gateway.saman h1 { color: var(--saman); }
.gateway.parsian h1 { color: var(--parsian); }

.mock-badge {
  background: #f59e0b;
  color: #111827;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.summary div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.summary span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }

.simulate-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.simulate-actions button { font-size: 15px; padding: 12px 22px; }

/* ---------- Landing / misc ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 7px 4px; border-bottom: 1px dashed var(--border); vertical-align: top; font-size: 13px; }
table.kv td:first-child { color: var(--muted); width: 44%; }
.links { padding-inline-start: 18px; margin: 0; }
.links li { margin-bottom: 6px; }

.error-card { border-top: 4px solid var(--danger); }
.error-card h1 { color: var(--danger); }

.hint { color: var(--muted); font-size: 12px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

/* ---------- Endpoints (home + docs) ---------- */
.method {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: .5px;
  direction: ltr;
  white-space: nowrap;
}
.method.post { background: #dbeafe; color: #1d4ed8; }
.method.get { background: #d1fae5; color: #065f46; }
.method.soap { background: #ede9fe; color: #5b21b6; }

.endpoint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.endpoint:last-child { border-bottom: 0; }
.endpoint .ep-name { color: var(--muted); font-size: 13px; }
.endpoint .ep-route { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.endpoint .ep-route code { font-size: 11.5px; overflow-wrap: anywhere; }

/* ---------- Docs ---------- */
.doc-section { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 18px; }
.doc-section h3 { font-size: 15px; margin: 0 0 8px; }
.doc-section p { margin: 6px 0; }

pre.codeblock {
  direction: ltr;
  text-align: left;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  margin: 10px 0;
}
pre.codeblock code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  display: block;
  max-width: none;
  overflow-wrap: normal;
  white-space: pre;
  font-size: inherit;
}

.credential-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.credential { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.credential span { display: block; color: var(--muted); font-size: 12px; }
.credential b { direction: ltr; display: inline-block; }
