@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700;800&display=swap');


html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    direction: rtl;
    transition: background-color 0.22s ease, color 0.22s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* =========================================================
   تطبيق خط IBM Plex Sans Arabic بشكل شامل على كامل لوحة التحكم والعمود الجانبي
   ========================================================= */
*, *::before, *::after,
body, html,
button, input, select, textarea,
.tm-wrapper, .tm-wrapper *,
.tm-app-layout, .tm-app-layout *,
.tm-sidebar, .tm-sidebar *,
.tm-sidebar button, .tm-sidebar span, .tm-sidebar a, .tm-sidebar div,
.tm-sidebar-header, .tm-sidebar-header *,
.tm-sidebar-nav, .tm-sidebar-nav *,
.tm-nav-group-label,
.tm-tab, .tm-tab *,
.tm-tab-text, .tm-tab-badge,
.tm-sidebar-footer, .tm-sidebar-footer *,
.tm-sidebar-user, .tm-sidebar-user *,
.tm-user-details, .tm-user-role, .tm-user-email,
.tm-sidebar-logout-btn, .tm-sidebar-logout-btn *, .tm-logout-text,
.tm-topbar, .tm-topbar *,
.tm-topbar-right, .tm-topbar-left,
.tm-page-heading, .tm-page-title,
.tm-admin-status-badge, .tm-admin-status-badge *,
.tm-topbar-link, .tm-topbar-link *,



button, input, select, textarea, .tm-wrapper, .tm-sidebar, .tm-sidebar *, .tm-topbar, .tm-topbar *, .tm-tab, .tm-tab * {
    font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* =========================================================
   template-manager | لوحة تحكم المدير — ادركها بريميوم
   Modern Obsidian SaaS Dashboard  ·  RTL  ·  Dark Glass
   ========================================================= */

/* ----- متغيرات التصميم ----- */
/* =========================================================
   نظام الألوان والرموز الدلالية (Warm Dark / Light Theme)
   ========================================================= */

/* 1. الوضع الليلي الدافئ المشتق من الأسود (Warm Obsidian Black) - الافتراضي */
:root,
[data-theme="dark"] {
    color-scheme: dark;
    /* Header & Topbar Tokens (Dark) */
    --header-bg:        #121110;
    --header-border:    rgba(255, 245, 230, 0.08);
    --header-text:      #faf6f0;
    --header-text-muted:#a8a29e;
    --header-btn-bg:    #1b1917;
    --header-btn-border:rgba(255, 245, 230, 0.12);
    --header-btn-hover: rgba(245, 158, 11, 0.14);

    --bg-deep:          #0c0b0a;
    --bg-card:          #141312;
    --bg-card-2:        #1c1b18;
    --bg-surface:       #181715;
    --bg-input:         #211f1c;
    --bg-dropdown:      #1a1916;
    
    --border:           rgba(255, 245, 230, 0.08);
    --border-hover:     rgba(245, 158, 11, 0.4);
    --border-focus:     rgba(245, 158, 11, 0.55);
    
    --accent:           #f59e0b;
    --accent-hover:     #d97706;
    --accent-dim:       rgba(245, 158, 11, 0.12);
    --accent-border:    rgba(245, 158, 11, 0.28);
    --accent-contrast:  #000000;
    
    --text-primary:     #faf6f0;
    --text-muted:       #a8a29e;
    --text-dim:         #78716c;
    
    --green:            #10b981;
    --green-bg:         rgba(16, 185, 129, 0.12);
    --red:              #ef4444;
    --red-bg:           rgba(239, 68, 68, 0.12);
    --blue:             #38bdf8;
    --blue-bg:          rgba(56, 189, 248, 0.12);
    --purple:           #c084fc;
    --purple-bg:        rgba(192, 132, 252, 0.12);
    
    --radius-lg:        14px;
    --radius-md:        10px;
    --radius-sm:        7px;
    --shadow-lg:        0 24px 48px rgba(0,0,0,0.7);
    --shadow-card:      0 4px 20px rgba(0,0,0,0.45);
    --transition:       all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. الوضع النهاري (Warm Alabaster / Clean Light) */
[data-theme="light"] {
    color-scheme: light;
    /* Header & Topbar Tokens (Light) */
    --header-bg:        #ffffff;
    --header-border:    #e7e3da;
    --header-text:      #1c1917;
    --header-text-muted:#57534e;
    --header-btn-bg:    #f5f2eb;
    --header-btn-border:#e2ded5;
    --header-btn-hover: rgba(217, 119, 6, 0.1);

    --bg-deep:          #f7f5f0;
    --bg-card:          #ffffff;
    --bg-card-2:        #f2efe9;
    --bg-surface:       #f5f2ec;
    --bg-input:         #ffffff;
    --bg-dropdown:      #ffffff;
    
    --border:           #e5e1d8;
    --border-hover:     #d4cfc3;
    --border-focus:     rgba(217, 119, 6, 0.5);
    
    --accent:           #d97706;
    --accent-hover:     #b45309;
    --accent-dim:       rgba(217, 119, 6, 0.09);
    --accent-border:    rgba(217, 119, 6, 0.25);
    --accent-contrast:  #ffffff;
    
    --text-primary:     #1c1917;
    --text-muted:       #6b655f;
    --text-dim:         #9c958d;
    
    --green:            #059669;
    --green-bg:         rgba(5, 150, 105, 0.1);
    --red:              #dc2626;
    --red-bg:           rgba(220, 38, 38, 0.1);
    --blue:             #0284c7;
    --blue-bg:          rgba(2, 132, 199, 0.1);
    --purple:           #9333ea;
    --purple-bg:        rgba(147, 51, 234, 0.1);
    
    --shadow-lg:        0 20px 40px rgba(28, 25, 23, 0.08);
    --shadow-card:      0 2px 10px rgba(28, 25, 23, 0.04);
}

/* ----- تهيئة عامة وحاوية الشاشة الكاملة ----- */
.tm-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
.tm-wrapper {
    font-family: inherit;
    direction: rtl;
    background: var(--bg-deep);
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99990 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    color: var(--text-primary);
    display: flex !important;
    flex-direction: row !important;
}

/* =========================================================
   شاشة تسجيل الدخول (Admin Login Guard)
   ========================================================= */
#tm-login-screen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at 50% 25%, #181715 0%, #0c0b0a 100%);
    transition: background 0.22s ease;
}

[data-theme="light"] #tm-login-screen {
    background: radial-gradient(ellipse at 50% 25%, #ffffff 0%, #f7f5f0 100%);
}

.tm-login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 44px 36px;
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.tm-login-brand {
    margin-bottom: 22px;
}
.tm-login-logo {
    max-height: 48px;
    max-width: 200px;
    object-fit: contain;
}

.tm-login-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1px solid rgba(255,152,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.tm-login-card h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tm-login-card p {
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 28px;
}

.tm-google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 13px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}
.tm-google-btn:hover { background: var(--accent-dim); border-color: var(--border-hover); color: var(--accent); }

#tm-login-msg {
    margin-top: 16px;
    font-size: 0.82rem;
    color: var(--red);
    min-height: 20px;
    text-align: center;
}

