:root {
    --brand: #60a5fa; --brand-2: #a78bfa;
    --brand-grad: linear-gradient(135deg, #60a5fa, #a78bfa);
    --green: #4ade80; --red: #f87171; --amber: #fbbf24;
    --cyan: #22d3ee; --purple: #a78bfa;
    --bg: #05070d; --surface-1: #0e1220; --surface-2: #111827;
    --surface-3: #1e293b; --border: #1b2335; --border-2: #263352;
    --text: #f2f5fa; --muted: #94a3b8;
    --radius: 14px; --radius-sm: 10px;
    --shadow: 0 4px 20px rgba(0,0,0,0.35);
    --sidebar-w: 260px; --header-h: 68px;
}
body.light-mode {
    --bg: #f4f6fb; --surface-1: #ffffff; --surface-2: #ffffff;
    --surface-3: #f1f5f9; --border: #e5e9f0; --border-2: #d1d8e3;
    --text: #0f172a; --muted: #64748b;
    --shadow: 0 4px 20px rgba(15,23,42,0.08);
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    transition: background 0.25s, color 0.25s; min-height: 100vh;
}
.titan-sidebar {
    position: fixed; top: 0; right: 0; width: var(--sidebar-w); height: 100vh;
    background: var(--surface-2); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 100;
    transform: translateX(0); transition: transform 0.3s ease;
}
.titan-sidebar.collapsed { transform: translateX(100%); }
.sidebar-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px; border-bottom: 1px solid var(--border);
    min-height: var(--header-h);
}
.sidebar-header .logo-icon { font-size: 1.6rem; }
.sidebar-header .logo-title {
    font-weight: 900; font-size: 1.05rem;
    background: var(--brand-grad); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-header .logo-sub { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.sidebar-close {
    margin-right: auto; background: transparent; border: none;
    color: var(--muted); font-size: 1.5rem; cursor: pointer; display: none;
}
.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 14px 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.nav-section-label {
    color: var(--muted); font-size: 0.72rem; font-weight: 600;
    padding: 14px 12px 6px; letter-spacing: 0.5px; text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px;
    border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
    font-size: 0.92rem; transition: background 0.15s, transform 0.15s;
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-3); transform: translateX(-3px); }
.nav-item.active {
    background: linear-gradient(90deg, rgba(96,165,250,0.15), transparent);
    border-color: rgba(96,165,250,0.3); color: var(--brand); font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
    padding: 12px; border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
}
.user-mini-card {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: var(--surface-3); border-radius: var(--radius-sm); margin-bottom: 6px;
}
.user-mini-card .avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--brand-grad);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}
.user-mini-card .info { min-width: 0; flex: 1; }
.user-mini-card .email {
    font-size: 0.82rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-mini-card .code { font-size: 0.7rem; color: var(--muted); font-family: monospace; }
.titan-main { margin-right: var(--sidebar-w); min-height: 100vh; transition: margin 0.3s ease; }
.titan-main.expanded { margin-right: 0; }
.titan-topbar {
    height: var(--header-h); background: rgba(14,18,32,0.85);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
body.light-mode .titan-topbar { background: rgba(255,255,255,0.85); }
.topbar-menu-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    cursor: pointer; display: none; align-items: center; justify-content: center;
}
.topbar-title { font-weight: 700; font-size: 1.1rem; }
.topbar-actions { margin-right: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    cursor: pointer; display: inline-flex; align-items: center;
    justify-content: center; transition: all 0.15s; position: relative;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-2); }
