/* ===== NIYANAVA PANEL - MAIN CSS ===== */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --accent: #8B0000;
  --accent-light: #c0392b;
  --accent-glow: rgba(139,0,0,0.25);
  --accent-ultra: rgba(139,0,0,0.08);
  --bg-primary: #020617;
  --bg-secondary: #0a0f1e;
  --bg-card: rgba(15,23,42,0.6);
  --bg-glass: rgba(15,23,42,0.75);
  --bg-sidebar: rgba(5,10,20,0.97);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --border: rgba(148,163,184,0.1);
  --border-glass: rgba(148,163,184,0.15);
  --glass-blur: blur(20px);
  --sidebar-width: 260px;
  --header-height: 64px;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow: 0 4px 32px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

body.light-mode {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255,255,255,0.85);
  --bg-glass: rgba(255,255,255,0.9);
  --bg-sidebar: rgba(248,250,252,0.98);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: rgba(100,116,139,0.15);
  --border-glass: rgba(100,116,139,0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Vazirmatn', system-ui, sans-serif;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,0,0,0.4); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== LAYOUT ===== */
.panel-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 900;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #c0392b);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.logo-text { flex: 1; }
.logo-text h2 { font-size: 15px; font-weight: 800; color: var(--text-primary); }
.logo-text span { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(139,0,0,0.1);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(139,0,0,0.2), rgba(139,0,0,0.08));
  color: #fca5a5;
  border: 1px solid rgba(139,0,0,0.25);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .icon { opacity: 1; }
.nav-badge {
  margin-right: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

/* ===== HEADER ===== */
.main-header {
  position: fixed;
  top: 0;
  right: var(--sidebar-width);
  left: 0;
  height: var(--header-height);
  z-index: 800;
  background: var(--bg-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  transition: right 0.3s ease;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }
.breadcrumb-sep { opacity: 0.4; }

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  min-width: 200px;
}
.header-search:hover { border-color: rgba(139,0,0,0.3); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-glass); color: var(--text-primary); border-color: var(--border-glass); }

.notification-dot {
  position: absolute;
  top: -3px;
  left: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  border: 2px solid var(--bg-primary);
  line-height: 1;
  box-shadow: 0 2px 6px rgba(139,0,0,.4);
}
/* پیل «X پیام جدید» زیر زنگوله */
.bell-undertext {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #c0392b);
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: 0 6px 18px -6px rgba(139,0,0,.6);
  z-index: 60;
  animation: bellPulse 2s ease-in-out infinite;
}
.bell-undertext::before {
  content: '';
  position: absolute;
  top: -4px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px; background: var(--accent);
}
@keyframes bellPulse { 0%,100%{ transform:translateX(-50%) translateY(0); } 50%{ transform:translateX(-50%) translateY(-2px); } }

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #c0392b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-right: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  transition: margin-right 0.3s ease;
}

.page-content {
  padding: 24px;
  max-width: 1400px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(139,0,0,0.2); }

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-card-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
}

.stat-card-label { font-size: 13px; color: var(--text-muted); }
.stat-card-change {
  font-size: 11px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 12px 16px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(139,0,0,0.04); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.12); color: #34d399; }