/* =========================================================
   هيكل لوحة التحكم الكاملة (Dashboard Layout)
   ========================================================= */
#tm-dashboard {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    position: relative;
    background: var(--bg-deep);
}

/* خلفية معتمة للجوال */
.tm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.tm-sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* =========================================================
   العمود الجانبي (Sidebar)
   ========================================================= */
.tm-sidebar {
    width: 260px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 999;
    position: relative;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* رأس العمود: الشعار وزر الطي */
.tm-sidebar-header {
    height: 64px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    transition: padding 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.tm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tm-brand-logo {
    height: 36px;
    max-width: 170px;
    object-fit: contain;
    object-position: right center;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.tm-sidebar-fallback-logo {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    border: 1px solid rgba(255,152,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tm-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.tm-sidebar-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-sidebar-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* زر طي / فتح العمود الجانبي */
.tm-sidebar-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    z-index: 2;
    /* في الوضع المفتوح: مخفي افتراضياً ولا يظهر إلا عند الوقوف على رأس القائمة لمنع تشويش وتداخل الشعار */
    opacity: 0;
    pointer-events: none;
    transform: scale(0.88);
}

.tm-sidebar-header:hover .tm-sidebar-toggle-btn {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.tm-sidebar-toggle-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent-border);
    color: var(--accent);
}

.tm-sidebar-toggle-btn svg {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* قائمة التبويبات بالعمود */
.tm-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tm-nav-group-label {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 10px 6px;
    white-space: nowrap;
    overflow: hidden;
}

.tm-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    text-align: right;
    width: 100%;
    position: relative;
}

.tm-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.tm-tab.active {
    color: var(--accent);
    background: rgba(255,152,0,0.09);
    border-color: rgba(255,152,0,0.22);
    font-weight: 800;
}

.tm-tab-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tm-tab-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 800;
    padding: 0 5px;
    margin-right: auto;
    margin-left: 0;
    flex-shrink: 0;
}

/* أسفل العمود الجانبي */
.tm-sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-card-2);
    flex-shrink: 0;
    transition: background-color 0.22s ease, border-color 0.22s ease;
}

.tm-sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
}

.tm-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.tm-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.tm-user-role {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
}

