/* ==========================================================================
   سایت‌ساز — Design system
   RTL-first · light/dark · mobile-first
   ========================================================================== */

/* --------------------------------------------------------------- tokens */
:root {
  --c-primary: #6366f1;
  --c-primary-hover: #4f46e5;
  --c-primary-soft: #eef2ff;
  --c-primary-border: #c7d2fe;

  --c-success: #10b981;
  --c-success-soft: #ecfdf5;
  --c-warning: #f59e0b;
  --c-warning-soft: #fffbeb;
  --c-danger: #ef4444;
  --c-danger-soft: #fef2f2;
  --c-info: #0ea5e9;
  --c-info-soft: #f0f9ff;

  --c-bg: #f6f7fb;
  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;
  --c-elevated: #ffffff;
  --c-text: #0f172a;
  --c-text-soft: #475569;
  --c-muted: #94a3b8;
  --c-border: #e6e9f0;
  --c-border-strong: #cbd5e1;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
  --shadow: 0 6px 22px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 45px rgba(15, 23, 42, .12);

  --sidebar-w: 260px;
  --header-h: 64px;

  --font: "Vazirmatn", "Vazir", Tahoma, system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .15s var(--ease);
  --t: .25s var(--ease);
}

[data-theme="dark"] {
  --c-primary: #818cf8;
  --c-primary-hover: #a5b4fc;
  --c-primary-soft: #1e1b4b;
  --c-primary-border: #3730a3;

  --c-success-soft: #052e26;
  --c-warning-soft: #2e1f05;
  --c-danger-soft: #2d1114;
  --c-info-soft: #04293d;

  --c-bg: #0b0e17;
  --c-surface: #141926;
  --c-surface-2: #1a2030;
  --c-elevated: #1a2030;
  --c-text: #e8ecf5;
  --c-text-soft: #a7b0c4;
  --c-muted: #6b7590;
  --c-border: #242b3d;
  --c-border-strong: #333c52;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow: 0 6px 22px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, .5);
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.85;
  color: var(--c-text);
  background: var(--c-bg);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t), color var(--t);
}

