/* ===== فونت‌ها (سلف‌هاست — بدون CDN) ===== */
@font-face {
  font-family: 'Vazirmatn';
  src: local('Vazirmatn'),
       url('../fonts/vazirmatn/Vazirmatn-VF.woff2') format('woff2-variations'),
       url('../fonts/vazirmatn/Vazirmatn-VF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: local('JetBrains Mono'),
       url('../fonts/jetbrains-mono/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: local('JetBrains Mono Medium'),
       url('../fonts/jetbrains-mono/JetBrainsMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: local('JetBrains Mono SemiBold'),
       url('../fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: local('JetBrains Mono Bold'),
       url('../fonts/jetbrains-mono/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: local('JetBrains Mono ExtraBold'),
       url('../fonts/jetbrains-mono/JetBrainsMono-ExtraBold.woff2') format('woff2');
  font-weight: 800 900;
  font-style: normal;
  font-display: swap;
}

/* ===== تم دارک (پیش‌فرض) ===== */
:root,
[data-theme="dark"] {
  --bg-void: #06080a;
  --bg-base: #0b0f14;
  --bg-panel: #11161d;
  --bg-elevated: #161d26;
  --bg-hover: #1d2630;
  --border: #1f2933;
  --border-glow: #243340;

  --neon: #00ff88;
  --neon-dim: #00cc6e;
  --neon-glow: rgba(0, 255, 136, 0.35);
  --neon-soft: rgba(0, 255, 136, 0.10);

  --cyan: #00d9ff;
  --amber: #ffb627;
  --red: #ff3b5c;
  --purple: #a855f7;

  --text-hi: #e8eef2;
  --text-mid: #93a1ad;
  --text-low: #5a6772;

  --shadow: 0 8px 30px rgba(0,0,0,.4);
  --bg-page-image:
    radial-gradient(circle at 85% -10%, rgba(0,255,136,0.06), transparent 45%),
    radial-gradient(circle at 10% 110%, rgba(0,217,255,0.05), transparent 40%);
}

/* ===== تم لایت ===== */
[data-theme="light"] {
  --bg-void: #eef1f5;
  --bg-base: #f4f6f9;
  --bg-panel: #ffffff;
  --bg-elevated: #f7f9fb;
  --bg-hover: #eef2f6;
  --border: #e2e8f0;
  --border-glow: #cbd5e1;

  --neon: #00a85a;
  --neon-dim: #00925a;
  --neon-glow: rgba(0, 168, 90, 0.25);
  --neon-soft: rgba(0, 168, 90, 0.10);

  --cyan: #0891b2;
  --amber: #d97706;
  --red: #e11d48;
  --purple: #9333ea;

  --text-hi: #0f172a;
  --text-mid: #475569;
  --text-low: #94a3b8;

  --shadow: 0 4px 20px rgba(15,23,42,.08);
  --bg-page-image:
    radial-gradient(circle at 85% -10%, rgba(0,168,90,0.05), transparent 45%),
    radial-gradient(circle at 10% 110%, rgba(8,145,178,0.04), transparent 40%);
}

:root {
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar-w: 256px;
  --tap: 44px; /* حداقل تاچ‌تارگت استاندارد */
  /* در --mono، Vazirmatn به‌عنوان fallback برای کاراکترهای فارسی قرار گرفته
     تا JetBrains Mono فقط برای لاتین/اعداد استفاده شود و فارسی هرگز روی
     Consolas/Tahoma نیفتد. */
  --mono: 'JetBrains Mono', 'Vazirmatn', 'Consolas', monospace;
  --sans: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* فرم‌المنت‌ها به‌صورت پیش‌فرض فونت body را ارث نمی‌برند — اجبار به Vazirmatn */
input, select, textarea, button, optgroup, option {
  font-family: inherit;
}

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--bg-void);
  color: var(--text-hi);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background-image: var(--bg-page-image);
  transition: background-color .3s ease, color .3s ease;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-dim); }

/* فوکوس قابل‌دسترس برای کیبورد */
:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; border-radius: 6px; }

/* ===== چیدمان کلی ===== */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ===== سایدبار (دسکتاپ) ===== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-base));
  border-left: 1px solid var(--border);
  position: fixed;
  right: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--neon), var(--neon-dim));
  display: grid; place-items: center;
  font-weight: 900; font-size: 20px; color: #04110a;
  box-shadow: 0 0 22px var(--neon-glow);
  font-family: var(--mono);
  flex-shrink: 0;
}
.brand-text b { font-size: 16px; letter-spacing: .3px; display: block; }
.brand-text span { font-size: 11px; color: var(--text-low); font-family: var(--mono); }

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-label {
  font-size: 10px; color: var(--text-low);
  padding: 14px 12px 8px; letter-spacing: 1.5px;
  font-family: var(--sans); font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  cursor: pointer;
  font-size: 14px;
  position: relative;
  transition: all .18s ease;
  margin-bottom: 3px;
  user-select: none;
  text-decoration: none;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-hi); }
