:root {
  color-scheme: dark;
  --bg: #0f0f23;
  --surface: #1a1a2e;
  --surface-2: #16213e;
  --accent: #ffd700;
  --accent-soft: #ffed4e;
  --accent-dark: #b7791f;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: rgba(255, 215, 0, .18);
  --danger: #f87171;
  --success: #4ade80;
  --info: #60a5fa;
}

* { box-sizing: border-box; font-family: "Vazirmatn", sans-serif; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 5%, rgba(255, 215, 0, .07), transparent 25rem),
    linear-gradient(135deg, var(--bg), var(--surface) 52%, var(--surface-2));
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.app-sidebar {
  position: fixed; inset: 0 0 0 auto; z-index: 50; width: 16rem;
  display: flex; flex-direction: column; background: rgba(26, 26, 46, .97);
  border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(0,0,0,.25);
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem; border-bottom: 1px solid var(--line); }
.brand-mark { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: 1rem; color: var(--bg); background: linear-gradient(135deg,var(--accent),var(--accent-dark)); box-shadow: 0 0 22px rgba(255,215,0,.22); }
.brand strong { color: var(--accent); display: block; }
.brand small, .profile small { color: var(--muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; scrollbar-width: thin; scrollbar-color: var(--accent-dark) transparent; }
.nav-link, .nav-group-toggle {
  width: 100%; display: flex; align-items: center; gap: .8rem; padding: .72rem .85rem;
  border: 0; border-radius: .75rem; color: #d1d5db; background: transparent; text-align: right;
  transition: color .2s, background .2s, transform .2s;
}
.nav-link:hover, .nav-group-toggle:hover { color: var(--accent); background: rgba(255,215,0,.07); transform: translateX(-2px); }
.nav-link.active { color: var(--accent); background: linear-gradient(90deg,rgba(255,215,0,.12),rgba(255,215,0,.04)); box-shadow: inset -3px 0 var(--accent); }
.nav-group-toggle .chevron { margin-right: auto; transition: transform .25s; }
.nav-group.open .chevron { transform: rotate(180deg); }
.nav-submenu { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.nav-group.open .nav-submenu { grid-template-rows: 1fr; }
.nav-submenu > div { overflow: hidden; }
.nav-submenu .nav-link { padding: .55rem 2.65rem .55rem .75rem; font-size: .86rem; }
.sidebar-profile { margin: .75rem; padding: .8rem; display: flex; align-items: center; gap: .7rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: .9rem; }
.sidebar-profile img { width: 2.35rem; height: 2.35rem; border-radius: 50%; }
.profile-status { width: .5rem; height: .5rem; margin-right: auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); }
.sidebar-overlay { position: fixed; inset: 0; z-index: 40; visibility: hidden; opacity: 0; background: rgba(0,0,0,.58); backdrop-filter: blur(3px); transition: .25s; }
.menu-button { display: none; position: fixed; top: 1rem; right: 1rem; z-index: 60; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%; background: var(--accent); color: var(--bg); box-shadow: 0 8px 25px rgba(0,0,0,.3); }

.app-main { min-height: 100vh; margin-right: 16rem; }
.app-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.5rem; background: rgba(26,26,46,.76); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px);
}
.page-title h1 { margin: 0; color: var(--accent); font-size: clamp(1.25rem,3vw,1.65rem); }
.page-title p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.header-actions { display: flex; align-items: center; gap: .65rem; }
.icon-button { position: relative; width: 2.6rem; height: 2.6rem; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); background: var(--surface-2); transition: .2s; }
.icon-button:hover { color: var(--bg); background: var(--accent); transform: translateY(-2px); }
.notification-dot { position: absolute; top: -.15rem; left: -.1rem; min-width: 1.1rem; height: 1.1rem; display: grid; place-items: center; border-radius: 1rem; color: white; background: #ef4444; font-size: .66rem; }
.page-content { width: min(100%, 1600px); margin-inline: auto; padding: 1.25rem 1.5rem 2.5rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 1.5rem; }

.card {
  position: relative; overflow: hidden; padding: 1.2rem; border: 1px solid var(--line); border-radius: 1rem;
  background: linear-gradient(145deg,rgba(26,26,46,.98),rgba(22,33,62,.9)); box-shadow: 0 12px 35px rgba(0,0,0,.13);
}
.lift { transition: transform .25s, box-shadow .25s, border-color .25s; }
.lift:hover { transform: translateY(-4px); border-color: rgba(255,215,0,.38); box-shadow: 0 18px 40px rgba(0,0,0,.23),0 0 20px rgba(255,215,0,.06); }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem; margin-bottom: 1rem; }
.section-head h2, .section-head h3 { margin: 0; color: var(--accent); font-size: 1.05rem; }
.section-head p { margin: .25rem 0 0; color: var(--muted); font-size: .82rem; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { margin: .3rem 0; color: var(--accent); font-size: clamp(1.25rem,3vw,1.7rem); font-weight: 700; }
.trend { font-size: .75rem; color: var(--success); }
.trend.down { color: var(--danger); }
.stat-icon { flex: 0 0 auto; width: 3.2rem; height: 3.2rem; display: grid; place-items: center; border-radius: 1rem; background: rgba(255,215,0,.1); color: var(--accent); font-size: 1.25rem; }

.btn { min-height: 2.55rem; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .55rem 1rem; border: 1px solid transparent; border-radius: .7rem; font-weight: 600; transition: .2s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { color: var(--bg); background: linear-gradient(135deg,var(--accent),var(--accent-dark)); box-shadow: 0 8px 20px rgba(255,215,0,.13); }
.btn-secondary { color: var(--accent); background: rgba(255,215,0,.08); border-color: var(--line); }
.btn-danger { color: #fecaca; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.25); }
.btn-sm { min-height: 2rem; padding: .35rem .65rem; font-size: .78rem; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; }
.toolbar .field { flex: 1 1 12rem; }

.field { display: grid; gap: .4rem; }
.field label { color: #d1d5db; font-size: .82rem; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 2.7rem; padding: .62rem .8rem; color: var(--text); background: rgba(15,15,35,.62);
  border: 1px solid rgba(156,163,175,.22); border-radius: .68rem; transition: border-color .2s,box-shadow .2s;
}
.textarea { min-height: 7rem; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,215,0,.09); }
.input::placeholder, .textarea::placeholder { color: #6b7280; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.field-full { grid-column: 1 / -1; }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch-track { width: 2.65rem; height: 1.4rem; padding: .18rem; border-radius: 2rem; background: #374151; transition: .2s; }
.switch-track::after { content: ""; display: block; width: 1.04rem; height: 1.04rem; border-radius: 50%; background: white; transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--accent-dark); }
.switch input:checked + .switch-track::after { transform: translateX(-1.25rem); }

.table-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--accent-dark) var(--surface); }
.data-table { width: 100%; min-width: 680px; border-collapse: collapse; }
.data-table th { padding: .85rem; color: var(--muted); font-size: .78rem; font-weight: 500; text-align: right; border-bottom: 1px solid rgba(156,163,175,.2); }
.data-table td { padding: .85rem; color: #d1d5db; font-size: .84rem; border-bottom: 1px solid rgba(156,163,175,.1); }
.data-table tbody tr { transition: background .2s; }
.data-table tbody tr:hover { background: rgba(255,215,0,.035); }
.data-table tr:last-child td { border-bottom: 0; }
.entity { display: flex; align-items: center; gap: .65rem; }
.entity-avatar { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: .7rem; color: var(--accent); background: rgba(255,215,0,.1); }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .55rem; border-radius: 2rem; font-size: .72rem; white-space: nowrap; }
.badge.success { color: var(--success); background: rgba(34,197,94,.12); }
.badge.warning { color: var(--accent); background: rgba(255,215,0,.11); }
.badge.info { color: var(--info); background: rgba(59,130,246,.13); }
.badge.danger { color: var(--danger); background: rgba(239,68,68,.12); }
.actions { display: flex; align-items: center; gap: .35rem; }
.action-btn { width: 2rem; height: 2rem; border: 0; border-radius: .55rem; color: var(--muted); background: var(--surface-2); transition: .2s; }
.action-btn:hover { color: var(--accent); background: rgba(255,215,0,.1); }