.tm-user-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: right;
}

.tm-sidebar-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239,68,68,0.25);
    background: rgba(239,68,68,0.08);
    color: #ef4444;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.tm-sidebar-logout-btn:hover {
    background: rgba(239,68,68,0.18);
    border-color: rgba(239,68,68,0.45);
}

/* =========================================================
   الوضع المطوي للعمود الجانبي (Collapsed Mode)
   ========================================================= */
.tm-sidebar.collapsed {
    width: 72px;
}
.tm-sidebar.collapsed .tm-brand-text,
.tm-sidebar.collapsed .tm-nav-group-label,
.tm-sidebar.collapsed .tm-tab-text,
.tm-sidebar.collapsed .tm-tab-badge,
.tm-sidebar.collapsed .tm-user-details,
.tm-sidebar.collapsed .tm-logout-text {
    display: none !important;
}

/* في الوضع المطوي: يظل الشعار ظاهراً في المنتصف بحجم أيقونة أنيق */
.tm-sidebar.collapsed .tm-sidebar-header {
    padding: 0;
    justify-content: center;
}

.tm-sidebar.collapsed .tm-sidebar-brand {
    display: flex !important;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 0;
    cursor: pointer;
}

.tm-sidebar.collapsed .tm-brand-logo {
    max-width: 38px;
    max-height: 34px;
    object-position: center;
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* السهم يختفي تماماً في الوضع المطوي ولا يظهر إلا إذا وقف الماوس على الشعار/رأس العمود */
.tm-sidebar.collapsed .tm-sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.tm-sidebar.collapsed .tm-sidebar-header:hover .tm-brand-logo,
.tm-sidebar.collapsed .tm-sidebar-header:hover .tm-sidebar-fallback-logo {
    opacity: 0;
    transform: scale(0.75);
}

.tm-sidebar.collapsed .tm-sidebar-header:hover .tm-sidebar-toggle-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.tm-sidebar.collapsed .tm-sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.tm-sidebar.collapsed .tm-tab {
    justify-content: center;
    padding: 11px 0;
}
.tm-sidebar.collapsed .tm-sidebar-footer {
    flex-direction: column;
    gap: 8px;
    padding: 10px 4px;
    align-items: center;
}
.tm-sidebar.collapsed .tm-sidebar-logout-btn {
    padding: 6px;
}

/* تلميح Tooltip عند الطي */
.tm-sidebar.collapsed .tm-tab:hover::after {
    content: attr(title);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e1e30;
    color: #f0f0f5;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    pointer-events: none;
    z-index: 1000;
}

/* =========================================================
   المنطقة الرئيسية للمحتوى (Main Content Area)
   ========================================================= */
.tm-main-area {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: var(--bg-deep);
}

/* الشريط العلوي للمحتوى */


.tm-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}




.tm-page-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tm-page-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}



.tm-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: tmPulse 2s infinite;
}

@keyframes tmPulse {
    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); }
}


/* زر التبديل بين النهاري والليلي */


[data-theme="dark"] .tm-theme-moon,
:root:not([data-theme="light"]) .tm-theme-moon {
    display: none;
}
[data-theme="dark"] .tm-theme-sun,
:root:not([data-theme="light"]) .tm-theme-sun {
    display: block;
}
[data-theme="light"] .tm-theme-sun {
    display: none;
}
[data-theme="light"] .tm-theme-moon {
    display: block;
}




/* جسم المحتوى القابل للتمرير المستقل */
.tm-main-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px 60px;
    scroll-behavior: smooth;
}

/* شريط تمرير عصري */
.tm-main-content::-webkit-scrollbar,
.tm-sidebar-nav::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.tm-main-content::-webkit-scrollbar-track,
.tm-sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.tm-main-content::-webkit-scrollbar-thumb,
.tm-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}
.tm-main-content::-webkit-scrollbar-thumb:hover,
.tm-sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 152, 0, 0.35);
}

.tm-tab-content {
    display: none;
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
}
.tm-tab-content.active { display: block; }

/* =========================================================
   تبويب 1: الإحصائيات (KPI Dashboard)
   ========================================================= */
.tm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.tm-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.tm-kpi-card:hover { border-color: rgba(255,152,0,0.2); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.tm-kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--kpi-color, var(--accent));
    opacity: 0.6;
}

.tm-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--kpi-bg, var(--accent-dim));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.tm-kpi-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.tm-kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* قائمة Top 5 */
.tm-top5-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.tm-section-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tm-top5-list { list-style: none; }

.tm-top5-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.tm-top5-item:last-child { border-bottom: none; }