.nav-item.active { background: var(--neon-soft); color: var(--neon); }
.nav-item.active::before {
  content: ''; position: absolute; right: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--neon);
  border-radius: 4px;
  box-shadow: 0 0 10px var(--neon);
}
.nav-badge {
  margin-right: auto;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  font-family: var(--mono);
  min-width: 20px; text-align: center;
}

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-card {
  display: flex; align-items: center; gap: 11px;
  padding: 10px; border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.user-card div b { font-size: 13px; display: block; }
.user-card div span { font-size: 11px; color: var(--text-low); }
.logout-btn {
  margin-right: auto; background: none; border: none; cursor: pointer;
  color: var(--text-low); width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
}
.logout-btn:hover { color: var(--red); background: var(--bg-hover); }

/* ===== محتوای اصلی ===== */
.main { flex: 1; margin-right: var(--sidebar-w); min-width: 0; }

.topbar {
  min-height: 64px;
  background: color-mix(in srgb, var(--bg-base) 80%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 10px 20px; gap: 14px;
  position: sticky; top: 0; z-index: 50;
}
.menu-btn {
  display: none; background: none; border: none;
  color: var(--text-hi); cursor: pointer;
  width: var(--tap); height: var(--tap);
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.menu-btn:active { background: var(--bg-hover); }
.page-title { font-size: 18px; font-weight: 700; min-width: 0; }
.page-title small { font-size: 12px; color: var(--text-low); font-weight: 400; margin-right: 8px; }

.topbar-right { margin-right: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.search-box {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px; width: 220px;
}
.search-box input {
  background: none; border: none; color: var(--text-hi);
  outline: none; flex: 1; font-family: var(--sans); font-size: 13px; min-width: 0;
}
.search-box svg { width: 16px; height: 16px; color: var(--text-low); flex-shrink: 0; }

.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
  display: grid; place-items: center; cursor: pointer; color: var(--text-mid);
  position: relative; transition: all .18s; flex-shrink: 0;
}
.icon-btn:hover { color: var(--neon); border-color: var(--border-glow); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .dot {
  position: absolute; top: 9px; left: 10px;
  width: 8px; height: 8px; background: var(--red);
  border-radius: 50%; border: 2px solid var(--bg-elevated);
}

/* سوییچ تم */
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .sun { display: none; }
[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

.content { padding: 22px; padding-bottom: 40px; }

/* ===== صفحه ===== */
.page { animation: fadeUp .4s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, .page { animation: none !important; transition: none !important; }
}

/* ===== کارت‌های آمار ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform .22s ease, border-color .22s ease;
  box-shadow: var(--shadow);
}
.stat-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 90px; height: 90px;
  background: radial-gradient(circle, var(--accent-c, var(--neon-glow)), transparent 70%);
  opacity: .15; pointer-events: none;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--border-glow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft, var(--neon-soft));
  color: var(--accent-c, var(--neon));
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-trend {
  font-size: 12px; font-family: var(--mono);
  padding: 4px 8px; border-radius: 7px;
  display: flex; align-items: center; gap: 3px;
}
.trend-up { background: var(--neon-soft); color: var(--neon); }
.trend-down { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.stat-value { font-size: 28px; font-weight: 800; font-family: var(--mono); letter-spacing: -.5px; }
.stat-label { color: var(--text-mid); font-size: 13px; margin-top: 4px; }

/* ===== شبکه دو ستونه ===== */
.dual-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.panel-head h3 svg { width: 18px; height: 18px; color: var(--neon); flex-shrink: 0; }
.panel-body { padding: 18px; }

/* ===== موجودی کدها ===== */
.stock-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.stock-row:last-child { border-bottom: none; }
.uc-badge {
  min-width: 60px; text-align: center;
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  padding: 7px 10px; border-radius: 9px;
  background: linear-gradient(135deg, var(--amber), #ff8a00);
  color: #1a1000;
  box-shadow: 0 0 14px color-mix(in srgb, var(--amber) 25%, transparent);
  flex-shrink: 0;
}
.uc-badge.sm { min-width: auto; padding: 4px 8px; font-size: 12px; }
.stock-bar-wrap { flex: 1; min-width: 0; }
.stock-bar-top { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; }
.stock-bar-top b { font-family: var(--mono); }
.stock-bar-top .low { color: var(--red); }
.stock-track { height: 8px; background: var(--bg-void); border-radius: 10px; overflow: hidden; }
.stock-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--neon-dim), var(--neon)); transition: width 1s ease; }
.stock-fill.warn { background: linear-gradient(90deg, #ff8a00, var(--amber)); }
.stock-fill.crit { background: linear-gradient(90deg, #b91c3c, var(--red)); }

/* ===== سلامت API ===== */
.api-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.api-card:last-child { margin-bottom: 0; }
.api-status-dot { width: 12px; height: 12px; border-radius: 50%; position: relative; flex-shrink: 0; }
.api-status-dot.ok { background: var(--neon); box-shadow: 0 0 10px var(--neon); }
.api-status-dot.ok::after {
  content: ''; position: absolute; inset: -5px;
  border-radius: 50%; border: 2px solid var(--neon);
  animation: pulse 1.8s infinite;
}
.api-status-dot.warn { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.api-status-dot.down { background: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes pulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2.2); opacity: 0; } }
.api-info { flex: 1; min-width: 0; }
.api-info b { font-size: 14px; display: block; }
.api-info span { font-size: 12px; color: var(--text-low); font-family: var(--sans); }
.api-ping { font-family: var(--mono); font-size: 13px; color: var(--text-mid); flex-shrink: 0; }
.api-ping b { color: var(--text-hi); }

/* ===== جدول ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: right; padding: 13px 16px;
  font-size: 12px; color: var(--text-low);
  font-weight: 600; letter-spacing: .3px;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  white-space: nowrap;
}
td { padding: 14px 16px; font-size: 13px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); color: var(--text-mid); }
.player-id { font-family: var(--mono); color: var(--cyan); font-weight: 600; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  padding: 5px 11px; border-radius: 20px;
  font-family: var(--sans); white-space: nowrap;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-done { background: var(--neon-soft); color: var(--neon); }
.st-proc { background: color-mix(in srgb, var(--cyan) 12%, transparent); color: var(--cyan); }
.st-wait { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }
.st-fail { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.st-avail { background: var(--neon-soft); color: var(--neon); }
.st-used { background: var(--bg-hover); color: var(--text-low); }

.row-action {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-mid); padding: 8px 14px; border-radius: 9px;
  font-size: 12px; cursor: pointer; font-family: var(--sans);
  transition: all .15s; min-height: 36px;
}
.row-action:hover { color: var(--neon); border-color: var(--neon-dim); }
.row-action:active { transform: scale(.96); }
.row-action.warn { color: var(--amber); border-color: var(--amber); }

/* ===== کارت موبایل (جایگزین جدول) ===== */
.m-cards { display: none; flex-direction: column; gap: 12px; padding: 14px; }
.m-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.m-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.m-card-id { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.m-card-rows { display: flex; flex-direction: column; gap: 9px; }
.m-card-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.m-card-row .k { color: var(--text-low); font-size: 12px; }
.m-card-row .v { font-family: var(--mono); }
.m-card-foot { margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.m-card-foot .row-action { flex: 1; text-align: center; }

/* ===== لاگ ===== */
.log-stream { font-family: var(--mono); font-size: 12.5px; line-height: 1.9; }
.log-line { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.log-time { color: var(--text-low); flex-shrink: 0; }
.log-tag { flex-shrink: 0; font-weight: 700; min-width: 16px; }
.log-tag.info { color: var(--cyan); }
.log-tag.ok { color: var(--neon); }
.log-tag.warn { color: var(--amber); }
.log-tag.err { color: var(--red); }
.log-msg { color: var(--text-mid); word-break: break-word; font-family: var(--sans); }

/* ===== تولبار ===== */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border);
  transition: all .18s; background: var(--bg-elevated); color: var(--text-hi);
  min-height: var(--tap);
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: var(--border-glow); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--neon), var(--neon-dim));
  color: #04110a; border: none;
  box-shadow: 0 0 18px var(--neon-glow);
}
.btn-primary:hover { box-shadow: 0 0 26px var(--neon-glow); transform: translateY(-1px); }
.filter-scroll { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.filter-scroll::-webkit-scrollbar { height: 0; }
.filter-chip {
  padding: 9px 16px; border-radius: 20px; font-size: 12px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  cursor: pointer; color: var(--text-mid); transition: all .15s;
  font-family: var(--sans); white-space: nowrap; min-height: 38px;
  display: inline-flex; align-items: center;
}
.filter-chip.active { background: var(--neon-soft); color: var(--neon); border-color: var(--neon-dim); }

/* فرم */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 12px; color: var(--text-low); font-family: var(--sans); font-weight: 500; }
.field input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-hi); font-family: var(--sans);
  min-height: var(--tap);
}
.field input:focus { border-color: var(--neon-dim); outline: none; }

/* ===== ناوبری پایین موبایل ===== */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; right: 0; left: 0;
  background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 90;
  padding-bottom: var(--safe-bottom);
  justify-content: space-around;
  align-items: stretch;
}
.bn-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 9px 4px;
  color: var(--text-low); cursor: pointer;
  font-size: 10px; position: relative;
  min-height: 56px; user-select: none;
  transition: color .18s;
  text-decoration: none;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--neon); }