.chart { min-height: 240px; display: flex; align-items: flex-end; gap: clamp(.45rem,2vw,1rem); padding: 1.3rem .4rem .3rem; border-bottom: 1px solid rgba(156,163,175,.18); }
.chart-bar { position: relative; flex: 1; min-width: 1rem; height: var(--value); max-width: 3rem; border-radius: .55rem .55rem 0 0; background: linear-gradient(to top,var(--accent-dark),var(--accent)); animation: grow .8s both; transform-origin: bottom; }
.chart-bar:hover { filter: brightness(1.15); }
.chart-bar::after { content: attr(data-label); position: absolute; bottom: -1.7rem; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: .68rem; }
.progress { height: .5rem; overflow: hidden; border-radius: 1rem; background: rgba(156,163,175,.12); }
.progress > span { display: block; height: 100%; width: var(--value); border-radius: inherit; background: linear-gradient(90deg,var(--accent-dark),var(--accent)); }
.list { display: grid; gap: .75rem; }
.list-item { display: flex; align-items: center; gap: .75rem; padding-bottom: .75rem; border-bottom: 1px solid rgba(156,163,175,.1); }
.list-item:last-child { padding-bottom: 0; border-bottom: 0; }
.list-icon { width: 2.3rem; height: 2.3rem; display: grid; place-items: center; flex: 0 0 auto; border-radius: .75rem; color: var(--accent); background: rgba(255,215,0,.09); }
.list-copy { min-width: 0; flex: 1; }
.list-copy strong { display: block; font-size: .85rem; }
.list-copy small { color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; color: var(--muted); font-size: .78rem; }
.pagination-controls { display: flex; gap: .3rem; }
.page-btn { min-width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--muted); background: transparent; }
.page-btn.active, .page-btn:hover { color: var(--bg); background: var(--accent); }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { display: block; margin-bottom: .7rem; color: var(--accent); font-size: 2rem; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; visibility: hidden; opacity: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(5px); transition: .2s; }
.modal-backdrop.open { visibility: visible; opacity: 1; }
.modal { width: min(100%, 34rem); max-height: 88vh; overflow-y: auto; padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); transform: translateY(20px) scale(.98); transition: .25s; }
.modal-backdrop.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-head h2 { margin: 0; color: var(--accent); font-size: 1.1rem; }
.toast-stack { position: fixed; left: 1rem; bottom: 1rem; z-index: 120; display: grid; gap: .6rem; }
.toast { display: flex; align-items: center; gap: .65rem; max-width: 22rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .8rem; color: var(--text); background: var(--surface-2); box-shadow: 0 15px 35px rgba(0,0,0,.3); animation: toast-in .3s both; }
.toast i { color: var(--success); }
.reveal { opacity: 0; transform: translateY(15px); animation: reveal .55s forwards; animation-delay: var(--delay,0ms); }

