:root {
  --bg: #f7f7f8; --surface: #ffffff; --surface-2: #fbfbfc; --text: #16161a; --muted: #6b6b76;
  --accent: #7c5cff; --accent-ink: #ffffff; --border: #e7e7ec;
  --success: #1f9d55; --danger: #d64545; --warning: #b8860b;
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0e0e12; --surface: #17171d; --surface-2: #1d1d24; --text: #f2f2f5; --muted: #97979f;
  --accent: #9b82ff; --accent-ink: #0e0e12; --border: #2a2a33;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
body[dir="rtl"], html[lang="fa"], [data-locale="fa"] {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif !important;
}
body[dir="rtl"] input, body[dir="rtl"] select, body[dir="rtl"] textarea, body[dir="rtl"] button,
html[lang="fa"] input, html[lang="fa"] select, html[lang="fa"] textarea, html[lang="fa"] button {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif !important;
}

.app-shell { display: flex; min-height: 100vh; position: relative; }
.sidebar .brand { font-weight: 700; font-size: 16px; padding: 0 10px 18px; }
.sidebar a {
  display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none;
  color: var(--muted); font-size: 14px;
}
.sidebar a.active, .sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar .spacer { flex: 1; }

.main { flex: 1; padding: 28px 3% 80px; width: 90%; max-width: 95%; min-width: 0; box-sizing: border-box; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar h1 { font-size: 20px; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .sidebar { display:none; } }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 10px; padding: 9px 15px; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit;
}
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.active, .badge.done, .badge.sold, .badge.paid { background: rgba(31,157,85,.15); color: var(--success); }
.badge.pending, .badge.queued, .badge.new { background: rgba(184,134,11,.15); color: var(--warning); }
.badge.failed, .badge.lost, .badge.disabled, .badge.void { background: rgba(214,69,69,.15); color: var(--danger); }

.muted { color: var(--muted); }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; font-size: 15px;
}
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }

/* --- Beautiful Popup Modal & Toast System --- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000005; opacity: 0; pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.active {
  opacity: 1; pointer-events: auto;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px 28px; width: 92%; max-width: 440px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.22), 0 0 1px 1px rgba(255,255,255,0.05);
  transform: scale(0.92) translateY(12px);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.modal-overlay.active .modal-box {
  transform: scale(1) translateY(0);
}
.modal-icon {
  width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 26px; margin-bottom: 16px;
}
.modal-icon.success { background: rgba(31,157,85,0.12); color: var(--success); }
.modal-icon.danger { background: rgba(214,69,69,0.12); color: var(--danger); }
.modal-icon.info { background: rgba(124,92,255,0.12); color: var(--accent); }
.modal-icon.warning { background: rgba(184,134,11,0.12); color: var(--warning); }
.modal-title { font-size: 19px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.modal-message { font-size: 14.5px; color: var(--muted); line-height: 1.5; margin-bottom: 22px; word-break: break-word; }
.modal-actions { display: flex; gap: 10px; width: 100%; justify-content: center; }
.modal-actions .btn { flex: 1; justify-content: center; padding: 10px 18px; font-weight: 600; }

/* Floating Toasts */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 10000010;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
body[dir="rtl"] .toast-container { right: auto; left: 24px; }
.app-toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 18px; font-size: 14px; display: flex;
  align-items: center; gap: 10px; box-shadow: 0 10px 25px rgba(0,0,0,0.12);
  pointer-events: auto; animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 260px; max-width: 380px;
}
.app-toast.success { border-inline-start: 4px solid var(--success); }
.app-toast.danger { border-inline-start: 4px solid var(--danger); }
.app-toast.info { border-inline-start: 4px solid var(--accent); }
@keyframes toastSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}



/* =========================================================================
 * PROFESSIONAL LUXURY ADMIN THEME ENHANCEMENTS (Item 5)
 * ========================================================================= */
/* =========================================================================
 * TINY BEAUTIFUL LUXURY SCROLLBAR (Item 1)
 * ========================================================================= */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(197, 160, 89, 0.35) transparent;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.35);
    border-radius: 999px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(197, 160, 89, 0.75);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.3);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(197, 160, 89, 0.75);
}

.luxury-scrollbar::-webkit-scrollbar {
    width: 4px;
}

.luxury-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.35);
    border-radius: 4px;
}

.luxury-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(197, 160, 89, 0.75);
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    padding: 18px 12px 24px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    z-index: 90;
    scrollbar-width: thin;
    scrollbar-color: rgba(197, 160, 89, 0.35) transparent;
}
.sidebar-brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.sidebar-brand-crest {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #C5A059, #9A7B38);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(197,160,89,0.3);
    flex-shrink: 0;
}
.sidebar-brand-meta h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--text);
    line-height: 1.2;
}
.sidebar-brand-meta span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    display: block;
}
.sidebar-section-title {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 10px 4px;
    margin-top: 6px;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.18s ease;
    margin-bottom: 2px;
    position: relative;
}
.sidebar a:hover {
    background: var(--surface-2);
    color: var(--text);
    transform: translateX(2px);
}
.sidebar a.active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
    font-weight: 700;
}
.sidebar a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--accent);
}

/* Professional Topbar & Top Line Menu */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.03);
    flex-wrap: wrap;
    gap: 12px;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.topbar-title {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.01em;
    color: var(--text);
}
.topbar-store-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e6f4ea;
    color: #137333;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #ceead6;
}
.status-beacon {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: beacon-pulse 2s infinite;
}
@keyframes beacon-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.topbar-store-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.topbar-store-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.topbar-credit-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.15s ease;
}
.topbar-credit-pill:hover {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.topbar-bell-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-decoration: none;
    transition: all 0.15s ease;
}
.topbar-bell-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}
.topbar-bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
}
.topbar-user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.topbar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.topbar-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.topbar-user-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-user-role {
    font-size: 10px;
    color: var(--muted);
    text-transform: capitalize;
}