.tm-top5-rank {
    font-size: 0.78rem;
    font-weight: 900;
    color: var(--text-dim);
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.tm-top5-item:nth-child(1) .tm-top5-rank { color: #f59e0b; }
.tm-top5-item:nth-child(2) .tm-top5-rank { color: #9ca3af; }
.tm-top5-item:nth-child(3) .tm-top5-rank { color: #b45309; }

.tm-top5-img {
    width: 52px;
    height: 30px;
    border-radius: 5px;
    object-fit: cover;
    background: var(--bg-input);
    flex-shrink: 0;
}

.tm-top5-info { flex: 1; min-width: 0; }
.tm-top5-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-top5-count {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.tm-top5-bar-wrap {
    width: 100px;
    height: 5px;
    border-radius: 3px;
    background: var(--bg-input);
    flex-shrink: 0;
    overflow: hidden;
}
.tm-top5-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transition: width 0.6s ease;
}

/* =========================================================
   تبويب 2: استوديو النشر (Publishing Studio)
   ========================================================= */
.tm-studio-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

.tm-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.tm-form-section-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.tm-form-section-title:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

/* حقول الإدخال */
.tm-field { margin-bottom: 16px; }
.tm-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 7px;
}
.tm-input {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}
.tm-input::placeholder { color: var(--text-dim); }
.tm-input:focus { border-color: var(--border-focus); background: rgba(245,158,11,0.04); box-shadow: 0 0 0 3px rgba(245,158,11,0.08); }

/* =========================================================
   تنسيق القوائم المنسدلة وعناصر الخيارات (Dropdowns & Select)
   ========================================================= */
select,
select option,
select optgroup,
.tm-input,
.tm-filter-select {
    color-scheme: dark;
}

[data-theme="light"] select,
[data-theme="light"] select option,
[data-theme="light"] select optgroup,
[data-theme="light"] .tm-input,
[data-theme="light"] .tm-filter-select {
    color-scheme: light;
}

select.tm-input,
select.tm-filter-select,
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--bg-dropdown) !important;
    color: var(--text-primary) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: left 12px center !important;
    padding-left: 36px !important;
    padding-right: 14px !important;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

select:focus,
select.tm-input:focus,
select.tm-filter-select:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12) !important;
}

[data-theme="light"] select.tm-input,
[data-theme="light"] select.tm-filter-select,
[data-theme="light"] select {
    background-color: var(--bg-input) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23d97706' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

/* معالجة خلفية وخيارات القوائم المنسدلة لمنع الخلفية الفاتحة في الوضع الداكن */
select option,
.tm-input option,
.tm-filter-select option {
    background-color: var(--bg-dropdown) !important;
    color: var(--text-primary) !important;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 500;
}

[data-theme="dark"] select option,
[data-theme="dark"] .tm-input option,
[data-theme="dark"] .tm-filter-select option {
    background-color: #1a1916 !important;
    color: #faf6f0 !important;
}

[data-theme="light"] select option,
[data-theme="light"] .tm-input option,
[data-theme="light"] .tm-filter-select option {
    background-color: #ffffff !important;
    color: #1c1917 !important;
}

/* منطقة السحب والإفلات */
.tm-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: var(--bg-input);
}
.tm-drop-zone:hover, .tm-drop-zone.dragging {
    border-color: var(--accent);
    background: rgba(255,152,0,0.05);
}
.tm-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.tm-drop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent-dim);
    margin: 0 auto 12px;
}
.tm-drop-zone h4 {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.tm-drop-zone p {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.tm-file-selected {
    margin-top: 12px;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--green);
    font-weight: 700;
}
.tm-file-selected.visible { display: flex; }

/* شريط التقدم */
.tm-progress-wrap {
    margin-top: 14px;
    display: none;
}
.tm-progress-wrap.visible { display: block; }
.tm-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}
.tm-progress-bar-bg {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-input);
    overflow: hidden;
}
.tm-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), #ffd54f);
    width: 0%;
    transition: width 0.25s ease;
}

/* نظام الوسوم */
.tm-tags-wrapper { position: relative; margin-bottom: 16px; }
.tm-tags-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    min-height: 46px;
    cursor: text;
    transition: var(--transition);
}
.tm-tags-box:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(255,152,0,0.08); }
.tm-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255,152,0,0.12);
    border: 1px solid rgba(255,152,0,0.2);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
}
.tm-tag-remove {
    cursor: pointer;
    font-style: normal;
    font-size: 14px;
    line-height: 1;
    color: rgba(255,152,0,0.6);
    transition: var(--transition);
}
.tm-tag-remove:hover { color: var(--red); }
.tm-tag-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    flex-grow: 1;
    min-width: 120px;
    padding: 4px 2px;
}
.tm-tag-input::placeholder { color: var(--text-dim); }

