/* --- Artistic Minimal Design System (Refined) --- */
:root {
    /* Primary Palette */
    --primary: #183453;       /* Deep Navy */
    --primary-hover: #2A4568; 
    --primary-light: #E8EEF5; 
    
    /* Secendary Palette */    
    --secendary: #adadad;
    
    /* Text Colors */
    --text-main: #1B2559;     
    --text-secondary: #8F9BBA; 
    --text-muted: #A3AED0;
    
    /* Backgrounds */
    --bg-body: #ededed;       
    --bg-card: #FFFFFF;       
    
    /* Status Colors */
    --success: #05CD99;
    --warning: #FFB547;
    --danger: #E31A1A;
    
    /* Dimensions & Shape */
    --sidebar-width: 70px;
    --radius-card: 20px;
    --radius-sm: 12px;
    
    /* Shadows */
    --shadow-sm: 0px 2px 10px rgba(112, 144, 176, 0.08);
    --shadow-md: 0px 10px 30px rgba(112, 144, 176, 0.10);
}

/* --- Reset & Base Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    font-family: 'Vazirmatn', sans-serif;
}

html {
    direction: rtl !important; /* Ensures scrollbar is on the left */
    overflow-x: hidden;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 0.75rem;
    line-height: 1.5;
    direction: rtl;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: all 0.2s ease; }
ul { list-style: none; }

/* --- Layout System --- */
.app-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* 1. Sidebar (Icon Only & No Scrollbar) */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 100;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.sidebar-header {
    margin-bottom: 1.3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}
.sidebar-logo {
    width: 35px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(24, 52, 83, 0.1));
    transition: transform 0.3s ease;
}

/* Navigation Container */
.sidebar-nav {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    overflow-y: auto;
    overflow-x: visible;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.nav-item i { transition: transform 0.2s; }

.nav-item:hover {
    color: var(--primary);
    background: var(--primary-light);
    transform: translateX(-2px);
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(24, 52, 83, 0.3);
}

/* Sidebar Separator */
.nav-separator {
    width: 30px;
    height: 2px;
    background-color: var(--primary);
    opacity: 0.1;
    margin: 6px 0;
    border-radius: 2px;
    flex-shrink: 0;
}

/* 2. Main Content */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s ease;
}

.top-header {
    padding: 1rem 2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left { display: flex; flex-direction: column; }
.breadcrumb { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--primary); }

.header-right { display: flex; align-items: center; gap: 15px; }


@media (max-width: 768px) {
     .breadcrumb {
         display: none;
     }
     .header-right {
        position: fixed;
        top: 1.2rem;
        left: 2rem;
     }
     .page-title {
         margin-top: 1.2rem;
     }
}





/* Profile Dropdown */
.profile-dropdown {
    position: relative;
}

.profile-pill {
    background: var(--bg-card);
    padding: 4px 4px 4px 12px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.profile-pill:hover {
    background: #fff;
    box-shadow: var(--shadow-md);
}

.dropdown-menu {
    position: absolute;
    top: 120%;
    left: 0;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow-md);
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.profile-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-main);
    transition: background 0.2s;
    text-decoration: none;
}

.dropdown-item:hover {
    background: var(--bg-body);
}

.dropdown-item.text-danger {
    color: var(--danger);
}
.dropdown-item.text-danger:hover {
    background: #FFF5F5;
}

.avatar {
    width: 30px;
    height: 30px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.user-name { font-size: 12px; font-weight: 600; color: var(--primary); }

.content-wrapper { padding: 1.5rem 2rem 3rem; }

/* --- Components --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

/* RESPONSIVE REPORT GRIDS (Refined) */
.report-grid-3-1, .report-grid-1-3,.report-grid-2-1, .report-grid-1-2,.report-grid-1-1 { display: grid; gap: 25px; margin-bottom: 25px; }
.report-grid-1-1 { grid-template-columns: 1fr 1fr; }
.report-grid-3-1 { grid-template-columns: 3fr 1.2fr; }
.report-grid-2-1 { grid-template-columns: 2fr 1.2fr; }
.report-grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-1-3 { grid-template-columns: 1fr 3fr; }

.card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: transform 0.2s;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.kpi-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; margin-bottom: 5px; }
.kpi-value { font-size: 20px; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; line-height: 1.2; }
.kpi-unit { font-size: 11px; font-weight: 500; color: var(--text-muted); margin-right: 2px; }

.progress-mini { margin-top: auto; padding-top: 10px; }
.progress-bar-bg { height: 4px; width: 100%; background: var(--primary-light); border-radius: 10px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 10px; }
.progress-text { font-size: 10px; color: var(--text-secondary); margin-top: 5px; display: flex; justify-content: space-between; }

.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--primary); margin: 0; }
.section-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Compact Toolbar for Projects */
.header-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-compact {
    width: 220px;
    flex-shrink: 0;
}