img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--c-primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--c-primary-hover); }
h1, h2, h3, h4, h5 { margin: 0 0 .6rem; line-height: 1.5; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-inline-start: 1.4rem; }
hr { border: none; border-top: 1px solid var(--c-border); margin: 1.5rem 0; }
code, pre, .ltr { direction: ltr; text-align: left; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
code { background: var(--c-surface-2); padding: .15em .45em; border-radius: 6px; font-size: .88em; }

:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 999;
  background: var(--c-primary); color: #fff; padding: .7rem 1.2rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { inset-inline-start: 0; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* -------------------------------------------------------------- layout */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 1rem; }
.container-narrow { max-width: 820px; }
.container-wide { max-width: 1440px; }

.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.row-center { display: flex; align-items: center; gap: .5rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.flex-1 { flex: 1 1 0; min-width: 0; }
.gap-sm { gap: .5rem; }
.gap-lg { gap: 1.5rem; }

.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }
.text-muted { color: var(--c-muted); }
.text-soft { color: var(--c-text-soft); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .78rem; }
.text-lg { font-size: 1.1rem; }
.fw-bold { font-weight: 700; }
.fw-medium { font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- card */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-pad { padding: 1.25rem; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 1.25rem; }
.card-foot {
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}
.card-hover { transition: transform var(--t), box-shadow var(--t), border-color var(--t); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--c-primary-border); }

.glass {
  background: color-mix(in srgb, var(--c-surface) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .62rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.6;
}
.btn:hover { background: var(--c-primary-hover); color: #fff; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }

.btn-ghost { background: transparent; color: var(--c-text-soft); border-color: var(--c-border); }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); border-color: var(--c-border-strong); }

.btn-soft { background: var(--c-primary-soft); color: var(--c-primary); border-color: var(--c-primary-border); }
.btn-soft:hover { background: var(--c-primary); color: #fff; }

.btn-danger { background: var(--c-danger); }
.btn-danger:hover { background: #dc2626; }
.btn-danger-soft { background: var(--c-danger-soft); color: var(--c-danger); border-color: color-mix(in srgb, var(--c-danger) 30%, transparent); }
.btn-danger-soft:hover { background: var(--c-danger); color: #fff; }

.btn-success { background: var(--c-success); }
.btn-success:hover { background: #059669; }

.btn-sm { padding: .4rem .8rem; font-size: .82rem; border-radius: var(--radius-sm); }
.btn-lg { padding: .85rem 1.7rem; font-size: 1rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; width: 36px; height: 36px; border-radius: var(--radius-sm); }
.btn .icon { width: 18px; height: 18px; flex-shrink: 0; }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- forms */
.field { margin-bottom: 1.1rem; }
.field-label {
  display: block; margin-bottom: .4rem;
  font-size: .88rem; font-weight: 600; color: var(--c-text-soft);
}
.field-label .req { color: var(--c-danger); margin-inline-start: .15rem; }

.input, .select, .textarea {
  width: 100%;
  padding: .65rem .9rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  font-size: .93rem;
}
.input::placeholder, .textarea::placeholder { color: var(--c-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--c-surface-2); color: var(--c-muted); cursor: not-allowed; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.9; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left .8rem center;
  background-size: 16px;
  padding-inline-start: 2.2rem;
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--c-danger); }
.field-error { display: block; margin-top: .35rem; font-size: .8rem; color: var(--c-danger); }
.field-hint { display: block; margin-top: .35rem; font-size: .8rem; color: var(--c-muted); }

.input-ltr { direction: ltr; text-align: left; }

.input-group { display: flex; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .btn { border-start-start-radius: 0; border-end-start-radius: 0; }

.input-prefix { position: relative; }
.input-prefix .input { padding-inline-start: 2.6rem; }
.input-prefix .prefix {
  position: absolute; inset-inline-start: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--c-muted); pointer-events: none; font-size: .85rem;
}

.checkbox, .radio { display: flex; align-items: flex-start; gap: .6rem; cursor: pointer; padding: .3rem 0; }
.checkbox input, .radio input { width: 18px; height: 18px; margin: .25rem 0 0; accent-color: var(--c-primary); cursor: pointer; flex-shrink: 0; }
.checkbox span, .radio span { font-size: .9rem; line-height: 1.7; }

.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 42px; height: 24px; border-radius: var(--radius-full);
  background: var(--c-border-strong); position: relative;
  transition: background var(--t); flex-shrink: 0;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; inset-inline-end: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform var(--t); box-shadow: var(--shadow-xs);
}
.switch input:checked + .switch-track { background: var(--c-primary); }
.switch input:checked + .switch-track::after { transform: translateX(-18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type="color"] {
  width: 46px; height: 38px; padding: 2px; border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm); background: var(--c-surface); cursor: pointer;
}

/* -------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: var(--radius-full);
  font-size: .75rem; font-weight: 600;
  background: var(--c-surface-2); color: var(--c-text-soft);
  border: 1px solid var(--c-border);
  white-space: nowrap;
}
.badge-success { background: var(--c-success-soft); color: var(--c-success); border-color: color-mix(in srgb, var(--c-success) 25%, transparent); }
.badge-warning { background: var(--c-warning-soft); color: #b45309; border-color: color-mix(in srgb, var(--c-warning) 25%, transparent); }
.badge-danger  { background: var(--c-danger-soft); color: var(--c-danger); border-color: color-mix(in srgb, var(--c-danger) 25%, transparent); }
.badge-info    { background: var(--c-info-soft); color: var(--c-info); border-color: color-mix(in srgb, var(--c-info) 25%, transparent); }
.badge-primary { background: var(--c-primary-soft); color: var(--c-primary); border-color: var(--c-primary-border); }
.badge-muted   { background: var(--c-surface-2); color: var(--c-muted); }
[data-theme="dark"] .badge-warning { color: var(--c-warning); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .89rem; min-width: 640px; }
.table th, .table td { padding: .8rem 1rem; text-align: right; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table th {
  font-weight: 600; font-size: .82rem; color: var(--c-text-soft);
  background: var(--c-surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: .35rem; justify-content: flex-start; }
.table-fixed { min-width: 0; }

/* ---------------------------------------------------------- empty state */
.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--c-muted);
}
.empty .icon { width: 56px; height: 56px; margin: 0 auto 1rem; opacity: .4; stroke-width: 1.2; }
.empty h3 { color: var(--c-text-soft); font-size: 1.05rem; margin-bottom: .4rem; }
.empty p { margin-bottom: 1.2rem; font-size: .9rem; }

/* --------------------------------------------------------------- alerts */
.alert {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: .9rem;
  margin-bottom: 1rem;
}
.alert .icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: .15rem; }
.alert-success { background: var(--c-success-soft); border-color: color-mix(in srgb, var(--c-success) 30%, transparent); color: #065f46; }
.alert-error, .alert-danger { background: var(--c-danger-soft); border-color: color-mix(in srgb, var(--c-danger) 30%, transparent); color: #991b1b; }
.alert-warning { background: var(--c-warning-soft); border-color: color-mix(in srgb, var(--c-warning) 30%, transparent); color: #92400e; }
.alert-info { background: var(--c-info-soft); border-color: color-mix(in srgb, var(--c-info) 30%, transparent); color: #075985; }
[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-error, [data-theme="dark"] .alert-danger { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info { color: #7dd3fc; }

/* --------------------------------------------------------------- toasts */
.toast-host {
  position: fixed; bottom: 1rem; inset-inline-start: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .6rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  background: var(--c-elevated);
  border: 1px solid var(--c-border);
  border-inline-start: 3px solid var(--c-primary);
  box-shadow: var(--shadow-lg);
  font-size: .88rem;
  pointer-events: auto;
  animation: toast-in .3s var(--ease);
}
.toast.is-out { animation: toast-out .25s var(--ease) forwards; }
.toast-success { border-inline-start-color: var(--c-success); }
.toast-error { border-inline-start-color: var(--c-danger); }
.toast-warning { border-inline-start-color: var(--c-warning); }
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: .2rem; }
.toast-success .icon { color: var(--c-success); }
.toast-error .icon { color: var(--c-danger); }
.toast-warning .icon { color: var(--c-warning); }
.toast-close { background: none; border: none; color: var(--c-muted); cursor: pointer; padding: 0 .2rem; margin-inline-start: auto; }

@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------- modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fade-in .2s var(--ease);
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
  animation: modal-in .25s var(--ease);
  border: 1px solid var(--c-border);
}
.modal-lg { max-width: 760px; }
.modal-head {
  padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1.3rem; overflow-y: auto; }
.modal-foot {
  padding: 1rem 1.3rem; border-top: 1px solid var(--c-border);
  display: flex; gap: .6rem; justify-content: flex-start; flex-wrap: wrap;
  background: var(--c-surface-2);
}
.modal-close {
  background: none; border: none; cursor: pointer; color: var(--c-muted);
  padding: .3rem; border-radius: var(--radius-sm); line-height: 0;
}
.modal-close:hover { background: var(--c-surface-2); color: var(--c-text); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------- pagination */
.pagination { display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 .6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-soft);
  font-size: .87rem;
  transition: all var(--t-fast);
}
.pagination a:hover { background: var(--c-primary-soft); color: var(--c-primary); border-color: var(--c-primary-border); }
.pagination .is-current { background: var(--c-primary); color: #fff; border-color: var(--c-primary); font-weight: 600; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }

/* ------------------------------------------------------------ progress */
.progress { height: 8px; background: var(--c-surface-2); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--c-primary); border-radius: var(--radius-full); transition: width .5s var(--ease); }
.progress-bar.is-warning { background: var(--c-warning); }
.progress-bar.is-danger { background: var(--c-danger); }

/* ------------------------------------------------------------- skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-border) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- tabs */
.tabs {
  display: flex; gap: .3rem; overflow-x: auto;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 1.25rem;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: .65rem 1rem;
  border-bottom: 2px solid transparent;
  color: var(--c-text-soft);
  font-size: .89rem; font-weight: 500;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.tab:hover { color: var(--c-text); }
.tab.is-active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }

/* --------------------------------------------------------- breadcrumbs */
.breadcrumb { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .82rem; color: var(--c-muted); margin-bottom: .9rem; }
.breadcrumb a { color: var(--c-muted); }
.breadcrumb a:hover { color: var(--c-primary); }
.breadcrumb .sep { opacity: .5; }

/* ============================== PANEL SHELL ============================== */
.panel { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--c-surface);
  border-inline-start: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  position: fixed; inset-block: 0; inset-inline-end: 0;
  z-index: 200;
  transition: transform var(--t);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  font-weight: 700; font-size: 1.02rem;
  position: sticky; top: 0; background: var(--c-surface); z-index: 2;
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--c-primary), #a855f7);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.sidebar-brand .logo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.sidebar-nav { padding: .75rem; flex: 1; }
.nav-group-label {
  font-size: .72rem; font-weight: 700; color: var(--c-muted);
  padding: .9rem .75rem .35rem; letter-spacing: .02em;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
  font-size: .89rem; font-weight: 500;
  transition: all var(--t-fast);
  margin-bottom: .12rem;
}
.nav-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-link.is-active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
.nav-link .icon { width: 19px; height: 19px; flex-shrink: 0; }
.nav-link .count {
  margin-inline-start: auto; font-size: .72rem; font-weight: 700;
  background: var(--c-danger); color: #fff;
  min-width: 20px; height: 20px; padding: 0 .35rem;
  border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-foot { padding: .75rem; border-top: 1px solid var(--c-border); }

.panel-main {
  flex: 1; min-width: 0;
  margin-inline-end: var(--sidebar-w);
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: .75rem;
  padding-inline: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 700; font-size: 1rem; margin: 0; }

.panel-content { padding: 1.25rem 1rem 3rem; flex: 1; }

.menu-toggle { display: none; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-primary-soft); color: var(--c-primary);
  display: grid; place-items: center; font-weight: 700; font-size: .82rem;
  overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + .4rem); inset-inline-end: 0;
  min-width: 220px;
  background: var(--c-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .35rem;
  z-index: 300;
  display: none;
  max-height: 70vh; overflow-y: auto;
}
.dropdown.is-open .dropdown-menu { display: block; animation: modal-in .18s var(--ease); }
.dropdown-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; border-radius: var(--radius-sm);
  color: var(--c-text-soft); font-size: .87rem;
  width: 100%; background: none; border: none; cursor: pointer; text-align: start;
}
.dropdown-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.dropdown-item .icon { width: 17px; height: 17px; flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--c-border); margin: .35rem 0; }

/* -------------------------------------------------------- stat cards */
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: grid; place-items: center; margin-bottom: .7rem;
  background: var(--c-primary-soft); color: var(--c-primary);
}
.stat-icon .icon { width: 21px; height: 21px; }
.stat-value { font-size: 1.65rem; font-weight: 800; line-height: 1.25; }
.stat-label { font-size: .82rem; color: var(--c-muted); }
.stat-trend { font-size: .78rem; font-weight: 600; margin-top: .3rem; display: flex; align-items: center; gap: .25rem; }
.stat-trend.up { color: var(--c-success); }
.stat-trend.down { color: var(--c-danger); }
.stat--success .stat-icon { background: var(--c-success-soft); color: var(--c-success); }
.stat--warning .stat-icon { background: var(--c-warning-soft); color: var(--c-warning); }
.stat--danger .stat-icon { background: var(--c-danger-soft); color: var(--c-danger); }
.stat--info .stat-icon { background: var(--c-info-soft); color: var(--c-info); }

/* -------------------------------------------------------------- charts */
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--c-muted); margin-top: .6rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ------------------------------------------------------------ sortable */
.sortable-item { transition: box-shadow var(--t-fast), opacity var(--t-fast); }
.sortable-item.is-dragging { opacity: .45; box-shadow: var(--shadow-lg); }
.drag-handle { cursor: grab; color: var(--c-muted); touch-action: none; display: inline-flex; }
.drag-handle:active { cursor: grabbing; }