.page-content { padding: 24px; max-width: 1600px; margin: 0 auto; }
.card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-subtitle { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; transition: transform 0.2s, border-color 0.2s;
}
.kpi-card:hover { transform: translateY(-3px); border-color: var(--border-2); }
.kpi-label { color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }
.kpi-value { font-size: 1.5rem; font-weight: 900; line-height: 1.2; font-feature-settings: 'tnum'; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; margin-top: 8px; font-weight: 600; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-3); flex-shrink: 0; font-size: 1.3rem;
}
.kpi-icon.blue   { background: rgba(96,165,250,0.15); color: var(--brand); }
.kpi-icon.green  { background: rgba(74,222,128,0.15); color: var(--green); }
.kpi-icon.red    { background: rgba(248,113,113,0.15); color: var(--red); }
.kpi-icon.amber  { background: rgba(251,191,36,0.15); color: var(--amber); }
.kpi-icon.purple { background: rgba(167,139,250,0.15); color: var(--brand-2); }
.kpi-icon.cyan   { background: rgba(34,211,238,0.15); color: var(--cyan); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-sm); font-size: 0.88rem;
    font-weight: 600; border: 1px solid transparent; cursor: pointer;
    text-decoration: none; transition: all 0.18s; font-family: inherit; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px rgba(96,165,250,0.3); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-success { background: rgba(74,222,128,0.12); color: var(--green); border-color: rgba(74,222,128,0.3); }
.btn-danger { background: rgba(248,113,113,0.12); color: var(--red); border-color: rgba(248,113,113,0.3); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.table-wrap { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.titan-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.titan-table thead { background: var(--surface-3); position: sticky; top: 0; z-index: 2; }
table.titan-table th {
    text-align: right; padding: 13px 16px; font-weight: 700;
    color: var(--muted); font-size: 0.78rem; text-transform: uppercase;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.titan-table td {
    padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.titan-table tbody tr { transition: background 0.15s; }
table.titan-table tbody tr:hover { background: var(--surface-3); }
table.titan-table tbody tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.table-empty .empty-icon { font-size: 3rem; opacity: 0.4; margin-bottom: 12px; }
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 0.72rem;
    font-weight: 700; line-height: 1.6;
}
.badge-green  { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-red    { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-amber  { background: rgba(251,191,36,0.15); color: var(--amber); }
.badge-blue   { background: rgba(96,165,250,0.15); color: var(--brand); }
.badge-gray   { background: var(--surface-3); color: var(--muted); }
.badge-purple { background: rgba(167,139,250,0.15); color: var(--brand-2); }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius-sm); padding: 10px 14px;
    font-size: 0.9rem; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}
.form-textarea { min-height: 100px; resize: vertical; }
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); max-width: 600px; width: 100%;
    max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
    transform: scale(0.95); transition: transform 0.2s;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header {
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-close {
    background: transparent; border: none; color: var(--muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 16px 22px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}
.toast-container {
    position: fixed; bottom: 20px; left: 20px; z-index: 2000;
    display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
    background: var(--surface-2); border: 1px solid var(--border);
    border-right: 4px solid var(--brand); border-radius: var(--radius-sm);
    padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4); animation: slideIn 0.25s ease;
    font-size: 0.88rem;
}
.toast.success { border-right-color: var(--green); }
.toast.error   { border-right-color: var(--red); }
.toast.warning { border-right-color: var(--amber); }
.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 700; margin-bottom: 2px; }
.toast-msg { color: var(--muted); font-size: 0.82rem; }
@keyframes slideIn {
    from { transform: translateX(-30px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.text-brand { color: var(--brand); }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-feature-settings: 'tnum'; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
@media (max-width: 1024px) {
    .titan-sidebar { transform: translateX(100%); }
    .titan-sidebar.open { transform: translateX(0); }
    .titan-main { margin-right: 0; }
    .topbar-menu-btn { display: inline-flex; }
    .sidebar-close { display: block; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .page-content { padding: 14px; }
    .titan-topbar { padding: 0 14px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.2rem; }
    .modal { max-width: 100%; margin: 0 8px; }
    table.titan-table th, table.titan-table td { padding: 10px 12px; font-size: 0.82rem; }
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ==========================================
   🚀 S97: Final Sidebar Fix (Fixing Overflow)
   ========================================== */
/* حل مشکل اسکرول افقی که باعث بیرون زدن منو می‌شد */
body { 
    overflow-x: hidden !important; 
    width: 100%;
}

.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    .titan-sidebar {
        z-index: 9999 !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease !important;
    }
    .titan-sidebar.open {
        transform: translateX(0) !important;
    }
    body.sidebar-open {
        overflow: hidden !important;
    }
    /* کاهش عرض کادر جستجو در موبایل برای جلوگیری از بیرون زدگی */
    .titan-search-form { margin-left: 5px !important; }
    .titan-search-form input { width: 80px !important; }
}