.filters-wrapper {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.filters-wrapper::-webkit-scrollbar { display: none; }

/* Bulk Actions Toolbar (New) */
.bulk-toolbar {
    display: none; 
    align-items: center; 
    justify-content: space-between;
    margin-bottom: 15px; 
    background: var(--bg-body); 
    padding: 8px 15px; 
    border-radius: 12px; 
    border: 1px solid var(--primary-light);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.table-responsive { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: right; font-size: 11px; color: var(--text-muted); font-weight: 600; padding: 10px 15px; border-bottom: 1px solid var(--primary-light); }
tbody td { padding: 12px 15px; font-size: 12px; color: var(--text-main); font-weight: 600; border-bottom: 1px solid #f0f0f0; }
tbody tr:last-child td { border-bottom: none; }

.pill-success { background: #E6FFFA; color: #05CD99; }
.pill-danger { background: #FFF5F5; color: var(--danger); }
.pill-warning { background: #FFF7E6; color: var(--warning); }
.pill-neutral { background: var(--bg-body); color: var(--text-secondary); }

.btn-mini { padding: 4px 10px; font-size: 10px; border-radius: 6px; border: 1px solid var(--primary-light); background: transparent; color: var(--text-secondary); transition: all 0.2s; }
.btn-mini:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-body); }

.mobile-toggle { display: none; font-size: 1.2rem; color: var(--primary); background: none; border: none; padding: 5px; }
.mobile-close { 
    display: none; 
    background: none; 
    border: none; 
    font-size: 1.2rem; 
    color: var(--text-muted);
    margin-bottom: 20px;
    cursor: pointer;
}

/* --- Forms & Inputs --- */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 15px; border-radius: 12px; border: 1px solid transparent;
    background: var(--bg-body); color: var(--text-main); font-size: 11px; font-weight: 500; transition: all 0.2s ease;
}
.form-control:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24, 52, 83, 0.1); }
.form-control[readonly], .form-control[disabled] { color: var(--text-secondary); cursor: default; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* --- Buttons --- */
.btn-primary {
    background: var(--primary); color: #fff; padding: 10px 24px; border-radius: 12px; font-size: 13px;
    font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(24, 52, 83, 0.2); }
.btn-icon { padding: 10px 12px; font-size: 16px; justify-content: center; }

.btn-secondary {
    background: var(--secendary); color: var(--text-main); padding: 10px 24px; border-radius: 12px;
    font-size: 13px; font-weight: 600; border: 1px solid var(--primary-light); cursor: pointer; transition: all 0.2s; text-decoration: none; white-space: nowrap;
}
.btn-secondary:hover { color: var(--primary); border-color: var(--primary); background: var(--bg-body); }

.btn-danger {
    background: #f3bebefa; color: var(--danger); padding: 10px 24px; border-radius: 12px;
    font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-danger:hover { background: var(--danger); color: #f3bebefa;}

/* --- Pagination --- */
.pagination-container { display: flex; justify-content: center; gap: 10px; margin-top: 25px; }
.pagination-btn {
    background: #fff; border: 1px solid var(--primary-light); color: var(--text-secondary);
    width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.pagination-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; background: var(--bg-body); }
.pagination-info { display: flex; align-items: center; font-size: 12px; color: var(--text-secondary); }

/* --- Multi-select --- */
.multiselect-container {
    background: var(--bg-body); border-radius: 12px; padding: 5px 10px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
    min-height: 42px; position: relative; transition: all 0.2s ease;
}
.multiselect-container:focus-within { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24, 52, 83, 0.1); }
.tag { background: var(--primary); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px; }
.tag-remove { background: none; border: none; color: #fff; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }
input#modal-category-input {border:none; background: var(--bg-body);}
#category-input, .multiselect-input { background: transparent; border: none; font-size: 13px; flex-grow: 1; min-width: 120px; color: var(--text-main); outline: none; }
.suggestions-dropdown {
    position: absolute; top: 105%; left: 0; right: 0; background: #fff; border-radius: 8px;
    box-shadow: var(--shadow-md); z-index: 50; max-height: 200px; overflow-y: auto; display: none;
}
.suggestion-item { padding: 8px 15px; cursor: pointer; font-size: 12px; transition: background 0.1s; }
.suggestion-item:hover { background: var(--bg-body); color: var(--primary); }

/* --- Media Queries (Mobile Optimization) --- */
@media (max-width: 992px) {
    :root { --sidebar-width: 0px; }
    .sidebar { width: 70px; transform: translateX(100%); box-shadow: -5px 0 15px rgba(0,0,0,0.05); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-right: 0; width: 100%; }
    .mobile-toggle { display: block; }
    .mobile-close { display: block; }
    .header-toolbar { flex-direction: column; align-items: flex-start; }
    .search-compact { width: 100%; }
    .filters-wrapper { width: 100%; overflow-x: auto; }
    
    /* FORCE SINGLE COLUMN STACK ON MOBILE/TABLET */
    .report-grid-1-1, 
    .report-grid-3-1, 
    .report-grid-1-3, 
    .report-grid-2-1, 
    .report-grid-1-2, 
    .grid-container {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    /* Ensure Performance Metrics stack nicely */
    #performanceMetrics {
        grid-template-columns: 1fr 1fr !important; /* Keep 2 small cards per row */
    }
    
@media (max-width: 600px) {
    #performanceMetrics {
        grid-template-columns: 1fr !important; /* تبدیل به 1 ستون در موبایل */
        gap: 12px;
    }
    
@media (max-width: 992px) {
    /* بازنشانی ترتیب فیلترها در داخل کارت‌ها */
    .card .toolbar-filters {
        order: 0 !important;
        margin-bottom: 20px; /* فاصله مناسب از نمودار پایین */
        width: 100%;
    }
}

    /* تنظیم فاصله و اندازه فونت برای خوانایی بهتر در موبایل */
    .stat-card-item {
        padding: 12px;
    }
    
    .stat-card-value {
        font-size: 14px;
    }
}
    
    
    /* Stage Columns stack */
    .stage-container {
        grid-template-columns: 1fr !important;
        overflow-x: visible;
    }
    .stage-column {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    /* Card adjustments */
    .card { padding: 15px; }
    .section-header { margin-bottom: 15px; }
    .section-title { font-size: 14px; }
    
    /* Funnel Row Mobile */
    .funnel-row {
        flex-direction: column;
        align-items: stretch !important;
        gap: 5px !important;
    }
    .funnel-label {
        width: 100% !important;
        text-align: right !important;
        font-size: 12px !important;
        margin-bottom: 2px;
    }
    
}

/* --- Companies Toolbar Specifics --- */
.companies-toolbar {
    display: flex;
    gap: 15px;
    width: 100%;
    align-items: center;
    flex-wrap: nowrap; /* Enforce single row on desktop */
}

.companies-toolbar .search-input {
    flex-grow: 1;
    background: var(--bg-body);
    height: 42px; /* Fixed Height */
    padding-top: 10px;
    padding-bottom: 10px;
}

.companies-actions-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0; /* Don't shrink the buttons area */
}

.companies-filter {
    width: 160px;
    flex-shrink: 0;
    height: 42px !important; /* Fixed Height */
    padding-top: 0;
    padding-bottom: 0;
    line-height: 40px; /* Vertical Center */
}

.companies-toolbar .btn-primary {
    height: 42px; /* Fixed Height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Tweaks for Companies Page */
@media (max-width: 768px) {
    .companies-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .companies-actions-group {
        display: flex;
        width: 100%;
        gap: 10px;
    }
    
    .companies-filter {
        flex-grow: 1;
        width: auto !important;
    }
    
    /* Show "New Company" text on mobile for better usability */
    .mobile-only-text {
        display: inline-block !important;
    }
    
    /* Reduce table text size slightly */
    tbody td {
        font-size: 11px;
        padding: 10px 8px;
    }
}

/* --- Persons Toolbar Specifics --- */
.persons-toolbar {
    display: flex;
    gap: 15px;
    width: 100%;
    align-items: center;
}

.persons-toolbar .search-input {
    flex-grow: 1;
    background: var(--bg-body);
    height: 42px; /* Fixed Height */
    padding-top: 10px;
    padding-bottom: 10px;
}

.persons-actions-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.persons-filter {
    width: 200px;
    flex-shrink: 0;
    height: 42px !important; /* Fixed Height */
    padding-top: 0;
    padding-bottom: 0;
    line-height: 40px; /* Vertical Center */
}

.persons-toolbar .btn-primary {
    height: 42px; /* Fixed Height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Tweaks for Persons Page */
@media (max-width: 768px) {
    .persons-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .persons-actions-group {
        display: flex;
        flex-direction: row; /* Explicitly row */
        width: 100%;
        gap: 10px;
    }
    
    .persons-filter {
        flex-grow: 1;
        width: auto !important;
    }
}

/* --- Projects Toolbar Specifics --- */
.projects-toolbar {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
    flex-wrap: nowrap;
}

.projects-toolbar .search-input {
    flex-grow: 1;
    min-width: 200px;
    background: var(--bg-body);
    height: 42px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.projects-filters-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.projects-filter {
    height: 42px !important;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 40px;
}

.projects-actions-group {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.projects-actions-group .btn-icon {
    height: 42px;
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Tweaks for Projects Page */
@media (max-width: 768px) {
    .projects-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .projects-filters-group {
        width: 100%;
        overflow-x: auto; /* Scroll horizontally */
        padding-bottom: 5px; /* Space for scrollbar */
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
        justify-content: flex-start;
    }
    
    .projects-filters-group::-webkit-scrollbar {
        display: none;
    }

    .projects-filter {
        flex-shrink: 0; /* Don't squish filters */
        width: auto !important;
        min-width: 120px;
    }

    .projects-actions-group {
        justify-content: flex-end;
        width: 100%;
        gap: 10px;
    }
    
    /* Make 'New Project' button wider with text on mobile */
    .projects-actions-group .mobile-expanded-btn {
        width: auto;
        padding: 0 20px;
    }
    
    /* Ensure mobile text is visible */
    .mobile-only-text {
        display: inline-block !important;
    }
}

/* --- Actions Toolbar Specifics --- */
.actions-toolbar {
    display: flex;
    gap: 15px;
    width: 100%;
    align-items: center;
}

.actions-toolbar .search-input {
    flex-grow: 1;
    background: var(--bg-body);
    height: 42px; /* Fixed Height */
    padding-top: 10px;
    padding-bottom: 10px;
}

.actions-actions-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.actions-filter {
    width: 180px;
    flex-shrink: 0;
    height: 42px !important; /* Fixed Height */
    padding-top: 0;
    padding-bottom: 0;
    line-height: 40px; /* Vertical Center */
}

.actions-toolbar .btn-primary {
    height: 42px; /* Fixed Height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Tweaks for Actions Page */
@media (max-width: 768px) {
    .actions-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .actions-actions-group {
        display: flex;
        width: 100%;
        gap: 10px;
    }
    
    .actions-filter {
        flex-grow: 1;
        width: auto !important;
    }
}

/* --- Sales Toolbar Specifics --- */
.sales-toolbar {
    display: flex;
    gap: 15px;
    width: 100%;
    align-items: center;
}

.sales-toolbar .search-input {
    flex-grow: 1;
    background: var(--bg-body);
    height: 42px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.sales-actions-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.sales-toolbar .btn-primary {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .sales-toolbar {
        flex-direction: row; /* Keep search and button on one row */
        align-items: center;
        gap: 10px;
    }
    
    .sales-actions-group {
        width: auto;
        flex-shrink: 0;
    }
    
    .sales-actions-group .btn-primary {
        width: auto; /* Don't stretch button */
    }
    
    .sales-toolbar .search-input {
        width: 100%; /* Ensure search takes available space */
    }
}

/* --- Accordion Styles (Responsive) --- */
.accordion { border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-sm); }
.accordion-item { border-bottom: 1px solid var(--bg-body); background: #fff; }
.accordion-item:last-child { border-bottom: none; }
.accordion-button {
    width: 100%; padding: 15px 20px; text-align: right; background: #fff; border: none;
    font-size: 12px; font-weight: 600; color: var(--text-main); display: flex; justify-content: space-between;
    align-items: center; cursor: pointer; transition: background 0.2s;
}
.accordion-button:hover { background: var(--bg-body); }
.accordion-button::after { content: '\f107'; font-family: "Font Awesome 7 Free"; font-weight: 900; transition: transform 0.3s; color: var(--text-secondary); margin-right: 10px;}
.accordion-button:not(.collapsed)::after { transform: rotate(180deg); color: var(--primary); }
.accordion-collapse { display: none; }
.accordion-collapse.show { display: block; }
.accordion-body { padding: 20px; background: var(--bg-body); }

.accordion-header-content {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    flex-wrap: wrap;
}

.accordion-invoice { min-width: 100px; color: var(--primary); font-weight: 700; }
.accordion-date { min-width: 120px; font-size: 12px; color: var(--text-secondary); }
.accordion-company { flex-grow: 1; font-weight: 600; }
.accordion-count { flex-shrink: 0; }

@media (max-width: 768px) {
    .accordion-header-content {
        gap: 5px;
    }
    .accordion-invoice { width: 100%; order: 1; }
    .accordion-date { width: 100%; order: 2; margin-bottom: 5px; }
    .accordion-company { width: 100%; order: 3; }
    .accordion-count { order: 4; margin-top: 5px; }
}

/* Responsive Table Helper */
.responsive-table-wrapper {
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-sm); 
    border-radius: 12px; 
    overflow: hidden;
}
@media (max-width: 768px) {
    .responsive-table-wrapper {
        max-width: 100%;
    }
}

/* --- Detail Page --- */
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.info-bar { background: #fff; padding: 0; border-radius: 0; box-shadow: none; }

.stage-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; overflow-x: auto; padding-bottom: 10px; }
.stage-column { border-radius: 16px; padding: 15px; box-shadow: var(--shadow-sm); min-width: 220px; border: 1px solid #00000021;}
.stage-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
    padding-bottom: 8px; border-bottom: 1px solid var(--primary-light); color: var(--primary); font-weight: 700; font-size: 12px;
}
.stage-badge { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.stage-items { display: flex; flex-direction: column; gap: 8px; }
.stage-item {
    background: var(--bg-body); border-radius: 10px; padding: 10px; font-size: 12px; color: var(--text-main);
    font-weight: 500; transition: transform 0.2s; border: 1px solid transparent;
}
.stage-item:hover { transform: translateY(-2px); border-color: var(--primary-light); background: #fff; box-shadow: var(--shadow-sm); }
.essence-tag { display: block; }

/* --- RESTORED REPORTS STYLES --- */

/* Skeleton Loader */
.skeleton-wrapper { display: flex; flex-direction: column; gap: 15px; width: 100%; padding: 10px 0; }
.skeleton-row { display: flex; gap: 15px; width: 100%; }
.skeleton-box { flex: 1; height: 80px; background: #f0f0f0; border-radius: 12px; animation: shimmer 1.5s infinite linear; background: linear-gradient(to right, #f0f0f0 4%, #e0e0e0 25%, #f0f0f0 36%); background-size: 1000px 100%; }
@keyframes shimmer { 0% { background-position: -1000px 0; } 100% { background-position: 1000px 0; } }
.hidden { display: none !important; }

/* Stat Cards (Performance Analysis) */
.stat-card { background: var(--bg-body); padding: 15px; border-radius: 12px; display: flex; align-items: center; gap: 15px; transition: transform 0.2s; border: 1px solid transparent; }
.stat-card:hover { transform: translateY(-2px); background: #fff; box-shadow: var(--shadow-sm); border-color: var(--primary-light); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: var(--shadow-sm); flex-shrink: 0; }

/* Lead Source Progress Bars */
.lead-source-item { margin-bottom: 15px; }
.lead-source-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 12px; }
.lead-source-name { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-main); }
.lead-source-values { display: flex; align-items: center; gap: 10px; }
.lead-source-percent { font-weight: 700; color: var(--primary); }

/* Modal System (Fixed Scroll & Inputs) */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(24, 52, 83, 0.4); backdrop-filter: blur(4px); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-box {
    background: #fff; width: 95%; max-width: 1000px; max-height: 90vh;
    border-radius: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    transform: scale(0.95); transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-overlay.active .modal-box { transform: scale(1); }

.modal-header {
    padding: 20px 30px; border-bottom: 1px solid var(--bg-body);
    display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.modal-title { font-size: 18px; font-weight: 800; color: var(--primary); }
.modal-close {
    background: var(--bg-body); border: none; width: 32px; height: 32px; border-radius: 10px;
    color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body {
    padding: 30px; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--primary) transparent;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background-color: var(--primary); border-radius: 20px; }

/* Login Page Styles */
.login-body {
    background-color: var(--bg-body);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Decorative background elements */
.login-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.6;
}
.blob-1 { width: 400px; height: 400px; background: #E8EEF5; top: -100px; right: -100px; }
.blob-2 { width: 300px; height: 300px; background: #E6FFFA; bottom: -50px; left: -50px; }

.login-card {
    display: flex;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: 100%;
    max-width: 1000px;
    min-height: 600px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(24, 52, 83, 0.08);
    border: 1px solid #fff;
    overflow: hidden;
    z-index: 1;
    position: relative;
}

/* Form Section */
.login-form-section {
    flex: 1;
    padding: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand {
    margin-bottom: 40px;
}
.login-logo {
    height: 50px;
    width: auto;
    margin-bottom: 15px;
}
.login-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
}
.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.login-input-group {
    margin-bottom: 20px;
    position: relative;
}
.login-input-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}
.login-input {
    width: 100%;
    padding: 14px 45px 14px 15px; /* Extra padding right for icon */
    border-radius: 14px;
    border: 1px solid var(--primary-light);
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}
.login-input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(24, 52, 83, 0.05);
}

.login-btn {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(24, 52, 83, 0.15);
}
.login-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(24, 52, 83, 0.25);
}

/* Image Section */
.login-image-section {
    flex: 1.2;
    background: var(--primary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
    mix-blend-mode: overlay;
    position: absolute;
}

.login-quote {
    position: relative;
    z-index: 2;
    color: #fff;
    text-align: center;
    padding: 40px;
    max-width: 400px;
}
.login-quote h2 { font-size: 28px; font-weight: 800; margin-bottom: 15px; }
.login-quote p { font-size: 14px; opacity: 0.8; line-height: 1.8; }

@media (max-width: 900px) {
    .login-card { flex-direction: column; max-width: 450px; min-height: auto; }
    .login-image-section { display: none; }
    .login-form-section { padding: 40px; }
}

/* --- Artistic Donut Chart Styles (Restored/Updated) --- */
.donut-chart-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    padding: 10px;
}

.chart-visual {
    position: relative;
    width: 240px; /* Restored larger size */
    height: 240px;
    max-width: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
}

.donut-segment {
    transition: all 0.2s ease;
    cursor: pointer;
}
.donut-segment:hover {
    transform: scale(1.02);
    transform-origin: center;
    filter: brightness(1.1);
}

.donut-label {
    font-size: 9px;
    font-weight: 700;
    fill: #fff;
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 120px; /* Increased */
    height: 120px;
}

.total-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.total-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.chart-legend {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 0;
}

/* Updated Legend Item to look like 'Pills' */
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-main);
    background: #fff; /* Distinct background */
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--primary-light);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: all 0.2s;
}
.legend-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.05);
    border-color: var(--primary);
}

.legend-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin: 0;
    box-shadow: none;
}
.legend-label {
    font-weight: 600;
}

/* ============================================
   CSS اضافی برای base.html - این را به انتهای style.css اضافه کنید
   ============================================ */

/* Force scrollbar to left side */
html { 
    direction: rtl; 
}

/* Header Avatar Styles */
.header-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar {
    width: 30px;
    height: 30px;
    background-color: var(--primary, #183453);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
}

/* Dropdown Icon */
.dropdown-icon {
    font-size: 10px;
    margin-right: 5px;
    color: var(--text-secondary);
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 20px;
}

.flash-message {
    font-size: 12px;
    padding: 8px 15px;
    margin-bottom: 5px;
    display: block;
    border-radius: 6px;
}

.flash-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.flash-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

/* ============================================
   CSS اضافی برای dashboard.html 
   این را به انتهای style.css اضافه کنید
   ============================================ */

/* KPI Header Layout */
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Card Icon Variants */
.card-icon-primary {
    background: #F4F7FE;
    color: var(--primary);
}

.card-icon-warning {
    background: #FFF7E6;
    color: var(--warning);
}

.card-icon-success {
    background: #E6FFFA;
    color: var(--success);
}

/* Text Color Utilities */
.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

/* Filter Group */
.filter-group {
    display: flex;
    gap: 8px;
}

/* Table Cell Styles */
.td-type {
    color: var(--primary);
    font-weight: 700;
}

.td-description {
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Empty Table Message */
.empty-table-message {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* =======================================================
   بخش اختصاصی صفحه جزئیات شرکت (Company Detail Page)
   ======================================================= */

/* --- 1. سیستم گرید فرم‌ها (Form Grids) --- */
.grid-form-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 15px; }
.grid-form-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 15px; margin-bottom: 15px; }
.grid-form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; }

/* --- 2. ویجت خلاصه عملکرد (Summary Stats) --- */
.summary-stats { display: flex; flex-direction: column; gap: 12px; }
.stat-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--primary-light); }
.stat-item:last-child { border-bottom: none; }
.stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-value { font-size: 14px; font-weight: 700; }

/* --- 3. ویجت اشخاص (Persons Widget) --- */
.persons-widget-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.person-widget-item { padding: 10px; background: var(--bg-body); border-radius: 10px; border: 1px solid transparent; transition: all 0.2s; }
.person-widget-item:hover { border-color: var(--primary-light); background: #fff; box-shadow: var(--shadow-sm); }

/* چیدمان نام و سمت در یک خط */
.person-widget-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}
.person-widget-name { font-weight: 700; font-size: 12px; color: var(--text-main); }
.person-role-inline { font-size: 11px; color: var(--text-secondary); font-weight: 400; }
.person-widget-contact { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-muted); }
.person-widget-contact i { width: 15px; text-align: center; }

/* --- 4. بخش پروژه‌ها (Projects Column View) --- */
/* نکته: کلاس stage-items اصلی را تغییر نمیدهیم تا صفحه گزارشات خراب نشود */

.stage-items-scrollable {
    max-height: 260px; /* ارتفاع دقیق برای نمایش حدود 4 آیتم */
    overflow-y: auto;
    padding-left: 4px; /* فضا برای اسکرول بار */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* استایل خاص ستون‌های پروژه در این صفحه */
.project-column { min-width: 240px; margin-bottom: 10px; }
.project-column.rejected { opacity: 0.75; }
.project-column-header-rejected { border-bottom-color: var(--danger) !important; }
.project-column-header-rejected span:first-child { color: var(--danger); }
.project-badge-rejected { background: #FFF5F5; color: var(--danger); }

/* --- 5. جدول اقدامات (Actions Table) --- */
/* کلاسی برای چسباندن محتوای کارت به بالا */
.card-align-top {
    display: flex;
    flex-direction: column;
    justify-content: flex-start !important;
    height: 100%; 
}

/* اسکرول جدول اقدامات */
.actions-scroll-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

.actions-table-compact { width: 100%; border-collapse: collapse; }
.actions-table-compact th {
    font-size: 11px; color: var(--text-secondary); padding: 12px 10px; text-align: right;
    background-color: #fff; /* برای استیکی بودن باید رنگ داشته باشد */
    border-bottom: 1px solid var(--primary-light);
    position: sticky; top: 0; z-index: 5;
}
.actions-table-compact td { padding: 12px 10px; font-size: 12px; border-bottom: 1px solid #f0f0f0; color: var(--text-main); vertical-align: middle; }
.actions-table-compact tr:last-child td { border-bottom: none; }

/* --- 6. جدول فروش (Sales History) --- */
.sales-scroll-wrapper {
    max-height: 550px; /* نمایش حدود 10 ردیف */
    overflow-y: auto;
    border-radius: 0 0 12px 12px;
}

#projects-history { max-height: calc(10 * 50px); overflow-y: auto; }

.sales-table { width: 100%; border-collapse: separate; border-spacing: 0; }
/* هدر استیکی برای جدول فروش */
.sales-table thead th { 
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-body); 
    padding: 15px; font-size: 12px; font-weight: 700; color: var(--text-secondary); text-align: right; 
    border-bottom: 2px solid var(--primary-light);
    box-shadow: 0 2px 2px -2px rgba(0,0,0,0.1);
}

.table-container .table-responsive#sales-history { max-height: calc(15 * 50px); overflow-y: auto; }

/* Sales Accordion */
.sales-main-row { cursor: pointer; transition: background 0.2s; background: #fff; }
.sales-main-row:hover { background: var(--bg-body); }
.sales-main-row td { padding: 15px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.sales-main-row.open { background: var(--primary-light); }
.toggle-icon { transition: transform 0.2s; }

/* جزئیات آکاردئونی فروش */
.sales-detail-row { display: none; }
.sales-detail-row.open { display: table-row; animation: fadeIn 0.3s ease; }
.sales-detail-wrapper { background: #f8f9fa; padding: 20px; }
.detail-table-inner { width: 100%; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid var(--primary-light); }
.detail-table-inner th { background: var(--primary); color: #fff !important; padding: 10px; font-size: 11px; font-weight: 500; }
.detail-table-inner td { padding: 10px; font-size: 12px; border-bottom: 1px solid #eee; color: var(--text-main); }

/* سلول‌های خاص */
.invoice-cell { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary); }
.date-cell { color: var(--text-secondary); font-size: 12px; }
.amount-cell { font-weight: 700; color: var(--text-main); }
.status-badge-sales { padding: 4px 10px; border-radius: 6px; font-size: 11px; background: #fff; border: 1px solid var(--primary-light); }
.col-toggle { width: 50px; text-align: center; color: var(--text-muted); }

/* --- 7. استایل اسکرول‌بارها (زیباسازی) --- */
.persons-widget-list::-webkit-scrollbar,
.stage-items-scrollable::-webkit-scrollbar,
.actions-scroll-wrapper::-webkit-scrollbar,
.sales-scroll-wrapper::-webkit-scrollbar,
#projects-history .stage-container::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar { width: 5px; height: 5px; }


.persons-widget-list::-webkit-scrollbar-track,
.stage-items-scrollable::-webkit-scrollbar-track,
.actions-scroll-wrapper::-webkit-scrollbar-track,
.sales-scroll-wrapper::-webkit-scrollbar-track,
#projects-history .stage-container::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track { background: transparent; }

.persons-widget-list::-webkit-scrollbar-thumb,
.stage-items-scrollable::-webkit-scrollbar-thumb,
.actions-scroll-wrapper::-webkit-scrollbar-thumb,
.sales-scroll-wrapper::-webkit-scrollbar-thumb,
#projects-history .stage-container::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px;}

.persons-widget-list:hover::-webkit-scrollbar-thumb,
.stage-items-scrollable:hover::-webkit-scrollbar-thumb,
.actions-scroll-wrapper:hover::-webkit-scrollbar-thumb,
.sales-scroll-wrapper:hover::-webkit-scrollbar-thumb,
#projects-history .stage-container:hover::-webkit-scrollbar-thumb,
.table-responsive:hover::-webkit-scrollbar-thumb { background: #cbd5e1;}


/* =======================================================
   تنظیمات ریسپانسیو (Mobile)
   ======================================================= */
@media (max-width: 992px) {
    /* تک ستونه شدن تمام لایه‌بندی‌ها */
    .report-grid-3-1, .report-grid-1-1, 
    .grid-form-4, .grid-form-3, .grid-form-2 { 
        grid-template-columns: 1fr !important; 
        gap: 15px; 
    }

    /* جلوگیری از اسکرول افقی کل صفحه */
    .card { width: 100%; overflow: hidden; }

    /* تبدیل جدول فروش به کارت */
    .sales-table thead { display: none; }
    .sales-main-row { 
        display: flex; flex-direction: column; padding: 15px; gap: 10px; 
        border: 1px solid var(--primary-light); margin-bottom: 10px; border-radius: 12px; 
    }
    .sales-main-row td { 
        border: none; padding: 0; display: flex; justify-content: space-between; align-items: center; width: 100%; 
    }
    
    /* نمایش لیبل‌ها در موبایل */
    .sales-main-row td:nth-child(2)::before { content: "فاکتور:"; font-size: 11px; color: var(--text-muted); }
    .sales-main-row td:nth-child(3)::before { content: "تاریخ:"; font-size: 11px; color: var(--text-muted); }
    .sales-main-row td:nth-child(4)::before { content: "تعداد:"; font-size: 11px; color: var(--text-muted); }
    .sales-main-row td:nth-child(5)::before { content: "مبلغ:"; font-size: 11px; color: var(--text-muted); }
    
    .invoice-cell { font-size: 14px; margin-bottom: 0; }
    .col-toggle { display: none; } /* مخفی کردن آیکون فلش در حالت موبایل اگر فضا کم است */
    
    /* اسکرول جداول داخلی */
    .sales-detail-wrapper { overflow-x: auto; }
    .detail-table-inner { min-width: 500px; }
}

@media (max-width: 768px) {
    /* مخفی کردن هدر */
    .table-container table thead {
        display: none;
    }
    
    /* تبدیل ردیف به کارت */
    .sales-main-row {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        padding: 12px 15px;
        gap: 8px;
        border-bottom: 1px solid #f0f0f0;
        justify-content: center;
        text-align: center;
    }
    
    .sales-main-row td {
        display: none;
        padding: 0 !important;
        border: none !important;
    }
    
    /* فقط نمایش: chevron، فاکتور، تاریخ، مبلغ */
    .sales-main-row td:nth-child(1) { display: block; order: 1; }  /* chevron */
    .sales-main-row td:nth-child(2) { display: block; order: 2; font-weight: 700; }  /* فاکتور */
    .sales-main-row td:nth-child(3) { display: block; order: 3; color: var(--text-muted); font-size: 11px; }  /* تاریخ */
    .sales-main-row td:nth-child(5) { display: block; order: 4; margin-right: 0; font-weight: 700; color: var(--primary); }  /* مبلغ */
    
    /* مخفی: اقلام، نظرسنجی، چاپ */
    /* td:nth-child(4), td:nth-child(6), td:nth-child(7) مخفی می‌مانند */
}


/* ============================================================
   PAGE SPECIFIC STYLES
   (Migrated from internal HTML styles)
   ============================================================ */

/* --- OKR Dashboard --- */
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1400px) { .grid-cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 992px) { .grid-cols-3 { grid-template-columns: 1fr; } }

.objective-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.objective-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.mini-chart {
    width: 4rem;
    height: 4rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: conic-gradient(var(--success) var(--percent), #edf2f7 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mini-chart::after {
    content: attr(data-percent) "%";
    position: absolute;
    background: var(--bg-card);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 10px;
    color: var(--text-main);
}

.kr-item {
    background: var(--bg-body);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
    margin-bottom: 10px;
}
.kr-item:hover { border-color: var(--primary-light); }
.kr-item:last-child { margin-bottom: 0; }

.progress-track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}
.progress-fill.main { background: var(--primary); }
.progress-fill.owner { background: var(--success); }

.assign-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px dashed var(--border-light);
    margin-top: 5px;
}
.assign-item:first-child { border-top: none; margin-top: 10px; }

.kr-badge { font-size: 9px; padding: 3px 8px; border-radius: 6px; font-weight: 700; }
.kr-badge.success { background: var(--bg-success-light); color: var(--success); }
.kr-badge.danger { background: var(--bg-danger-light); color: var(--danger); }
.kr-badge.primary { background: var(--primary-light); color: var(--primary); }

.assign-badge { font-size: 8px; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.assign-badge.success { background: var(--bg-success-light); color: var(--success); }
.assign-badge.danger { background: var(--bg-danger-light); color: var(--danger); }
.assign-badge.primary { background: var(--bg-body); color: var(--text-secondary); }

.grid-loading { opacity: 0.5; pointer-events: none; }

/* --- Surveys & Star Ratings --- */
.stars-display { 
    color: var(--text-muted); 
    font-size: 12px; 
    direction: ltr; 
    display: inline-flex; 
    gap: 2px; 
}
.star-filled { color: var(--warning); }
.star-empty { color: var(--primary-light); }

.stars-rating { 
    display: inline-flex; 
    gap: 3px; 
    font-size: 16px; 
    direction: ltr; 
    cursor: pointer; 
}
.stars-rating .star { 
    color: var(--primary-light); 
    transition: all 0.2s; 
}
.stars-rating .star:hover { transform: scale(1.2); }
.stars-rating .star.filled, .stars-rating .star.active { color: var(--warning); }

.service-rating-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 5px 0; 
}

.product-rating-card-modal { 
    border: 1px solid var(--primary-light); 
    border-radius: 12px; 
    padding: 15px; 
}
.product-header-modal { 
    font-weight: 700; 
    color: var(--primary); 
    margin-bottom: 10px; 
    font-size: 13px; 
}
.product-ratings-list { display: flex; flex-direction: column; gap: 5px; }

.products-grid, .services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .products-grid, .services-grid { grid-template-columns: 1fr; }
}

/* Accordion Specifics */
.accordion-toggle { cursor: pointer; transition: background-color 0.2s; }
.accordion-toggle:hover { background-color: var(--primary-light); }
.accordion-toggle.active { background-color: var(--primary-light); }
.accordion-icon { color: var(--text-secondary); transition: transform 0.3s; display: inline-block; }
.accordion-toggle.active .accordion-icon { transform: rotate(180deg); color: var(--primary); }

/* --- Documents & General Form Elements --- */
/* Custom Checkbox */
input[type="checkbox"].project-checkbox,
input[type="checkbox"].custom-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}

.selected-row {
    background-color: var(--bg-body) !important;
}

/* Empty State Helper */
.empty-state-dashed {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
    background: var(--bg-body);
    border-radius: 12px;
    border: 1px dashed var(--border-default);
}
.objective-header {
    padding-bottom: 15px;
}

.toolbar-container.mb-0 {
    margin-bottom: 0 !important;
}

/* ============================================================
   PAGE SPECIFIC STYLES
   (Migrated from internal HTML styles)
   ============================================================ */
.stars-display { color: var(--text-muted); font-size: 12px; direction: ltr; display: inline-flex; gap: 2px; }
.star-filled { color: var(--warning); }
.star-empty { color: var(--primary-light); }

.accordion-toggle { cursor: pointer; transition: background-color 0.2s; }
.accordion-toggle:hover { background-color: var(--primary-light); }
.accordion-toggle.active { background-color: var(--primary-light); }

.accordion-icon { color: var(--text-secondary); transition: transform 0.3s; display: inline-block; }
.accordion-toggle.active .accordion-icon { transform: rotate(180deg); color: var(--primary); }

/* Modal Specifics */
.service-rating-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.stars-rating { display: inline-flex; gap: 3px; font-size: 16px; direction: ltr; cursor: pointer; }
.stars-rating .star { color: var(--primary-light); transition: all 0.2s; }
.stars-rating .star:hover { transform: scale(1.2); }
.stars-rating .star.filled, .stars-rating .star.active { color: var(--warning); }

.product-header-modal { font-weight: 700; color: var(--primary); margin-bottom: 10px; font-size: 13px; }
.product-ratings-list { display: flex; flex-direction: column; gap: 5px; }
    /* Grid for Product Cards */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
    /* Grid for Service Card */
.services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
.service-card, .product-card {
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--primary-light);
    padding: 15px;
    border-radius: 12px;
}

/* Mobile */
@media (max-width: 768px) {
    .products-grid, .services-grid { grid-template-columns: 1fr; }
}

/* Suggestions Dropdown (Fixed Position) */
.suggestions-dropdown { 
    display: none; 
    position: fixed;
    background-color: var(--bg-card); 
    border: 1px solid var(--border-default); 
    border-radius: 0 0 12px 12px; 
    box-shadow: var(--shadow-lg);
    z-index: 999999; 
    max-height: 200px; 
    overflow-y: auto;
    text-align: right;
    direction: rtl;
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    transition: background-color 0.15s ease;
}

.suggestion-item:hover { background-color: var(--bg-body); color: var(--primary); }
.suggestion-item:last-child { border-bottom: none; }
    
.modal-box { max-height: 90vh; display: flex; flex-direction: column; }
.modal-body { overflow-y: auto; flex: 1; }
.max-w-900 { max-width: 900px; }


/* ============================================================
   PAGE SPECIFIC STYLES
   (Migrated from internal HTML styles)
   ============================================================ */
.document-empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
    background: var(--bg-body);
    border-radius: 12px;
    border: 1px dashed var(--border-default);
}

i.fa-regular.fa-file-lines.fa-3x.text-primary-light.mb-md.block { display: inline-table; padding-bottom: 10px; }

/* Checkbox Styling override */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}
    
.selected-row {
    background-color: var(--bg-body) !important;
}

.card-action-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--bg-body);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.action-buttons.flex.gap-xs {
    display: flex;
    gap: 8px;
}

.card-header-row.flex-between.items-start.mb-md.pb-md {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--primary-light);
    padding-bottom: 15px;
}

/* ============================================================
   PAGE SPECIFIC STYLES
   (Migrated from internal HTML styles) - OKR - MANAGE
   ============================================================ */

.col-span-2 { grid-column: span 2; }

.manage-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.2s;
}
.manage-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-sm); }

