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

:root {
  --bg: #08070f;
  --bg-2: #0d0c17;
  --panel: #12111d;
  --panel-2: #171525;
  --card: #141322;
  --line: #262238;
  --line-soft: #1e1b2c;
  --txt: #e9e7f3;
  --txt-2: #a39fba;
  --txt-3: #726d8c;
  --accent: #7c5cff;
  --accent-2: #9d7bff;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.13);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.13);
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, 0.13);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* SVG بدون width/height ذاتاً ۳۰۰×۱۵۰ می‌شود و کل کارت را می‌بلعد.
   این اندازهٔ پیش‌فرض است و هر قانون دقیق‌تری (مثل .btn svg) بر آن مقدم است. */
svg { width: 20px; height: 20px; flex: none; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

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

button, input, select, textarea { font-family: inherit; font-size: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2640; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a3458; }

.num { font-variant-numeric: tabular-nums; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--txt); cursor: pointer; font-weight: 500;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #1e1b30; border-color: #342e4d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(180deg, #ad90ff, #8a6dff); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { color: #ff9c9c; }
.btn-danger:hover { background: var(--bad-soft); border-color: rgba(239, 68, 68, .4); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-icon { padding: 7px; }
.btn-icon svg { width: 17px; height: 17px; }

/* ---------- فرم ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { color: var(--txt-2); font-size: 13px; }
.field .hint { color: var(--txt-3); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #0f0e1a; color: var(--txt);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; text-align: left; }
.input.ltr { direction: ltr; text-align: left; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* سوییچ */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 999px; background: #302b45;
  position: relative; transition: background .18s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 15px; height: 15px;
  border-radius: 50%; background: #9f9ab8; transition: transform .18s, background .18s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(-17px); background: #fff; }

/* ---------- نشان‌ها ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: #f87171; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-idle { background: #1d1a2c; color: var(--txt-3); }

/* ---------- اعلان ---------- */
#toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 300; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-right: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 11px 15px; box-shadow: var(--shadow);
  max-width: 380px; animation: slideIn .22s ease;
}
.toast.ok { border-right-color: var(--ok); }
.toast.err { border-right-color: var(--bad); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

/* ---------- مودال ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 3, 10, .72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow); animation: pop .18s ease;
}
.modal.wide { max-width: 900px; }

/* ---------- کشو: از لبهٔ چپ به داخل می‌لغزد ---------- */
.drawer-backdrop { padding: 0; align-items: stretch; justify-content: flex-start; }
.modal.drawer {
  max-width: 560px; width: 100%; height: 100vh; max-height: 100vh;
  border-radius: 0; border-top: none; border-bottom: none; border-left: none;
  animation: drawerIn .24s cubic-bezier(.22, .68, .36, 1);
}
.modal.drawer.wide { max-width: 720px; }
@keyframes drawerIn {
  from { transform: translateX(-100%); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.drawer-backdrop.closing { animation: fadeOut .2s ease forwards; }
.drawer-backdrop.closing .modal.drawer { animation: drawerOut .2s ease forwards; }
@keyframes drawerOut { to { transform: translateX(-100%); opacity: .5; } }
@keyframes fadeOut { to { opacity: 0; } }

.modal.drawer .modal-body { flex: 1; }
@media (max-width: 620px) {
  .modal.drawer, .modal.drawer.wide { max-width: 100%; }
}
@keyframes pop { from { opacity: 0; transform: scale(.97) } to { opacity: 1; transform: none } }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; justify-content: flex-start;
}
.x-btn { background: none; border: none; color: var(--txt-3); cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.x-btn:hover { background: var(--panel-2); color: var(--txt); }

/* ---------- جعبه‌های توضیح ---------- */
.note-box {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px; line-height: 2;
  margin-bottom: 14px;
}
.note-box .nb-ico { flex: none; font-size: 14px; line-height: 2; }
.note-box.info { background: rgba(56, 189, 248, .09); border: 1px solid rgba(56, 189, 248, .25); color: #93c5fd; }
.note-box.warn { background: var(--warn-soft); border: 1px solid rgba(245, 158, 11, .28); color: #fcd34d; }

/* ---------- بخش جمع‌شونده ---------- */
details.adv {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 0 13px; margin-bottom: 14px; background: rgba(255, 255, 255, .012);
}
details.adv > summary {
  cursor: pointer; padding: 11px 0; color: var(--txt-2); font-size: 13px;
  list-style: none; user-select: none;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: '▸'; display: inline-block; margin-inline-end: 7px; transition: transform .18s; }
details.adv[open] > summary::before { transform: rotate(-90deg); }
details.adv[open] > summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 13px; }
details.adv > .adv-body { padding-bottom: 4px; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--txt-3);
  border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(255,255,255,.01);
}
.empty h4 { color: var(--txt-2); margin: 10px 0 6px; font-size: 15px; }
/* بدون این، SVG بدون width/height تمام عرض کارت را می‌گیرد */
.empty svg { width: 40px; height: 40px; opacity: .45; }

.spin { animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }
