/* =========================================================================
   پنل مدیریت چندسایتی وردپرس/ووکامرس — شیوه‌نامهٔ اصلی
   تم: تیره | جهت: راست‌به‌چپ | فونت: Dana
   ========================================================================= */

@font-face {
  font-family: 'Dana';
  /* src: url('https://cdn.fontcdn.ir/Font/Persian/Dana/Dana-Regular.woff2') format('woff2'); */
  src: url('./font/dana/DanaFaNum-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Dana';
  /* src: url('https://cdn.fontcdn.ir/Font/Persian/Dana/Dana-Medium.woff2') format('woff2'); */
  src: url('./font/dana/DanaFaNum-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Dana';
  /* src: url('https://cdn.fontcdn.ir/Font/Persian/Dana/Dana-Bold.woff2') format('woff2'); */
  src: url('./font/dana/DanaFaNum-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Dana FaNum';
  /* src: url('https://cdn.fontcdn.ir/Font/Persian/Dana/Dana-FaNum-Medium.woff2') format('woff2'); */
  src: url('./font/dana/DanaFaNum-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

:root {
  /* --- سطوح پس‌زمینه --- */
  --bg: #0b0d12;
  --bg-elev: #10131a;
  --surface: #161a23;
  --surface-2: #1d2230;
  --surface-hover: #232939;
  --border: #262d3d;
  --border-soft: #1b202c;

  /* --- متن --- */
  --text: #eceef3;
  --text-dim: #9aa1b4;
  --text-faint: #616a80;

  /* --- برند و وضعیت‌ها --- */
  --accent: #7c6cf0;
  --accent-2: #a394ff;
  --accent-soft: rgba(124, 108, 240, 0.16);
  --success: #2bd9a3;
  --success-soft: rgba(43, 217, 163, 0.14);
  --warning: #f5ab3d;
  --warning-soft: rgba(245, 171, 61, 0.14);
  --danger: #f0596a;
  --danger-soft: rgba(240, 89, 106, 0.14);
  --info: #4fb4f0;
  --info-soft: rgba(79, 180, 240, 0.14);

  /* --- ابعاد --- */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-w: 272px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 6px 16px -8px rgba(0, 0, 0, 0.5);

  --font: 'Dana', 'Vazirmatn', Tahoma, sans-serif;
  --font-num: 'Dana FaNum', 'Dana', 'Vazirmatn', Tahoma, sans-serif;
}

/* --- تم روشن --- */
:root[data-theme="light"] {
  --bg: #f3f4f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --surface-hover: #e7e9f2;
  --border: #dde1ec;
  --border-soft: #e6e9f2;

  --text: #1c1f2b;
  --text-dim: #565f74;
  --text-faint: #8890a3;

  --accent: #6a58e8;
  --accent-2: #5a48d8;
  --accent-soft: rgba(106, 88, 232, 0.1);
  --success: #12b686;
  --success-soft: rgba(18, 182, 134, 0.1);
  --warning: #d98a1c;
  --warning-soft: rgba(217, 138, 28, 0.1);
  --danger: #e0405a;
  --danger-soft: rgba(224, 64, 90, 0.1);
  --info: #2f8fd6;
  --info-soft: rgba(47, 143, 214, 0.1);

  --shadow: 0 16px 40px -16px rgba(30, 34, 60, 0.18);
  --shadow-sm: 0 6px 16px -8px rgba(30, 34, 60, 0.14);
}
:root[data-theme="light"] body { background: var(--bg); }
:root[data-theme="light"] .topbar { background: rgba(243, 244, 248, 0.75); }
:root[data-theme="light"] .bottom-nav { background: rgba(255, 255, 255, 0.92); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.7;
  overscroll-behavior-y: none;
  transition: background .2s ease, color .2s ease;
}
h1, h2, h3, h4 { font-weight: 700; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
::selection { background: var(--accent-soft); color: var(--accent-2); }

.num, .price, td.num, .stat-card__value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.icon { width: 19px; height: 19px; display: inline-block; flex-shrink: 0; }
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 26px; height: 26px; }

/* =========================================================================
   چیدمان کلی
   ========================================================================= */

#app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .22s ease;
}
#app-shell.is-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* --- نوار کناری (سایدبار) --- */

.sidebar {
  background: var(--bg-elev);
  border-left: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: padding .2s ease;
}
#app-shell.is-collapsed .sidebar { padding: 20px 10px; }
#app-shell.is-collapsed .brand__text,
#app-shell.is-collapsed .nav-group__label,
#app-shell.is-collapsed .nav-link span,
#app-shell.is-collapsed .site-switcher__label,
#app-shell.is-collapsed .site-chip__meta,
#app-shell.is-collapsed .site-switcher__add span,
#app-shell.is-collapsed .sidebar__footer span {
  display: none;
}
#app-shell.is-collapsed .nav-link { justify-content: center; }
#app-shell.is-collapsed .site-switcher { padding: 8px; }
#app-shell.is-collapsed .site-chip { justify-content: center; }
#app-shell.is-collapsed .brand { justify-content: center; padding-inline: 0; }
#app-shell.is-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-collapse-btn {
  display: none;
}
@media (min-width: 901px) {
  .sidebar-collapse-btn {
    display: inline-flex; margin-top: 8px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
}
.brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(155deg, var(--accent), #4b3fc4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px -6px rgba(124, 108, 240, 0.55);
}
.brand__text strong { display: block; font-size: 15px; }
.brand__text span { display: block; font-size: 12px; color: var(--text-faint); }

.site-switcher {
  margin-bottom: 18px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
}
.site-switcher__label {
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 2px 6px 8px;
}
.site-chip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.site-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: right;
}
.site-chip:hover { background: var(--surface-hover); }
.site-chip.is-active {
  background: var(--accent-soft);
  border-color: rgba(124, 108, 240, 0.35);
}
.site-chip__avatar {
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  position: relative;
}
.site-chip__dot {
  position: absolute; bottom: -2px; left: -2px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--text-faint);
}
.site-chip__dot.is-ok { background: var(--success); }
.site-chip__dot.is-error { background: var(--danger); }
.site-chip__meta { min-width: 0; flex: 1; }
.site-chip__meta strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-chip__meta span { display: block; font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-switcher__add {
  margin-top: 6px; width: 100%; padding: 8px; border-radius: 10px;
  border: 1px dashed var(--border);
  background: transparent; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; font-size: 12.5px;
}
.site-switcher__add:hover { border-color: var(--accent); color: var(--accent-2); }

.nav-group__label {
  font-size: 11px; color: var(--text-faint); padding: 14px 10px 6px;
  letter-spacing: .03em;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-dim); cursor: pointer; font-size: 13.5px;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.is-active {
  background: var(--accent-soft); color: var(--accent-2); font-weight: 500;
}
.nav-link .icon { color: inherit; }

.sidebar__footer {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft);
  font-size: 11px; color: var(--text-faint); display: flex; justify-content: space-between; align-items: center;
}

/* --- ناحیه اصلی --- */

.main {
  display: flex; flex-direction: column; min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 13, 18, 0.7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { display: flex; flex-direction: column; gap: 2px; }
.topbar__title h1 { font-size: 17px; }
.topbar__title span { font-size: 12px; color: var(--text-faint); }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }

.connection-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-soft);
  font-size: 12px; color: var(--text-dim);
}
.connection-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.connection-pill.is-ok .connection-pill__dot { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.connection-pill.is-error .connection-pill__dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

.view {
  padding: 24px 26px 100px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

#app-main.is-loading .view { opacity: .5; pointer-events: none; }

/* =========================================================================
   کامپوننت‌های عمومی
   ========================================================================= */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head h2 { font-size: 20px; }
.page-head p { color: var(--text-faint); font-size: 13px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13.5px; cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #6a5ae0; }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); border-color: var(--accent); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(240,89,106,.3); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border-soft);
  color: var(--text-dim); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger); }

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
}
.card--pad-lg { padding: 24px; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1.4fr 1fr; align-items: start; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.stat-card__top { display: flex; align-items: center; justify-content: space-between; }
.stat-card__icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card__icon.tone-accent { background: var(--accent-soft); color: var(--accent-2); }
.stat-card__icon.tone-success { background: var(--success-soft); color: var(--success); }
.stat-card__icon.tone-warning { background: var(--warning-soft); color: var(--warning); }
.stat-card__icon.tone-info { background: var(--info-soft); color: var(--info); }
.stat-card__value { font-size: 24px; font-weight: 700; }
.stat-card__label { font-size: 12.5px; color: var(--text-faint); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
}
.badge.tone-success { background: var(--success-soft); color: var(--success); }
.badge.tone-warning { background: var(--warning-soft); color: var(--warning); }
.badge.tone-danger { background: var(--danger-soft); color: var(--danger); }
.badge.tone-info { background: var(--info-soft); color: var(--info); }
.badge.tone-muted { background: var(--surface-2); color: var(--text-faint); }

.table-wrap {
  overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead th {
  text-align: right; font-size: 12px; color: var(--text-faint); font-weight: 500;
  padding: 13px 16px; border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
.cell-title { font-weight: 500; }
.cell-sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-start; }

.toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 0 12px; min-width: 220px; flex: 1;
}
.search-box .icon { color: var(--text-faint); }
.search-box input { background: transparent; border: none; outline: none; padding: 10px 0; width: 100%; color: var(--text); }
select.select {
  background: var(--surface); border: 1px solid var(--border-soft); color: var(--text);
  padding: 10px 12px; border-radius: 10px; outline: none;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--text-dim); }
.field input, .field textarea, .field select {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field__hint { font-size: 11.5px; color: var(--text-faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty-state {
  padding: 60px 20px; text-align: center; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state__icon {
  width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-faint);
}
.empty-state__title { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.empty-state__hint { font-size: 12.5px; max-width: 320px; }

.skeleton {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; }
.pagination span { font-size: 12.5px; color: var(--text-faint); }

/* --- مودال --- */

#modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-root.is-open { display: block; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 6, 10, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 460px;
  box-shadow: var(--shadow); max-height: 88vh; display: flex; flex-direction: column;
  animation: pop-in .18s ease;
}
.modal--wide { max-width: 720px; }
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.modal__head h3 { font-size: 15.5px; }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__foot { padding: 16px 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; }

/* --- toast --- */
.toast-host { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow-sm);
  transform: translateY(10px); opacity: 0; transition: all .22s ease; max-width: 320px;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast--success { border-color: rgba(43,217,163,.4); color: var(--success); }
.toast--error { border-color: rgba(240,89,106,.4); color: var(--danger); }
.toast--info { color: var(--text); }

.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }

/* --- کتابخانه رسانه --- */
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px;
}
.media-tile {
  position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-soft);
  background: var(--surface-2); cursor: pointer; aspect-ratio: 1/1; padding: 0;
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile:hover { border-color: var(--accent); }
.media-tile__file { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.media-tile--card { cursor: default; }
.media-tile__overlay {
  position: absolute; inset: 0; background: rgba(11,13,18,.55); opacity: 0; transition: opacity .15s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.media-tile--card:hover .media-tile__overlay { opacity: 1; }

/* --- انتخاب چندتایی (چیپ/چک‌باکس) --- */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev); cursor: pointer; font-size: 12.5px; color: var(--text-dim);
}
.chip-check input { accent-color: var(--accent); }
.chip-check:has(input:checked) { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* --- تب‌های فرم --- */
.form-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; }
.form-tab {
  padding: 9px 14px; border-radius: 8px 8px 0 0; font-size: 13px; color: var(--text-faint);
  cursor: pointer; border: 1px solid transparent; border-bottom: none; margin-bottom: -1px;
}
.form-tab.is-active { color: var(--accent-2); border-color: var(--border-soft); background: var(--bg-elev); }
.form-tab-panel { display: none; }
.form-tab-panel.is-active { display: block; }

/* --- انتخاب‌گر تصویر --- */
.image-picker {
  display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px dashed var(--border);
  border-radius: 12px; background: var(--bg-elev);
}
.image-picker__preview {
  width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-faint); flex-shrink: 0;
}
.image-picker__preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }

/* --- ردیف ترکیب متغیر --- */
.variation-row {
  display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border-soft);
  border-radius: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.variation-row__label { font-size: 12.5px; min-width: 130px; flex: 1; }
.variation-row input[type="number"], .variation-row select { width: 110px; padding: 7px 9px; border-radius: 8px; }

/* --- سربرگ سیستم اتصال خالی (وقتی هیچ سایتی وجود ندارد) --- */
.connect-hero {
  max-width: 560px; margin: 60px auto; text-align: center;
}
.connect-hero .empty-state__icon { width: 72px; height: 72px; margin: 0 auto; }

/* --- ویرایشگر پیشرفته محتوا --- */
.rich-editor {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-elev);
}
.rich-editor__toolbar {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 7px; border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}
.rich-editor__btn {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 12.5px; font-weight: 600;
}
.rich-editor__btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-soft); }
.rich-editor__area {
  min-height: 160px; max-height: 380px; overflow-y: auto; padding: 14px; outline: none; font-size: 13.5px; line-height: 1.9;
}
.rich-editor__area h2 { font-size: 17px; margin: .5em 0; }
.rich-editor__area h3 { font-size: 15px; margin: .5em 0; }
.rich-editor__area blockquote { border-inline-start: 3px solid var(--accent); margin: .6em 0; padding: 4px 14px; color: var(--text-dim); }
.rich-editor__area ul, .rich-editor__area ol { padding-inline-start: 22px; margin: .5em 0; }
.rich-editor__area a { color: var(--accent-2); text-decoration: underline; }
.rich-editor__area:empty:before { content: attr(data-placeholder); color: var(--text-faint); }