.bn-item.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; background: var(--neon); border-radius: 0 0 4px 4px;
  box-shadow: 0 0 8px var(--neon);
}
.bn-badge {
  position: absolute; top: 6px; right: calc(50% - 18px);
  background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 10px;
  display: grid; place-items: center; font-family: var(--mono); padding: 0 4px;
}

/* ===== شبکه‌ی کلید-مقدار (Key/Value) — برای جزئیات در مودال‌ها ===== */
.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  font-size: 13px;
  margin-bottom: 18px;
}
.kv-grid > div b { color: var(--text-mid); margin-left: 6px; }

/* ===== کارت مودال استاندارد — اندازه‌ی responsive ===== */
.modal-overlay {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 100; padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow: auto;
}

/* ردیف ادیتور Recipe — flex با امکان wrap */
.recipe-row {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg-elevated);
  padding: 10px; border-radius: 10px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.recipe-row > select { flex: 1 1 200px; min-width: 0; }
.recipe-row > input { width: 80px; }

/* ===== ریسپانسیو ===== */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dual-grid { grid-template-columns: 1fr; }
}

/* تبلت و موبایل */
@media (max-width: 820px) {
  .sidebar {
    transform: translateX(100%);
    box-shadow: -10px 0 40px rgba(0,0,0,.5);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0; }
  .menu-btn { display: flex; }
  .search-box { display: none; }
  .content { padding: 16px; padding-bottom: 90px; } /* فضا برای bottom-nav */
  .bottom-nav { display: flex; }

  /* جدول → کارت */
  .table-wrap { display: none; }
  .m-cards { display: flex; }

  /* مودال‌ها روی موبایل تقریباً تمام‌صفحه */
  .modal-overlay { padding: 10px; }
  .modal-card { max-width: 100%; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }

  /* شبکه‌های 2 ستونه به 1 ستون */
  .kv-grid { grid-template-columns: 1fr; gap: 10px; }

  /* تولبار با Wrap و رفتار بهتر */
  .toolbar { gap: 8px; }
  .toolbar .btn { font-size: 12px; padding: 9px 14px; }
}