.kr-input-card {
    background: #fff;
    border: 1px dashed var(--border-default);
    border-radius: 12px;
    padding: 15px;
}

/* ============================================================
   PAGE SPECIFIC STYLES
   (Migrated from internal HTML styles) - Survey-details
   ============================================================ */
.stars-rating { display: inline-flex; gap: 5px; font-size: 18px; direction: ltr; color: var(--border-default); }
.stars-rating .star { transition: all 0.2s; color: #e2e8f0; } /* Default gray */
.stars-rating .star.filled { color: var(--warning); } /* Yellow */
.stars-rating.editable { cursor: pointer; }
.stars-rating.editable .star:hover { transform: scale(1.2); }
.stars-rating.editable .star.active { color: var(--warning); }

/* ============================================================
   PROFILE PAGE STYLES
   Add this section to the end of style.css
   ============================================================ */

/* --- Profile Page Layout --- */
.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 992px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }
}

/* --- Profile Avatar Section --- */
.avatar-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border: 4px solid var(--primary-light);
    transition: all 0.3s ease;
}

.avatar-wrapper:hover {
    border-color: var(--primary);
}

.profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 48px;
    font-weight: 700;
}

.avatar-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    color: white;
    text-align: center;
    padding: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.avatar-wrapper:hover .avatar-overlay {
    opacity: 1;
}