.tm-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    z-index: 50;
    max-height: 160px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: none;
}
.tm-suggestions.visible { display: block; }
.tm-suggestion-item {
    padding: 9px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    color: var(--text-primary);
}
.tm-suggestion-item:hover { background: var(--accent-dim); color: var(--accent); }
.tm-suggestion-item:last-child { border-bottom: none; }

/* أزرار النموذج */
.tm-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.tm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.88rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.tm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tm-btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    box-shadow: 0 4px 14px rgba(255,152,0,0.25);
}
.tm-btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(255,152,0,0.35); }

.tm-btn-secondary {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.tm-btn-secondary:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.tm-btn-danger {
    background: rgba(239,68,68,0.1);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
}
.tm-btn-danger:hover { background: rgba(239,68,68,0.18); }

.tm-btn-green {
    background: rgba(16,185,129,0.1);
    color: var(--green);
    border: 1px solid rgba(16,185,129,0.2);
}
.tm-btn-green:hover { background: rgba(16,185,129,0.18); }

/* رسائل الحالة */
.tm-status {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 700;
    display: none;
}
.tm-status.visible { display: block; }
.tm-status.success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); color: var(--green); }
.tm-status.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: var(--red); }
.tm-status.loading { background: rgba(255,152,0,0.08); border: 1px solid rgba(255,152,0,0.2); color: var(--accent); }

/* بطاقة المعاينة الحية */
.tm-preview-card-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: sticky;
    top: 80px;
}
.tm-preview-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tm-preview-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px rgba(16,185,129,0.5); }

