/* Noor admin panel — design system. Server-rendered, no build step. */

@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
             font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
             font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
             font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #101828;
  --text-2: #5a6478;
  --muted: #8a93a6;
  --line: #e6e8ef;
  --line-strong: #d4d8e3;
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --ok: #0f9d58;
  --ok-soft: #e6f6ee;
  --warn: #b76e00;
  --warn-soft: #fdf1dd;
  --bad: #d92d20;
  --bad-soft: #fdecea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 236px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --surface: #141922;
    --surface-2: #1a212c;
    --text: #e9edf5;
    --text-2: #a4adbe;
    --muted: #79839a;
    --line: #232c3a;
    --line-strong: #2f3a4c;
    --accent: #7c83ff;
    --accent-soft: #1e2340;
    --ok: #46d18a;
    --ok-soft: #123024;
    --warn: #f0b44a;
    --warn-soft: #33270f;
    --bad: #ff6b62;
    --bad-soft: #3a1714;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -18px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", "SF Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
p { margin: 0 0 10px; }
bdi, .num, code, input, .ltr { font-variant-numeric: tabular-nums; }

/* ── layout ── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface);
  border-inline-start: 1px solid var(--line); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 14px; gap: 4px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 17px; flex: none;
}
.logo b { display: block; font-size: 15px; line-height: 1.3; }
.logo span { display: block; color: var(--muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav a .ic { width: 18px; text-align: center; font-size: 15px; }
.nav a .count {
  margin-inline-start: auto; background: var(--bad); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 0 7px; font-weight: 700;
}
.sidebar .bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.who { color: var(--muted); font-size: 12px; padding: 0 10px 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: 14px 24px; display: flex; align-items: center; gap: 14px;
}
.topbar .sub { color: var(--muted); font-size: 12.5px; }
.content { padding: 22px 24px 60px; max-width: 1180px; width: 100%; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap;
    align-items: center; border-inline-start: 0; border-bottom: 1px solid var(--line); padding: 10px 14px;
  }
  .logo { padding: 0 8px 0 0; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav a { padding: 7px 9px; }
  .nav a .ic { display: none; }
  .sidebar .bottom { margin: 0; padding: 0; border: 0; }
  .who { display: none; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
}

/* ── cards ── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card > h2 { margin-bottom: 4px; }
.card > .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { flex: 1; }

/* ── KPI grid ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.kpi .label { color: var(--text-2); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; line-height: 1.35; }
.kpi .value.sm { font-size: 18px; }
.kpi .foot { color: var(--muted); font-size: 11.5px; }
.kpi.attention { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); }
.kpi.attention .value { color: var(--warn); }
.kpi.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); }
.kpi.danger .value { color: var(--bad); }
.kpi a { color: inherit; }

/* ── tables ── */
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; padding: 0 2px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: start; color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .02em;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  text-transform: uppercase; background: var(--surface-2);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ── badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.badge.gray { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ── buttons & forms ── */
.btn, button {
  font: inherit; font-weight: 600; font-size: 13px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.4; white-space: nowrap;
}
button:hover { filter: brightness(1.07); }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; color: var(--text-2); border-color: var(--line-strong); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.ok { background: var(--ok); }
button.warn { background: var(--warn); }
button.danger { background: var(--bad); }
button.sm { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  font: inherit; font-size: 13.5px; width: 100%; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
         linear-gradient(135deg, var(--muted) 50%, transparent 50%);
         background-position: 14px calc(50% + 1px), 19px calc(50% + 1px); background-size: 5px 5px, 5px 5px;
         background-repeat: no-repeat; padding-inline-start: 32px; }
label { font-size: 13px; font-weight: 500; }

/* switch for booleans */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(-18px); }

/* settings rows */
.field { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.field:last-child { border-bottom: 0; padding-bottom: 0; }
.field .meta { flex: 1 1 46%; min-width: 0; }
.field .meta .desc { color: var(--muted); font-size: 12px; line-height: 1.6; }
.field .control { flex: 1 1 54%; max-width: 420px; }
.field.stacked { flex-direction: column; align-items: stretch; gap: 8px; }
.field.stacked .control { max-width: none; }

/* generic rows / toolbars */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > .grow { flex: 1; min-width: 160px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.mono, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; direction: ltr; display: inline-block; max-width: 100%;
  overflow-wrap: anywhere; unicode-bidi: embed;
}
/* copy-to-clipboard values */
.copyable {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  cursor: pointer; vertical-align: middle;
}
.copyable > code { cursor: pointer; }
td .copyable > code { white-space: nowrap; }  /* .table-wrap scrolls instead of wrapping mid-token */
.copy-btn {
  all: unset; flex: none; cursor: pointer; width: 22px; height: 22px; line-height: 22px;
  text-align: center; border-radius: 6px; color: var(--muted); font-size: 12px;
  border: 1px solid transparent; transition: color .12s, background .12s, border-color .12s;
}
.copyable:hover .copy-btn { color: var(--accent); background: var(--accent-soft); border-color: var(--line); }
.copyable.copied > code { border-color: var(--ok); color: var(--ok); }
.copyable.copied .copy-btn { color: var(--ok); background: var(--ok-soft); border-color: transparent; }

/* paging footer */
.pager {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 2px; border-top: 1px solid var(--line);
}
.table-wrap + .pager { margin-top: 18px; }  /* cancel .table-wrap's negative bottom margin */
.pager .pages { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.pager .pbtn {
  padding: 6px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 12.5px; font-weight: 600; text-decoration: none;
}
.pager .pbtn:hover { background: var(--surface-2); color: var(--accent); border-color: var(--accent); }
.pager .pnow { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding: 0 4px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* flash toast */
.toast {
  margin: 16px 24px -4px; background: var(--surface); border: 1px solid var(--accent);
  border-inline-start-width: 4px; border-radius: var(--radius-sm); padding: 11px 14px;
  box-shadow: var(--shadow); font-weight: 500;
}

/* order/withdrawal item */
.item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.item:first-of-type { padding-top: 0; }
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.item .head .id { font-weight: 700; font-size: 14.5px; }
.item .facts { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin-bottom: 10px; }
.item .facts b { color: var(--text); font-weight: 600; }

details.inline-form { display: inline-block; }
details.inline-form > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-strong); color: var(--text-2);
}
details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form > summary:hover { background: var(--surface-2); color: var(--text); }
details.inline-form[open] > summary { border-color: var(--accent); color: var(--accent); }
details.inline-form .body { margin-top: 10px; }

details.block > summary {
  list-style: none; cursor: pointer; padding: 11px 0; font-weight: 600; display: flex;
  align-items: center; gap: 8px; border-bottom: 1px dashed var(--line);
}
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before { content: "▾"; color: var(--muted); font-size: 11px; }
details.block[open] > summary::before { content: "▴"; }

.sticky-save {
  position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 12px 0; margin-top: 6px;
  display: flex; gap: 12px; align-items: center;
}

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { max-width: 460px; width: 100%; text-align: center; }
.login-card .mark {
  width: 54px; height: 54px; border-radius: 16px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 26px; margin: 0 auto 14px;
}
.steps { text-align: start; color: var(--text-2); font-size: 13.5px; margin: 18px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; gap: 10px; padding: 7px 0; }
.steps .n {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none;
}