/* --- Profile Info --- */
.profile-name {
    color: var(--primary);
    font-size: var(--font-2xl);
    font-weight: 800;
}

.profile-username {
    color: var(--text-secondary);
    font-size: var(--font-base);
}

.profile-last-login {
    border-top: 1px solid var(--primary-light);
    padding-top: var(--space-lg);
    text-align: right;
    font-size: var(--font-base);
    color: var(--text-secondary);
}

/* --- Profile Section Header --- */
.profile-section-header {
    border-bottom: 1px solid var(--bg-body);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-lg);
}

/* --- Toggle Switch Component --- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* Dark mode adjustments */
[data-theme="dark"] .toggle-slider {
    background-color: var(--border-default);
}

[data-theme="dark"] .toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

/* --- Preference Item --- */
.preference-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm);
    background: var(--bg-body);
    border-radius: 8px;
}

.preference-info {
    flex: 1;
    min-width: 0;
}

.preference-title {
    font-weight: 600;
    font-size: var(--font-md);
    color: var(--text-main);
}

.preference-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

/* --- Gamification Badge Styles --- */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(4, 55px);
    justify-content: center;
    gap: 10px;
    direction: rtl;
    width: 100%;
    margin-bottom: var(--space-xl);
    padding: 1rem;
}

.badge-box {
    background-color: #111827;
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
    cursor: pointer;
}