.tm-preview-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card-2);
}
.tm-preview-img-wrap {
    aspect-ratio: 16/9;
    background: var(--bg-input);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tm-preview-img { width: 100%; height: 100%; object-fit: cover; display: none; }
.tm-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    font-size: 0.78rem;
    text-align: center;
}
.tm-preview-body { padding: 14px; }
.tm-preview-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.tm-preview-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.tm-preview-tag {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.tm-preview-btns {
    display: flex;
    gap: 6px;
}
.tm-preview-btn {
    flex: 1;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
    cursor: default;
}
.tm-pb-pptx { background: linear-gradient(135deg, #1d8a54, #15693f); }
.tm-pb-canva { background: linear-gradient(135deg, #7428ef, #4569e0); }
.tm-pb-preview { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* =========================================================
   تبويب 3: جدول القوالب
   ========================================================= */
.tm-table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tm-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
}
.tm-search-wrap input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    width: 100%;
}
.tm-search-wrap input::placeholder { color: var(--text-dim); }

.tm-filter-select {
    padding: 9px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.tm-view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.tm-view-btn {
    padding: 9px 12px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
}
.tm-view-btn.active { background: var(--accent-dim); color: var(--accent); }

/* عرض الجدول */
.tm-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.tm-data-table th {
    text-align: right;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    white-space: nowrap;
}
.tm-data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}
.tm-data-table tr:hover td { background: rgba(255,255,255,0.02); }
.tm-data-table tr:last-child td { border-bottom: none; }

.tm-table-thumb {
    width: 64px;
    height: 38px;
    border-radius: 5px;
    object-fit: cover;
    background: var(--bg-input);
    display: block;
}
.tm-table-title { font-weight: 700; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-table-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tm-table-tag {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.tm-table-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 700;
}
.tm-table-actions { display: flex; gap: 6px; flex-shrink: 0; }
.tm-action-btn {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.tm-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.tm-action-btn.edit:hover { border-color: rgba(59,130,246,0.4); color: var(--blue); background: rgba(59,130,246,0.08); }
.tm-action-btn.del:hover { border-color: rgba(239,68,68,0.4); color: var(--red); background: rgba(239,68,68,0.08); }
.tm-action-btn.copy:hover { border-color: rgba(16,185,129,0.4); color: var(--green); background: rgba(16,185,129,0.08); }

/* عرض الشبكة */
.tm-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.tm-grid-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}
.tm-grid-card:hover { border-color: rgba(255,152,0,0.2); transform: translateY(-3px); box-shadow: var(--shadow-card); }
.tm-grid-img {
    aspect-ratio: 16/9;
    width: 100%;
    object-fit: cover;
    background: var(--bg-input);
    display: block;
}
.tm-grid-body { padding: 12px; }
.tm-grid-title { font-size: 0.85rem; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-grid-meta { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 10px; }
.tm-grid-actions { display: flex; gap: 6px; }

/* حاوية الجدول */
.tm-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}

/* ترقيم الصفحات */
.tm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.tm-page-btn {
    min-width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tm-page-btn:hover { border-color: rgba(255,152,0,0.3); color: var(--accent); }
.tm-page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tm-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* =========================================================
   تبويب 4: المشتركون
   ========================================================= */
.tm-subscribers-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tm-add-user-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 20px;
}
.tm-add-user-form h3 {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tm-add-user-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

/* بطاقات ورابط الواتساب */
.tm-whatsapp-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(37, 211, 102, 0.1);
    color: #25D366;
    border: 1px solid rgba(37, 211, 102, 0.25);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    direction: ltr;
    text-decoration: none;
    transition: all 0.2s ease;
}
.tm-whatsapp-badge:hover {
    background: rgba(37, 211, 102, 0.2);
    border-color: #25D366;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.2);
}
.tm-phone-copy-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 4px;
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.15s ease;
}
.tm-phone-copy-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* جدول المشتركين */
.tm-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}
.tm-status-active { background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.tm-status-suspended { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.tm-status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tm-badge-premium {
    background: rgba(245,158,11,0.15) !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245,158,11,0.3) !important;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tm-badge-single {
    background: rgba(16,185,129,0.15) !important;
    color: #10b981 !important;
    border: 1px solid rgba(16,185,129,0.3) !important;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tm-badge-free {
    background: rgba(99,102,241,0.12) !important;
    color: #818cf8 !important;
    border: 1px solid rgba(99,102,241,0.25) !important;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tm-resend-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(59,130,246,0.25);
    background: rgba(59,130,246,0.08);
    color: var(--blue);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.tm-resend-btn:hover { background: rgba(59,130,246,0.16); }
.tm-resend-btn.loading { opacity: 0.6; cursor: not-allowed; }

.tm-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(16,185,129,0.2);
    background: rgba(16,185,129,0.08);
    color: var(--green);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.tm-export-btn:hover { background: rgba(16,185,129,0.16); }

/* =========================================================
   إشعارات Toast
   ========================================================= */
#tm-toast-container {
    position: fixed;
    top: 80px;
    left: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.tm-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-primary);
    pointer-events: all;
    animation: toastIn 0.3s ease forwards;
    max-width: 320px;
}
.tm-toast.success { border-color: rgba(16,185,129,0.3); }
.tm-toast.error { border-color: rgba(239,68,68,0.3); }
.tm-toast.info { border-color: rgba(255,152,0,0.3); }
.tm-toast.fadeout { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-20px); }
}

/* =========================================================
   مكتبة الملفات (Files Library CSS)
   ========================================================= */
.tm-files-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.tm-files-stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.tm-files-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: rgba(59,130,246,0.1);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tm-files-stat-val {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1.2;
}
.tm-files-stat-lbl {
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 600;
}

.tm-file-upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 24px;
}

.tm-file-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tm-file-badge.pptx {
    background: rgba(234, 88, 12, 0.12);
    color: #ea580c;
    border: 1px solid rgba(234, 88, 12, 0.25);
}
.tm-file-badge.zip {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.25);
}
.tm-file-badge.other {
    background: rgba(100, 116, 139, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.25);
}

.tm-linked-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-primary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tm-linked-badge img {
    width: 26px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.tm-unlinked-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* نافذة التأكيد المنبثقة (Confirm Dialog) */
#tm-confirm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100010;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#tm-confirm-modal.open { display: flex; }
.tm-confirm-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
}
.tm-confirm-icon-wrap {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.tm-confirm-icon-wrap.danger {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}
.tm-confirm-icon-wrap.warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}
.tm-confirm-icon-wrap.success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--green);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}
.tm-confirm-card h3 { font-size: 1.15rem; font-weight: 900; margin-bottom: 10px; color: var(--text-primary); }
.tm-confirm-card p { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }
.tm-confirm-actions { display: flex; gap: 12px; justify-content: center; }
.tm-confirm-actions .tm-btn { min-width: 120px; padding: 10px 20px; font-weight: 700; }

/* بانر استيراد بلوجر في الاستوديو */
.tm-blogger-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(135deg, rgba(255,127,50,0.08) 0%, rgba(255,152,0,0.03) 100%);
    border: 1px solid rgba(255,127,50,0.25);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
}
.tm-blogger-banner-info {
    display: flex;
    align-items: center;
    gap: 14px;
}
.tm-blogger-badge-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255,127,50,0.12);
    border: 1px solid rgba(255,127,50,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tm-blogger-banner-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 3px;
}
.tm-blogger-banner-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.tm-btn-blogger {
    background: linear-gradient(135deg, #ff7f32 0%, #e65100 100%);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 0.84rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255,127,50,0.3);
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.tm-btn-blogger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255,127,50,0.4);
    opacity: 0.95;
}