.badge-warning { background: rgba(245,158,11,0.12); color: #fbbf24; }
.badge-danger { background: rgba(239,68,68,0.12); color: #f87171; }
.badge-info { background: rgba(59,130,246,0.12); color: #60a5fa; }
.badge-neutral { background: rgba(148,163,184,0.12); color: #94a3b8; }
.badge-accent { background: rgba(139,0,0,0.15); color: #fca5a5; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}
.btn-secondary:hover { background: var(--bg-glass); color: var(--text-primary); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-danger { background: rgba(239,68,68,0.12); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success { background: rgba(16,185,129,0.12); color: #34d399; }
.btn-success:hover { background: rgba(16,185,129,0.2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 9px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: rgba(139,0,0,0.5); box-shadow: 0 0 0 3px rgba(139,0,0,0.1); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; background: var(--bg-card); border-radius: 10px; padding: 4px; }
.tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition);
}
.tab.active {
  background: linear-gradient(135deg, rgba(139,0,0,0.2), rgba(139,0,0,0.1));
  color: #fca5a5;
  border: 1px solid rgba(139,0,0,0.2);
}

/* ===== ALERTS ===== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); color: #34d399; }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2); color: #fbbf24; }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.2); color: #60a5fa; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 320px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== PROGRESS ===== */
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.progress-accent { background: linear-gradient(90deg, var(--accent), #c0392b); }
.progress-success { background: linear-gradient(90deg, #059669, #10b981); }
.progress-info { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }
.progress-warning { background: linear-gradient(90deg, #b45309, #f59e0b); }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 500;
  display: none;
  overflow: hidden;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.dropdown-item:hover { background: rgba(139,0,0,0.08); color: var(--text-primary); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: var(--transition);
}
.page-btn:hover { border-color: rgba(139,0,0,0.3); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ===== AVATAR ===== */
.avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-text { font-size: 13px; }

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
}
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ===== TOGGLE ===== */
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 99px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 2px; right: 2px;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: rgba(139,0,0,0.2); border-color: rgba(139,0,0,0.4); }
.toggle input:checked + .toggle-slider::before { background: var(--accent); transform: translateX(-18px); }

/* ===== CHART AREA ===== */
.chart-container { position: relative; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-left h1 { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.page-header-left p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== SIDEBAR TOGGLE (mobile) ===== */
.sidebar-toggle { display: none; }

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(100%);
    box-shadow: -8px 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .main-header { right: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 850;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 16px; }
  .form-row-2 { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card-value { font-size: 18px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade { animation: fadeIn 0.3s ease; }
.animate-slide { animation: slideUp 0.3s ease; }

/* ===== UTILITY ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-accent { color: var(--accent-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.opacity-50 { opacity: 0.5; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }
.ltr { direction: ltr; }
.rtl { direction: rtl; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.bold { font-weight: 700; }

/* Liquid glass micro effect on hover */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: var(--transition);
}
.glass-card:hover {
  background: var(--accent-ultra);
  border-color: rgba(139,0,0,0.22);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
}

/* ============================================================
   بهبود تناسب رنگ‌ها + زنگوله‌ی اعلان‌ها (نسخه اصلاحی)
   ============================================================ */

/* هایلایت انتخاب متن — خوانا در هر دو تم */
::selection { background: var(--accent); color: #fff; }
::-moz-selection { background: var(--accent); color: #fff; }

/* اطمینان از کنتراست ورودی‌ها در فوکوس (پس‌زمینه‌ی توپر، نه شفاف تیره) */
.form-control:focus {
  border-color: rgba(139,0,0,0.6);
  box-shadow: 0 0 0 3px rgba(139,0,0,0.12);
  background: var(--bg-card);
}
textarea.form-control { background: var(--bg-card); color: var(--text-primary); }

/* آلرت‌ها: متن پررنگ‌تر و مجزا از پس‌زمینه */
.alert { font-weight: 600; }
.alert-success { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.35); color: #34d399; }
.alert-danger  { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.35);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.40); color: #fbbf24; }
.alert-info    { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.35); color: #60a5fa; }
body.light-mode .alert-success { color: #047857; }
body.light-mode .alert-danger  { color: #b91c1c; }
body.light-mode .alert-warning { color: #b45309; }
body.light-mode .alert-info    { color: #1d4ed8; }

/* ===== زنگوله‌ی اعلان‌ها ===== */
.bell-dropdown {
  position: absolute;
  top: 46px;
  left: 0;
  width: 340px;
  max-width: 88vw;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all .18s ease;
  z-index: 1200;
  overflow: hidden;
}
.bell-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.bell-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px; color: var(--text-primary);
}
.bell-mark {
  background: none; border: none; cursor: pointer;
  color: var(--accent-light); font-size: 11px; font-family: inherit;
}
.bell-list { max-height: 380px; overflow-y: auto; }
.bell-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.bell-item {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .15s ease;
}
.bell-item:hover { background: rgba(139,0,0,0.06); }
.bell-item.new { background: rgba(139,0,0,0.05); }
.bell-item.new .bell-title::after {
  content: ''; display: inline-block; width: 7px; height: 7px;
  background: var(--accent); border-radius: 50%; margin-right: 6px;
}
.bell-ico {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 10px; background: rgba(139,0,0,0.1);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.bell-body { flex: 1; min-width: 0; }
.bell-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.bell-msg { font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.6;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bell-date { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; }

/* نوار قرمز «N پیام جدید» داخل منوی زنگوله (liquid glass) */
.bell-newbar {
  padding: 9px 16px; font-size: 12px; font-weight: 700; color: #fff; text-align: center;
  background: linear-gradient(135deg, rgba(192,57,43,0.95), rgba(139,0,0,0.95));
  border-bottom: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* لوگوی برند در سایدبار — متناسب با تم */
.logo-imgbox { background: transparent !important; padding: 0 !important; display: flex; align-items: center; justify-content: center; overflow: visible; }
.brand-logo { width: auto; height: 42px; object-fit: contain; }
.brand-logo-light { display: none; }
body.light-mode .brand-logo-dark { display: none; }
body.light-mode .brand-logo-light { display: inline-block; }
/* لوگوی سایدبار: تیره‌تم→سفید، روشن‌تم→مشکی */
.sb-blogo { display: none; }
.sb-wlogo { display: block; }
body.light-mode .sb-blogo { display: block; }
body.light-mode .sb-wlogo { display: none; }
/* آواتار کاربر با عکس */
.avatar-btn.has-photo { padding: 0; overflow: hidden; }
.avatar-btn.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* آواتار بدون عکس: خاکستری ملایم و بدون پس‌زمینه‌ی قرمز */
.avatar-btn { background: var(--bg-card) !important; color: var(--text-secondary) !important; border: 1px solid var(--border-glass); text-decoration: none; }
.avatar-btn.has-photo { background: transparent !important; border: none; }
/* لوگوی برند در سایدبار بدون کادر/پس‌زمینه */
.logo-icon.logo-imgbox { width: auto !important; height: auto !important; background: transparent !important; box-shadow: none !important; border-radius: 0 !important; }

/* ===== نوار وضعیت سفارش (انیمیشنی) ===== */
.order-timeline { display:flex; align-items:flex-start; justify-content:space-between; position:relative; margin:8px 0 4px; padding:0 4px; }
.order-timeline .otl-line { position:absolute; top:22px; right:8%; left:8%; height:3px; background:var(--border-glass); border-radius:3px; z-index:0; }
.order-timeline .otl-line-fill { position:absolute; top:22px; right:8%; height:3px; background:linear-gradient(90deg,var(--success),#34d399); border-radius:3px; z-index:1; transition:width .6s ease; }
.otl-step { position:relative; z-index:2; display:flex; flex-direction:column; align-items:center; gap:6px; flex:1; text-align:center; }
.otl-dot { width:46px; height:46px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:20px; background:var(--bg-glass); border:2px solid var(--border-glass); color:var(--text-muted); transition:.3s; }
.otl-step.done .otl-dot { background:rgba(16,185,129,0.15); border-color:var(--success); color:var(--success); }
.otl-step.active .otl-dot { background:rgba(139,0,0,0.12); border-color:var(--accent); color:var(--accent-light,#ff6b6b); box-shadow:0 0 0 6px rgba(139,0,0,0.10); }
.otl-label { font-size:11px; color:var(--text-muted); font-weight:600; }
.otl-step.active .otl-label, .otl-step.done .otl-label { color:var(--text-primary); }
.otl-step.active .otl-anim-clock { animation:otl-tick 2s steps(8) infinite; transform-origin:center; }
.otl-step.active .otl-anim-gear  { animation:otl-spin 2.4s linear infinite; }
.otl-step.active .otl-anim-truck { animation:otl-drive 1.3s ease-in-out infinite; }
.otl-step.active .otl-anim-check { animation:otl-pop .7s ease infinite alternate; }
@keyframes otl-tick { to { transform:rotate(360deg); } }
@keyframes otl-spin { to { transform:rotate(360deg); } }
@keyframes otl-drive { 0%,100%{ transform:translateX(4px); } 50%{ transform:translateX(-4px); } }
@keyframes otl-pop { from{ transform:scale(1);} to{ transform:scale(1.18);} }
.order-timeline.cancelled { justify-content:center; }
.otl-cancel { display:flex; flex-direction:column; align-items:center; gap:8px; padding:8px 0; color:var(--danger); }
.otl-cancel .otl-dot { background:rgba(239,68,68,0.12); border-color:var(--danger); color:var(--danger); animation:otl-pop 1s ease infinite alternate; }

/* ============================================================
   ریسپانسیو موبایل — جمع‌کردن گریدهای inline و بهبود چیدمان
   (attribute selector + !important برای غلبه بر استایل inline)
   ============================================================ */
@media (max-width: 860px) {
  /* چیدمان‌های دو/چندستونه که با استایل inline ساخته شده‌اند → تک‌ستون */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns:3fr 2fr"],
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns:340px 1fr"],
  [style*="grid-template-columns:260px 1fr"],
  [style*="grid-template-columns:240px 1fr"],
  [style*="grid-template-columns:200px 1fr"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  /* نوارهای فیلتر افقی → عمودی */
  [style*="grid-template-columns:1fr auto auto auto"] {
    grid-template-columns: 1fr !important;
  }
  /* کارت‌های آماری چهارتایی/پنج‌تایی → دوتایی */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* عرض مودال‌ها در موبایل */
  .modal, .modal-lg { max-width: 94vw !important; width: 94vw !important; }
  /* هدر و محتوا */
  .page-content { padding: 14px !important; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  h1 { font-size: 20px !important; }
  /* جدول‌ها اسکرول افقی بگیرند */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 640px; }
}

@media (max-width: 480px) {
  /* در گوشی‌های کوچک، آماری‌ها هم تک‌ستون */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
  .page-content { padding: 10px !important; }
  .stat-card-value { font-size: 18px !important; }
  .btn { font-size: 13px; }
  /* دکمه‌های شناور گوشه‌ی صفحه‌ها زیر هم */
  .page-header .btn { width: 100%; }
}

/* اطمینان از اینکه محتوای اصلی در موبایل تمام‌عرض است */
@media (max-width: 1024px) {
  .main-content { margin-right: 0 !important; }
  .shop-layout { grid-template-columns: 1fr !important; }
}

/* ============================================================
   تقویت ریسپانسیو پنل برای موبایل (سبد، کیف پول، سفارش‌ها، اعلان‌ها)
   ============================================================ */
@media (max-width: 640px) {
  /* ردیف‌های آیتم با padding زیاد → جمع‌وجورتر و قابل wrap */
  .page-content [style*="display:flex"][style*="align-items:center"][style*="gap:16px"] { gap: 12px !important; flex-wrap: wrap; }
  /* دکمه‌های کنترل تعداد و حذف زیر هم نروند و جمع بمانند */
  .qtybox { flex-wrap: wrap; }
  /* کارت‌های آماری تک‌ستون در گوشی کوچک */
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] { grid-template-columns: 1fr !important; }
  /* عنوان صفحه و اکشن‌ها */
  .page-header .btn { width: 100%; }
  /* مودال‌ها تقریباً تمام‌عرض با اسکرول داخلی */
  .modal, .modal-lg, .modal-xl { max-width: 94vw !important; width: 94vw !important; max-height: 88vh; overflow-y: auto; }
  .modal-body { padding: 16px !important; }
  /* dropdown اعلان: در موبایل ثابت و داخل ویوپورت */
  .bell-dropdown { position: fixed !important; top: 64px !important; right: 8px !important; left: 8px !important; width: auto !important; max-width: none !important; max-height: 76vh; overflow-y: auto; }
  .bell-undertext { display: none !important; } /* در موبایل فقط نشان عددی کافی است */
  /* دکمه‌های ردیفی درون کارت‌ها wrap شوند */
  .page-content [style*="display:flex"][style*="justify-content:space-between"] { flex-wrap: wrap; gap: 10px; }
}
/* آدرس‌های ذخیره‌شده در چک‌اوت */
.saved-addr-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.saved-addr { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: .2s; background: var(--bg-card); }
.saved-addr:hover { border-color: rgba(139,0,0,.4); }
.saved-addr.selected { border-color: var(--accent); background: rgba(139,0,0,.06); box-shadow: 0 0 0 2px rgba(139,0,0,.12); }
.saved-addr input[type=radio] { margin-top: 3px; accent-color: var(--accent); }
.saved-addr .sa-body { flex: 1; min-width: 0; }
.saved-addr .sa-title { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.saved-addr .sa-text { font-size: 13px; color: var(--text-secondary); line-height: 1.8; }

/* آیکون‌های SVG منوی سایدبار */
.nav-ico { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.nav-ico svg { width: 18px; height: 18px; display: block; }

/* آیکون SVG داخل استت‌کارت‌ها (مرکزچین) */
.stat-card-icon { display: flex; align-items: center; justify-content: center; }
.stat-card-icon svg { width: 24px; height: 24px; display: block; }

/* ===== کارت سفارش «خریدهای من» — چیدمان مرتب موبایل ===== */
.uo-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); }
.uo-price { font-size: 17px; font-weight: 800; color: var(--success); white-space: nowrap; }
.uo-price bdi { direction: ltr; unicode-bidi: isolate; }
.uo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 540px) {
  .uo-foot { flex-direction: column; align-items: stretch; }
  .uo-price { text-align: center; font-size: 18px; }
  .uo-actions { width: 100%; }
  .uo-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ===== چیپ‌های فیلتر اعلان‌ها — نمایش کامل در موبایل ===== */
#notif-tabs { flex-wrap: wrap; }
@media (max-width: 640px) {
  #notif-tabs { gap: 6px; }
  #notif-tabs .btn { padding: 7px 11px; font-size: 12px; flex: 0 0 auto; white-space: nowrap; }
}
@media (max-width: 380px) {
  #notif-tabs .btn { flex: 1 1 calc(50% - 6px); justify-content: center; }
}
