@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #16121f;
  --bg-2: #1e1830;
  --surface: #251d3a;
  --surface-2: #2e2547;
  --border: #3a2f56;
  --ink: #f0ecf8;
  --ink-dim: #b3a7cf;
  --ink-faint: #7d7299;
  --plum: #a855f7;
  --plum-soft: #7c3aed;
  --amber: #f5b945;
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -18px rgba(0,0,0,.7);
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(168,85,247,.12), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(245,185,69,.07), transparent 55%),
    var(--bg);
  color: var(--ink);
  direction: rtl;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--plum); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-inline-start: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 8px 20px;
  font-weight: 700; font-size: 18px;
  letter-spacing: -.3px;
}
.brand .dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--plum), var(--amber));
  display: grid; place-items: center; font-size: 16px;
  box-shadow: 0 6px 16px -6px rgba(168,85,247,.7);
}
.brand small { display:block; font-weight: 400; font-size: 11px; color: var(--ink-faint); }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  color: var(--ink-dim); font-size: 14.5px; font-weight: 500;
  border: 1px solid transparent; transition: .15s;
}
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(168,85,247,.18), transparent);
  color: var(--ink); border-color: var(--border);
}
.nav-item .ic { width: 19px; text-align: center; opacity: .85; }
.nav-spacer { flex: 1; }

.main { flex: 1; padding: 28px 34px; max-width: 1180px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 26px; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 23px; margin: 0; font-weight: 700; letter-spacing: -.4px; }
.topbar .sub { color: var(--ink-faint); font-size: 13px; margin-top: 2px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--ink-faint); font-size: 13px; }
.stat .value { font-size: 27px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.stat .value.accent { color: var(--amber); }
.stat .foot { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }

.section-title {
  font-size: 16px; font-weight: 700; margin: 30px 0 14px;
  display: flex; align-items: center; gap: 9px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--bg-2); font-size: 13.5px; }
th, td { padding: 12px 14px; text-align: right; white-space: nowrap; }
th { background: var(--surface); color: var(--ink-dim); font-weight: 600; font-size: 12.5px; position: sticky; top: 0; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface); }
td.wrap { white-space: normal; max-width: 240px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--green); background: rgba(52,211,153,.12); }
.badge.online { color: var(--green); background: rgba(52,211,153,.12); }
.badge.offline { color: var(--ink-faint); background: rgba(125,114,153,.14); }
.badge.expired { color: var(--red); background: rgba(248,113,113,.12); }
.badge.depleted { color: var(--amber); background: rgba(245,185,69,.12); }
.badge.pending { color: var(--blue); background: rgba(96,165,250,.12); }
.badge.approved { color: var(--green); background: rgba(52,211,153,.12); }
.badge.rejected { color: var(--red); background: rgba(248,113,113,.12); }
.badge.locked { color: var(--red); background: rgba(248,113,113,.12); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  font-size: 14px; font-weight: 600; transition: .15s;
}
.btn:hover { border-color: var(--plum); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--plum-soft), var(--plum));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 24px -12px rgba(168,85,247,.9);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.amber { background: linear-gradient(135deg, #d98a14, var(--amber)); border-color: transparent; color: #2a1c00; }
.btn.danger { background: rgba(248,113,113,.14); border-color: rgba(248,113,113,.4); color: var(--red); }
.btn.danger:hover { background: rgba(248,113,113,.22); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-family: inherit; font-size: 14px; transition: .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(168,85,247,.18);
}
textarea { resize: vertical; min-height: 70px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: auto; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,7,18,.72); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 40px 16px; overflow-y: auto;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 480px; padding: 24px; box-shadow: var(--shadow);
}
.modal.wide { max-width: 640px; }
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 22px; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 22px; left: 22px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 13px 17px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: slidein .25s ease; max-width: 360px;
}
.toast.ok { border-inline-start: 4px solid var(--green); }
.toast.err { border-inline-start: 4px solid var(--red); }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--ink-faint); }
.empty .ic { font-size: 34px; opacity: .5; margin-bottom: 10px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.copy-field { display: flex; gap: 8px; align-items: center; }
.copy-field input { font-size: 12px; }
.bar { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--plum), var(--amber)); }
.bar.warn > span { background: var(--amber); }
.bar.full > span { background: var(--red); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-dim); }
.muted { color: var(--ink-faint); }
.right { text-align: left; }
.hide { display: none !important; }

/* ---------- login ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: 20px; padding: 36px 30px; box-shadow: var(--shadow);
}
.login-card .brand { justify-content: center; padding-bottom: 26px; font-size: 21px; }
.login-card .brand .dot { width: 40px; height: 40px; font-size: 20px; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap;
    border-inline-start: none; border-bottom: 1px solid var(--border); padding: 12px;
  }
  .brand { width: 100%; padding-bottom: 12px; }
  .nav-item { flex: 1; justify-content: center; padding: 9px; }
  .nav-item span:not(.ic) { display: none; }
  .nav-spacer { display: none; }
  .main { padding: 18px; }
  .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
}