/* نافذة استيراد بلوجر المنبثقة */
#tm-blogger-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#tm-blogger-modal.open { display: flex; }
.tm-blogger-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 680px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.tm-blogger-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.tm-blogger-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
}
.tm-blogger-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: rgba(255,255,255,0.015);
    border-bottom: 1px solid var(--border);
}
.tm-blogger-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.tm-blogger-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
}
.tm-blogger-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.tm-blogger-item:hover {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,127,50,0.4);
    transform: translateX(-3px);
}
.tm-blogger-item-thumb {
    width: 64px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.tm-blogger-item-info {
    flex: 1;
    min-width: 0;
}
.tm-blogger-item-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.tm-blogger-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
    color: var(--text-muted);
}
.tm-blogger-item-tag {
    background: rgba(255,255,255,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}
.tm-blogger-select-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,127,50,0.12);
    border: 1px solid rgba(255,127,50,0.25);
    color: #ff9800;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    white-space: nowrap;
    transition: var(--transition);
}
.tm-blogger-item:hover .tm-blogger-select-btn {
    background: #ff7f32;
    color: #fff;
    border-color: #ff7f32;
}

/* نافذة التعديل السريع */
#tm-edit-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#tm-edit-modal.open { display: flex; }
.tm-edit-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 560px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}
.tm-edit-card h3 {
    font-size: 1rem;
    font-weight: 900;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* عناصر ملف القالب في نافذة التعديل */
.tm-current-file-box {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 14px;
}
.tm-current-file-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(234, 88, 12, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tm-current-file-info {
    flex: 1;
    min-width: 0;
}
.tm-current-file-name {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: right;
    margin-bottom: 2px;
}
.tm-current-file-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tm-file-link {
    font-size: 0.76rem;
    color: var(--accent);
    text-decoration: underline;
    font-weight: 600;
}
.tm-file-link:hover { color: var(--text-primary); }

.tm-file-replace-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 12px;
}
.tm-replace-tab {
    flex: 1;
    padding: 8px 10px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}
.tm-replace-tab:hover { color: var(--text-primary); }
.tm-replace-tab.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.tm-replace-panel {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 14px;
}
.tm-modal-close {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    transition: var(--transition);
}
.tm-modal-close:hover { color: var(--text-primary); }

/* تكيف الألوان مع الوضع الليلي */
.drK .tm-wrapper {
    background: var(--bg-deep);
}

/* Responsive */
@media (max-width: 1100px) { .tm-kpi-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 860px) {
    .tm-studio-layout { grid-template-columns: 1fr; }
    .tm-preview-card-wrap { position: static; }
    .tm-add-user-grid { grid-template-columns: 1fr; }
    .tm-files-stats-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 992px) {
    .tm-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 270px;
        max-width: 85vw;
        transform: translateX(100%);
        box-shadow: -10px 0 35px rgba(0,0,0,0.75);
    }
    .tm-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    
    .tm-main-content {
        padding: 20px 16px 40px;
    }
}
@media (min-width: 993px) {
    .tm-sidebar.collapsed + .tm-main-area .tm-topbar-toggle-btn {
        display: flex !important;
    }
}
@media (max-width: 640px) {
    .tm-kpi-grid { grid-template-columns: 1fr 1fr; }
    .tm-topbar-link span { display: none; }
    .tm-files-stats-bar { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
    .tm-kpi-grid { grid-template-columns: 1fr; }
}

    
/* =========================================================
   تنسيق الهيدر والشريط العلوي والعمود الجانبي بألوان متناسقة ومضبوطة
   ========================================================= */










.tm-page-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--header-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.22s ease;
}










.tm-tab {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-size: 0.88rem;
    font-weight: 600;
}
.tm-nav-group-label {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.tm-user-role {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-weight: 700;
}
.tm-user-email {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
}


/* =========================================================
   تنسيق الهيدر والشريط العلوي والعمود الجانبي بألوان متناسقة ومضبوطة
   ========================================================= */










.tm-page-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--header-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.22s ease;
}










.tm-tab {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-size: 0.88rem;
    font-weight: 600;
}
.tm-nav-group-label {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.tm-user-role {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-weight: 700;
}
.tm-user-email {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
}


/* =========================================================
   تنسيق الهيدر والشريط العلوي والعمود الجانبي بألوان متناسقة ومضبوطة
   ========================================================= */
.tm-sidebar-header {
    height: 68px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--header-border);
    flex-shrink: 0;
    gap: 8px;
    background: var(--header-bg);
    transition: background-color 0.22s ease, border-color 0.22s ease;
}