/* --------------------------------------------------------- media grid */
.media-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.media-item {
  position: relative; aspect-ratio: 1;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--c-border); background: var(--c-surface-2);
  cursor: pointer;
}
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .7), transparent 55%);
  opacity: 0; transition: opacity var(--t);
  display: flex; align-items: flex-end; padding: .5rem; gap: .3rem;
}
.media-item:hover .overlay, .media-item:focus-within .overlay { opacity: 1; }

/* --------------------------------------------------------- responsive */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .panel-main { margin-inline-end: 0; }
  .menu-toggle { display: inline-flex; }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    z-index: 150; display: none; backdrop-filter: blur(2px);
  }
  .sidebar-overlay.is-open { display: block; }
}

@media (max-width: 768px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.35rem; }
  .panel-content { padding: 1rem .75rem 4rem; }
  .card-pad, .card-body { padding: 1rem; }
  .card-head { padding: .9rem 1rem; }
  .stat-value { font-size: 1.4rem; }
  .modal { max-width: 100%; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .toast-host { inset-inline: .75rem; max-width: none; bottom: .75rem; }
}

@media (max-width: 480px) {
  .container { padding-inline: .75rem; }
  .btn { padding: .6rem 1rem; }
  .table th, .table td { padding: .65rem .7rem; }
  .stat { padding: .9rem; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
}

/* ------------------------------------------------------------- print */
@media print {
  .sidebar, .topbar, .btn, .toast-host, .no-print { display: none !important; }
  .panel-main { margin: 0; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ddd; box-shadow: none; }
}
