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

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #e6e9f0;
  --primary: #3563e9;
  --primary-dark: #2449b8;
  --green: #138a53;
  --red: #c0392b;
  --amber: #b7791f;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(31, 41, 55, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card {
  width: min(920px, 100%);
  padding: 28px;
}
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}
.sidebar {
  background: #111827;
  color: #e5e7eb;
  padding: 22px 16px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 800;
  margin-bottom: 28px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  display: inline-block;
}
.nav a {
  display: flex;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  margin-bottom: 4px;
}
.nav a.active, .nav a:hover { background: #1f2937; color: #fff; }
.main { min-width: 0; }
.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.content { padding: 24px; }
.page-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; margin-bottom: 6px; }
h2 { font-size: 18px; margin-bottom: 0; }
p, small, .muted { color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: 18px; margin-bottom: 18px; }
.stat strong { display: block; font-size: 24px; margin: 8px 0 4px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.full { grid-column: 1 / -1; }
label span { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
select[data-multiselect-dropdown].is-enhanced { display: none; }
.multi-dropdown {
  position: relative;
  width: 100%;
}
.multi-dropdown-toggle {
  position: relative;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 38px 9px 11px;
  font: inherit;
  text-align: right;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.multi-dropdown-toggle::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 18px;
  border: 5px solid transparent;
  border-top-color: var(--muted);
}
.multi-dropdown-toggle.is-empty {
  color: var(--muted);
}
.multi-dropdown-menu {
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  top: calc(100% + 6px);
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 6px;
}
.multi-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.multi-dropdown-option:hover {
  background: #f4f6fb;
}
.multi-dropdown-option input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}
textarea { min-height: 100px; resize: vertical; }
.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #eef2ff; color: #243b7a; }
.btn-outline { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-icon {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 8px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.modal-backdrop {
  position: fixed;
  z-index: 9000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.46);
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 20px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: #f1f4f9;
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}
.modal-close:hover { background: #e8edf6; }
.modal-form { margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.alert-success { background: #e9f8f1; color: var(--green); }
.alert-error { background: #fdeaea; color: var(--red); }
.alert[data-toast][data-toast-consumed="1"] { display: none; }
.toast-viewport {
  position: fixed;
  z-index: 10000;
  top: 18px;
  left: 18px;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 28px));
  pointer-events: none;
}
.app-toast {
  --toast-accent: var(--primary);
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: flex-start;
  min-height: 64px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}
.app-toast::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--toast-accent);
}
.app-toast.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.app-toast.is-hiding { opacity: 0; transform: translateY(-6px) scale(0.98); }
.app-toast-success { --toast-accent: var(--green); }
.app-toast-error { --toast-accent: var(--red); }
.app-toast-warning { --toast-accent: var(--amber); }
.app-toast-info { --toast-accent: var(--primary); }
.app-toast-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--toast-accent);
}
.app-toast-icon svg,
.app-toast-close svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: currentColor;
}
.app-toast-content { display: grid; gap: 3px; min-width: 0; }
.app-toast-content strong { font-size: 13px; font-weight: 900; color: var(--text); }
.app-toast-content span { color: var(--muted); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.app-toast-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8a94a8;
  cursor: pointer;
}
.app-toast-close:hover,
.app-toast-close:focus-visible { background: #f1f3f8; color: var(--text); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 960px; }
th, td {
  text-align: right;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td small { display: block; margin-top: 4px; }
.copy-code {
  display: inline-flex;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  vertical-align: top;
}
.copy-code code {
  max-width: 100%;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.copy-code:hover code,
.copy-code:focus-visible code {
  background: #eef2ff;
  color: var(--primary);
}
.copy-code.is-copied code {
  background: #e9f8f1;
  color: var(--green);
}
.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf2f7;
  color: #475569;
  font-size: 12px;
}
.status.active { background: #e9f8f1; color: var(--green); }
.status.paused { background: #fff7e6; color: var(--amber); }
.status.revoked { background: #fdeaea; color: var(--red); }
.status.suspended { background: #fdeaea; color: var(--red); }
.code-box {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 8px;
  padding: 12px;
  font-family: Consolas, monospace;
  max-height: 220px;
  overflow: auto;
}
.inline-form { display: inline; }
.empty { text-align: center; color: var(--muted); padding: 22px; }
.jalali-date-field {
  position: relative;
}
.jalali-date-field input {
  padding-right: 42px;
}
.jalali-date-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.jalali-date-toggle:hover,
.jalali-date-toggle:focus-visible {
  background: #eef2ff;
  color: var(--primary);
}
.jalali-date-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.jalali-calendar {
  position: absolute;
  z-index: 10050;
  top: calc(100% + 8px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
}
.jalali-calendar[hidden] {
  display: none;
}
.jalali-calendar-header,
.jalali-calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.jalali-calendar-header {
  margin-bottom: 10px;
}
.jalali-calendar-header strong {
  font-size: 14px;
}
.jalali-calendar-nav {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.jalali-calendar-nav:hover {
  border-color: #c7d2fe;
  color: var(--primary);
}
.jalali-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.jalali-calendar-weekday,
.jalali-calendar-empty,
.jalali-calendar-day {
  min-height: 32px;
  display: grid;
  place-items: center;
}
.jalali-calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.jalali-calendar-day {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.jalali-calendar-day:hover {
  border-color: #c7d2fe;
  color: var(--primary);
}
.jalali-calendar-day.is-today {
  border-color: #f4c76a;
  background: #fff8e7;
  color: var(--amber);
}
.jalali-calendar-day.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.jalali-calendar-footer {
  margin-top: 10px;
}
.jalali-calendar-footer .btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .grid.two, .grid.four, .form-grid { grid-template-columns: 1fr; }
  .page-title { align-items: stretch; flex-direction: column; }
  .page-title .btn-icon { align-self: flex-start; }
  .modal-backdrop { padding: 12px; place-items: stretch; }
  .modal-card { max-height: calc(100vh - 24px); }
  .modal-actions { flex-direction: column-reverse; }
}