.tm-sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--header-btn-border);
    background: var(--header-btn-bg);
    color: var(--header-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.tm-sidebar-toggle-btn:hover {
    color: var(--accent);
    background: var(--header-btn-hover);
    border-color: var(--border-hover);
}

.tm-topbar {
    height: 68px;
    background: var(--header-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--header-border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 50;
    gap: 16px;
    transition: background-color 0.22s ease, border-color 0.22s ease;
}

.tm-topbar-toggle-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--header-btn-border);
    background: var(--header-btn-bg);
    color: var(--header-text-muted);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.tm-topbar-toggle-btn:hover {
    color: var(--accent);
    background: var(--header-btn-hover);
    border-color: var(--border-hover);
}

.tm-page-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--header-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.22s ease;
}

.tm-theme-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--header-btn-border);
    background: var(--header-btn-bg);
    color: var(--header-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.tm-theme-btn:hover {
    color: var(--accent);
    background: var(--header-btn-hover);
    border-color: var(--border-hover);
}

.tm-topbar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--header-btn-bg);
    border: 1px solid var(--header-btn-border);
    color: var(--header-text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-decoration: none;
    transition: var(--transition);
}
.tm-topbar-link:hover {
    color: var(--accent);
    background: var(--header-btn-hover);
    border-color: var(--border-hover);
}

.tm-admin-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--green-bg);
    border: 1px solid rgba(16,185,129,0.25);
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--green);
}


.tm-tab {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-size: 0.88rem;
    font-weight: 600;
}
.tm-nav-group-label {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.tm-user-role {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
    font-weight: 700;
}
.tm-user-email {
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif !important;
}


/* =========================================================
   تنسيقات نموذج الدخول السحابي المزدوج (Email + Google)
   ========================================================= */
.tm-login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 18px;
    text-align: right;
}

.tm-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: right;
}

.tm-login-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

.tm-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tm-input-icon {
    position: absolute;
    right: 14px;
    color: var(--text-dim);
    pointer-events: none;
    z-index: 2;
}

.tm-login-input {
    width: 100%;
    padding: 11px 40px 11px 42px !important;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.tm-login-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.tm-pwd-toggle-btn {
    position: absolute;
    left: 12px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 2;
}

.tm-pwd-toggle-btn:hover {
    color: var(--accent);
}

.tm-login-submit-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.92rem;
    font-weight: 700;
    margin-top: 4px;
}

.tm-login-divider {
    display: flex;
    align-items: center;
    margin: 18px 0;
    color: var(--text-dim);
    font-size: 0.76rem;
    font-weight: 700;
}

.tm-login-divider::before,
.tm-login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.tm-login-divider span {
    padding: 0 14px;
}

.tm-login-msg {
    margin-top: 14px;
    min-height: 20px;
    text-align: center;
}

/* =========================================================
   تنسيقات لوحة الأرباح والمبيعات ومنحنى المبيعات (Spline Chart)
   ========================================================= */
.tm-financial-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.tm-kpi-sub {
    font-size: 0.73rem;
    color: var(--text-dim);
    line-height: 1.3;
}

.tm-sales-chart-card {
    transition: var(--transition);
}

.tm-chart-period-tabs {
    display: inline-flex;
    background: var(--bg-input);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.tm-period-btn {
    padding: 5px 12px;
    font-size: 0.78rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 600;
}

.tm-period-btn:hover {
    color: var(--text-primary);
}

.tm-period-btn.active {
    background: var(--bg-card);
    color: #10b981;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.tm-sar-icon {
    display: inline-block;
    vertical-align: -0.14em;
    width: 0.88em;
    height: 0.88em;
    fill: currentColor;
    margin-right: 3px;
    margin-left: 2px;
    flex-shrink: 0;
}

.tm-spend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.78rem;
}

.tm-spend-badge.has-spend {
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.tm-spend-badge.is-free {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

@media (max-width: 1100px) {
    .tm-financial-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .tm-financial-kpi-grid {
        grid-template-columns: 1fr;
    }
    .tm-chart-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
}

/* =========================================================
   مكون زر المزامنة الذكي وخيارات ترشيد القراءات
   ========================================================= */
.tm-sync-split-btn-wrap {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.tm-sync-dropdown-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    text-align: right;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
    font-size: 0.8rem;
}

.tm-sync-dropdown-item:hover {
    background: var(--bg-subtle, rgba(255, 255, 255, 0.05));
}

.tm-sync-dropdown-item.tm-sync-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* =========================================================
   تنسيقات شريط فترات وإحصائيات شارت المبيعات
   ========================================================= */
.tm-period-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.18s ease;
}

.tm-period-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tm-period-btn.active {
    background: var(--bg-card);
    color: #10b981;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tm-chart-period-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.8rem;
}

.tm-chart-stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tm-chart-stat-label {
    color: var(--text-muted);
}

.tm-chart-stat-value {
    font-weight: 700;
}