@keyframes reveal { to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(-15px); } }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .app-sidebar { transform: translateX(102%); }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay { visibility: visible; opacity: 1; }
  .menu-button { display: grid; place-items: center; }
  .app-main { margin-right: 0; }
  .app-header { padding-right: 4.5rem; }
}
@media (max-width: 640px) {
  .page-content { padding: 1rem .8rem 2rem; }
  .app-header { align-items: flex-start; padding-left: .8rem; }
  .page-title p { display: none; }
  .header-profile span { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .card { padding: 1rem; }
  .toolbar { align-items: stretch; }
  .toolbar > * { width: 100%; }
  .btn { width: 100%; }
  .actions .action-btn { width: 2.2rem; }
  .data-table.responsive { min-width: 0; }
  .data-table.responsive thead { display: none; }
  .data-table.responsive, .data-table.responsive tbody, .data-table.responsive tr, .data-table.responsive td { display: block; width: 100%; }
  .data-table.responsive tr { margin-bottom: .75rem; padding: .5rem; border: 1px solid var(--line); border-radius: .75rem; background: rgba(15,15,35,.35); }
  .data-table.responsive td { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem; text-align: left; border-bottom: 1px solid rgba(156,163,175,.08); }
  .data-table.responsive td::before { content: attr(data-label); color: var(--muted); text-align: right; }
  .data-table.responsive td:last-child { border-bottom: 0; }
}
@media print {
  .app-sidebar, .app-header, .menu-button, .sidebar-overlay, .no-print { display: none !important; }
  .app-main { margin: 0; }
  body, .card { color: #111; background: #fff; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =========================================================
   افزوده‌های نسخه کامل — بوتیک موژان
   ========================================================= */

.avatar-circle {
  width: 2.35rem; height: 2.35rem; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--bg); font-weight: 700;
}
.toast-danger { border-color: var(--danger) !important; color: var(--danger); }
.hide-sm { display: inline; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* --- صفحه ورود --- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-card {
  width: min(26rem, 100%); padding: 2rem;
  background: rgba(26, 26, 46, .92); border: 1px solid var(--line);
  border-radius: 1.4rem; box-shadow: 0 30px 60px rgba(0,0,0,.45);
}
.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-brand .brand-mark {
  width: 3.5rem; height: 3.5rem; margin: 0 auto .9rem; display: grid; place-items: center;
  border-radius: 1.1rem; font-size: 1.4rem; color: var(--bg);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 0 30px rgba(255,215,0,.3);
}
.login-brand h1 { margin: 0; color: var(--accent); font-size: 1.35rem; }
.login-brand p { margin: .35rem 0 0; color: var(--muted); font-size: .88rem; }
.login-error {
  display: none; margin-bottom: 1rem; padding: .7rem .9rem; border-radius: .7rem;
  background: rgba(248,113,113,.12); border: 1px solid var(--danger);
  color: var(--danger); font-size: .87rem;
}
.login-error.show { display: block; }

/* --- حالت‌های بارگذاری و خالی --- */
.state-row td { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.state-row .fa-spinner { margin-left: .5rem; }
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2.5rem; color: var(--line); display: block; margin-bottom: .9rem; }
.empty-state strong { display: block; color: var(--text); margin-bottom: .35rem; }

/* --- گالری تصاویر محصول --- */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: .7rem; }
.image-tile { position: relative; aspect-ratio: 1; border-radius: .8rem; overflow: hidden; border: 1px solid var(--line); }
.image-tile img { width: 100%; height: 100%; object-fit: cover; }
.image-tile button {
  position: absolute; top: .3rem; left: .3rem; width: 1.7rem; height: 1.7rem;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: var(--danger);
}
.upload-tile {
  aspect-ratio: 1; display: grid; place-items: center; gap: .35rem; cursor: pointer;
  border: 1px dashed var(--line); border-radius: .8rem; color: var(--muted); font-size: .8rem;
  transition: border-color .2s, color .2s;
}
.upload-tile:hover { border-color: var(--accent); color: var(--accent); }

/* --- نمودار --- */
.chart { min-height: 12rem; }
.chart-bar { position: relative; }
.chart-bar::after {
  content: attr(data-value); position: absolute; top: -1.35rem; right: 50%;
  transform: translateX(50%); font-size: .68rem; color: var(--muted); white-space: nowrap;
}

/* --- ریز‌جزئیات جدول --- */
.table-meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; color: var(--muted); font-size: .85rem; }
.color-dot { display: inline-block; width: .85rem; height: .85rem; border-radius: 50%; border: 1px solid var(--line); vertical-align: -2px; margin-left: .3rem; }
.variant-chip {
  display: inline-flex; align-items: center; gap: .3rem; margin: .15rem;
  padding: .2rem .55rem; border-radius: 999px; font-size: .75rem;
  background: rgba(255,215,0,.08); border: 1px solid var(--line);
}
.variant-chip.low { background: rgba(248,113,113,.12); border-color: var(--danger); color: var(--danger); }