@media (max-width: 480px) {
  html { font-size: 15px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 15px; }
  .stat-value { font-size: 24px; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-icon svg { width: 20px; height: 20px; }
  .content { padding: 13px; padding-bottom: 90px; }
  .panel-head { padding: 14px; gap: 8px; flex-wrap: wrap; }
  .panel-head h3 { font-size: 14px; }
  .panel-body { padding: 14px; }
  .page-title { font-size: 16px; }
  .page-title small { display: none; }
  .topbar { padding: 8px 14px; }

  /* لاگ‌ها: ردیف‌ها در صفحه‌ی Logs روی موبایل عمودی‌تر بشن */
  .log-line { flex-wrap: wrap; }
  .log-time { font-size: 11px; min-width: auto !important; }
  .log-tag { font-size: 10px !important; min-width: auto !important; }

  /* فیلتر چیپ‌ها کوچک‌تر */
  .filter-chip { padding: 7px 12px; font-size: 11px; min-height: 34px; }

  /* مودال‌ها روی موبایل کوچک */
  .modal-card { border-radius: var(--radius-sm); }
  .panel-body pre { font-size: 10px !important; }

  /* فرم‌ها: input/textarea full width */
  textarea, select { font-size: 14px !important; }
}

/* صفحات خیلی کوچک: یک ستون آمار */
@media (max-width: 360px) {
  .stat-grid { grid-template-columns: 1fr; }
}

.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 99; backdrop-filter: blur(2px);
}
.overlay.show { display: block; }

/* ===== صفحه‌ی ورود ===== */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--neon), var(--neon-dim));
  display: grid; place-items: center; font-weight: 900; font-size: 24px;
  color: #04110a; box-shadow: 0 0 22px var(--neon-glow); font-family: var(--mono);
}
.login-card h1 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--text-low); font-size: 12px; margin-bottom: 24px; font-family: var(--sans); }
.login-error {
  background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; text-align: center;
}

/* Blazor error UI */
#blazor-error-ui {
  background: var(--amber); color: #1a1000; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
  display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