.badge-box img {
    width: 35px;
    height: 35px;
    opacity: 0.15;
    filter: brightness(1) invert(0);
}

/* Light mode badge adjustments */
[data-theme="light"] .badge-box {
    background-color: var(--bg-body);
}

/* Dark mode badge adjustments */
[data-theme="dark"] .badge-box img {
    opacity: 0.15;
    filter: brightness(0) invert(1);
}


/* ============================================================
   NEXT BEST ACTIONS — Dashboard
   Uses CRM design-system tokens; no page-level inline CSS.
   ============================================================ */
.nba-section {
    overflow: hidden;
}

.nba-header {
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.nba-title-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    border-radius: 9px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
}

.nba-list {
    display: flex;
    flex-direction: column;
}

.nba-item {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) 24px;
    gap: var(--space-md);
    align-items: center;
    padding: 16px var(--space-lg);
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
    transition: background-color .18s ease, padding-right .18s ease;
}

.nba-item:last-child {
    border-bottom: 0;
}

.nba-item:hover {
    background: var(--bg-body);
    padding-right: 24px;
}

.nba-priority-col {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
}

.nba-priority-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex: 0 0 7px;
}

.nba-priority-label {
    font-size: var(--font-xs);
    font-weight: 700;
}

.nba-item[data-priority="High"] .nba-priority-dot { background: var(--danger); }
.nba-item[data-priority="High"] .nba-priority-label { color: var(--danger); }
.nba-item[data-priority="Medium"] .nba-priority-dot { background: var(--warning); }
.nba-item[data-priority="Medium"] .nba-priority-label { color: var(--warning); }
.nba-item[data-priority="Low"] .nba-priority-dot { background: var(--text-muted); }

.nba-content {
    min-width: 0;
}

.nba-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: var(--font-xs);
}

.nba-meta-separator {
    color: var(--text-muted);
}

.nba-recommendation {
    color: var(--text-main);
    font-size: var(--font-md);
    font-weight: 700;
    line-height: 1.7;
}

.nba-reason {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    line-height: 1.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nba-arrow {
    color: var(--text-muted);
    font-size: 10px;
    transition: transform .18s ease, color .18s ease;
}

.nba-item:hover .nba-arrow {
    color: var(--primary);
    transform: translateX(-3px);
}

.nba-empty {
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.nba-empty-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-success-light);
    color: var(--success);
    font-size: 16px;
}

@media (max-width: 768px) {
    .nba-item {
        grid-template-columns: 62px minmax(0, 1fr) 18px;
        gap: var(--space-sm);
        padding: 14px var(--space-md);
    }
    .nba-item:hover { padding-right: 18px; }
    .nba-recommendation { font-size: var(--font-base); }
    .nba-reason { white-space: normal; }
}