/* --- نمودارها --- */
.chart-scroll { overflow-x: auto; }
.chart-svg { display: block; }
.chart-baseline { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 9px; fill: var(--text-faint); font-family: var(--font-num); }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-faint); }
.chart-legend__dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-inline-end: 5px; }

/* --- دکمه شناور (FAB) --- */
.fab {
  display: none;
}

/* --- انتخاب‌گر تعداد رکورد --- */
.per-page-select { min-width: 90px; }

/* =========================================================================
   واکنش‌گرا: تبلت و موبایل — تجربه شبیه اپلیکیشن واقعی
   ========================================================================= */

.bottom-nav { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1080px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  #app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 60; inset-inline-end: 0; top: 0;
    width: min(86vw, 310px); height: 100vh; height: 100dvh;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1);
    box-shadow: var(--shadow);
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
    position: fixed; inset: 0; background: rgba(5,6,10,.55); z-index: 55; backdrop-filter: blur(1px);
  }
  .sidebar-backdrop.is-open { display: block; opacity: 1; pointer-events: auto; }

  .menu-btn { display: inline-flex; }
  .sidebar-collapse-btn { display: none !important; }
  .view { padding: 16px 14px calc(90px + env(safe-area-inset-bottom)); }
  .topbar {
    padding: 0 14px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 40;
    background: rgba(16,19,26,.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-soft);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  :root[data-theme="light"] .bottom-nav { background: rgba(255,255,255,.92); }
  .bottom-nav__item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; color: var(--text-faint); padding: 6px 12px; border-radius: 12px;
    transition: transform .12s ease, color .12s ease; -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav__item:active { transform: scale(.9); }
  .bottom-nav__item.is-active { color: var(--accent-2); }
  .bottom-nav__item.is-active .icon { transform: translateY(-1px); }

  /* دکمه شناور برای افزودن آیتم جدید */
  .fab {
    display: flex; position: fixed; z-index: 45;
    inset-inline-end: 16px; bottom: calc(76px + env(safe-area-inset-bottom));
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--accent); color: #fff; align-items: center; justify-content: center;
    box-shadow: 0 10px 26px -8px rgba(124,108,240,.7); border: none; cursor: pointer;
    transition: transform .15s ease;
  }
  .fab:active { transform: scale(.92); }
  .page-head .page-add-btn { display: none; }

  /* مودال‌ها به‌صورت شیت پایین‌آمده (bottom sheet) */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; width: 100%; border-radius: 20px 20px 0 0; max-height: 90dvh;
    animation: sheet-up .22s cubic-bezier(.32,.72,0,1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal::before {
    content: ''; display: block; width: 40px; height: 4px; border-radius: 3px;
    background: var(--border); margin: 10px auto 0;
  }
  .modal--wide { max-width: 100%; }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* جدول‌ها به کارت‌های عمودی تبدیل می‌شوند تا اسکرول افقی نداشته باشیم */
  .table-wrap { border: none; background: transparent; overflow: visible; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
    margin-bottom: 10px; padding: 6px 4px;
  }
  .table-wrap tr:hover { background: var(--surface); }
  .table-wrap td {
    border: none; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-size: 13px; text-align: left;
  }
  .table-wrap td[data-label]:before {
    content: attr(data-label); color: var(--text-faint); font-size: 11.5px; flex-shrink: 0;
  }
  .table-wrap td.cell-nolabel:before { content: ''; }
  .table-wrap .row-actions { justify-content: flex-end; width: 100%; }
}

@media (max-width: 560px) {
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .toolbar { flex-direction: column; align-items: stretch; }
}

@media (min-width: 901px) {
  .fab { display: none !important; }
}
