/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --cs-blue: #1d4ed8;
    --cs-blue-dark: #1e40af;
    --cs-blue-deep: #1e3a8a;
    --cs-sky: #0369a1;
    --cs-green: #059669;
    --cs-green-dark: #047857;
    --cs-green-soft: #10b981;
    --cs-ink: #0f172a;
    --cs-muted: #475569;
    --cs-surface: rgba(255, 255, 255, 0.92);
    --cs-bg-1: #e0f2fe;
    --cs-bg-2: #ecfdf5;
    --cs-bg-3: #dbeafe;
    --cs-danger: #b91c1c;
    --cs-danger-dark: #991b1b;
    --cs-radius: 18px;
    --cs-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(16, 185, 129, 0.28), transparent 55%),
        radial-gradient(900px 500px at -10% 110%, rgba(29, 78, 216, 0.22), transparent 50%),
        linear-gradient(160deg, var(--cs-bg-1) 0%, var(--cs-bg-2) 45%, var(--cs-bg-3) 100%);
    background-attachment: fixed;
    color: var(--cs-ink);
    line-height: 1.6;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(800px 400px at 80% 0%, rgba(16, 185, 129, 0.2), transparent 60%),
        linear-gradient(160deg, #f0f9ff, #ecfdf5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(3, 105, 161, 0.15);
    border-top: 4px solid var(--cs-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Page Layout */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-item {
    background: linear-gradient(145deg, var(--cs-blue) 0%, var(--cs-sky) 100%);
    border-radius: var(--cs-radius);
    padding: 30px 20px;
    text-align: center;
    color: white;
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 12px 30px rgba(29, 78, 216, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.dashboard-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 40px rgba(5, 150, 105, 0.28);
    border-color: rgba(255, 255, 255, 0.45);
    background: linear-gradient(145deg, var(--cs-green) 0%, var(--cs-blue) 100%);
}

.dashboard-item-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.dashboard-item-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.dashboard-item-desc {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

/* Special styling for different sections */
.dashboard-item.users {
    background: linear-gradient(145deg, #1d4ed8 0%, #0369a1 100%);
}

.dashboard-item.marketing {
    background: linear-gradient(145deg, #059669 0%, #047857 100%);
}

.dashboard-item.performance {
    background: linear-gradient(145deg, #0ea5e9 0%, #0284c7 100%);
    color: #fff;
}

.dashboard-item.payment {
    background: linear-gradient(145deg, #10b981 0%, #0f766e 100%);
}

.dashboard-item.complaint {
    background: linear-gradient(145deg, #2563eb 0%, #1e40af 100%);
}

.dashboard-item.insurance {
    background: linear-gradient(145deg, #0891b2 0%, #0e7490 100%);
}

.dashboard-item.message {
    background: linear-gradient(145deg, #34d399 0%, #059669 100%);
}

.dashboard-item.faq {
    background: linear-gradient(145deg, #64748b 0%, #475569 100%);
}

.dashboard-item.balance {
    background: linear-gradient(145deg, #1d4ed8 0%, #059669 100%);
}

.dashboard-item.representativeRequest {
    background: linear-gradient(145deg, #0284c7 0%, #059669 100%);
}

/* Login Page */
#loginPage {
    justify-content: center;
    align-items: center;
    padding: 32px 16px;
}

.login-container {
    width: min(420px, 100%);
    margin: 0 auto;
    padding: 44px 36px 36px;
    background: var(--cs-surface);
    border-radius: 28px;
    box-shadow: var(--cs-shadow);
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(14px);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header .brand-mark {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.7rem;
    background: linear-gradient(145deg, var(--cs-blue) 0%, var(--cs-green) 100%);
    box-shadow: 0 14px 30px rgba(29, 78, 216, 0.35);
}

.login-header h1 {
    color: var(--cs-ink);
    margin-bottom: 8px;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.login-header p {
    color: var(--cs-muted);
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
}

.portal-settings-panels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.portal-settings-card {
    padding: 20px 24px;
}

.portal-settings-card h3 {
    margin: 0 0 8px;
    color: #1e293b;
}

.portal-kavenegar-hint code {
    font-size: 0.85em;
}

.automation-settings-form .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.automation-settings-form .form-group {
    flex: 1 1 220px;
    min-width: 0;
}

.automation-settings-form .checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

/* Dashboard Layout */
.header {
    background: linear-gradient(120deg, #0f172a 0%, #1e3a8a 55%, #047857 100%);
    padding: 16px 30px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1100;
    flex-shrink: 0;
}

.header-left {
    min-width: 0;
    flex: 1 1 auto;
}

.header h1 {
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: transparent;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-header-icon:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.btn-header-icon--danger {
    border-color: rgba(252, 165, 165, 0.55);
    color: #fecaca;
}

.btn-header-icon--danger:hover {
    background: rgba(220, 38, 38, 0.35);
    border-color: rgba(254, 202, 202, 0.75);
    color: #fff;
}

.header .btn-outline {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.45);
}

.header .btn-outline:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.header .user-info,
.header .user-name,
.header .user-role {
    color: #e2e8f0;
}

.header .user-role {
    background: rgba(255, 255, 255, 0.12);
}

.user-info {
    color: #666;
    font-size: 14px;
}

/* Navigation */
.nav {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.nav-item {
    padding: 10px 20px;
    background: #f8f9fa;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
}

.nav-item:hover {
    background: #e9ecef;
}

.nav-item.active {
    background: #0369a1;
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px 24px 30px;
}

/* Portal layout — sidebar + main (مثل اتوماسیون) */
.portal-layout {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    min-height: 0;
}

.portal-layout--no-sidebar {
    display: block;
}

.portal-layout--no-sidebar .portal-sidebar {
    display: none;
}

.portal-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--portal-header-height, 68px) + 12px);
    max-height: calc(100vh - var(--portal-header-height, 68px) - 24px);
    overflow-y: auto;
    padding: 4px 0 12px;
}

.portal-main {
    flex: 1;
    min-width: 0;
}

.portal-main--home .content-section:not(.portal-home-section) {
    display: none !important;
}

/* Portal home — world map background */
.portal-home-section {
    position: relative;
    min-height: calc(100vh - 120px);
    padding: 0 !important;
    margin: 0;
    border-radius: 16px;
    overflow: hidden;
    background: #0c4a6e;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
}

.portal-home-map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.portal-home-map .leaflet-container {
    width: 100%;
    height: 100%;
    background: #dbeafe;
    font-family: inherit;
}

.portal-home-overlay {
    position: relative;
    z-index: 2;
    pointer-events: none;
    padding: 20px;
}

.portal-home-card {
    display: inline-block;
    max-width: 360px;
    padding: 16px 18px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(8px);
    color: #f8fafc;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}

.portal-home-card h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
    color: #fff;
}

.portal-home-lead {
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.portal-home-stats {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: #7dd3fc;
}

.portal-map-blink-marker-wrap {
    background: transparent !important;
    border: none !important;
}

.portal-map-blink-marker {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2563eb;
    border: 2px solid #fff;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.65);
    animation: portal-map-blink 1.7s ease-in-out infinite;
}

@keyframes portal-map-blink {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.65);
    }
    50% {
        opacity: 0.45;
        transform: scale(1.45);
        box-shadow: 0 0 0 14px rgba(37, 99, 235, 0);
    }
}

.portal-map-tooltip {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
}

.portal-nav-home {
    margin-bottom: 10px;
}

.portal-nav-home .portal-nav-item {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 12px;
}

.portal-nav-home .portal-nav-icon {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

.portal-nav-home .portal-nav-label {
    font-size: 0.78rem;
    -webkit-line-clamp: 1;
}

.portal-main--home .content-section:not(.portal-home-section) {
    display: none !important;
}

.portal-nav-group {
    --portal-group-accent: #2563eb;
    border: 1px solid #e2e8f0;
    border-right: 3px solid var(--portal-group-accent);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    margin-bottom: 10px;
    overflow: hidden;
}

.portal-nav-group--inquiry { --portal-group-accent: #059669; }
.portal-nav-group--admin { --portal-group-accent: #64748b; }
.portal-nav-group--finance { --portal-group-accent: #2563eb; }
.portal-nav-group--documents { --portal-group-accent: #7c3aed; }
.portal-nav-group--support { --portal-group-accent: #0891b2; }
.portal-nav-group--forms { --portal-group-accent: #d97706; }

.portal-nav-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--portal-group-accent);
    background: linear-gradient(90deg, rgba(248, 250, 252, 0.95), #fff);
    border-bottom: 1px solid #f1f5f9;
}

.portal-nav-group-header i {
    width: 14px;
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.9;
}

.portal-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
}

.portal-sidebar .portal-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding: 8px 4px 7px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    font-family: inherit;
    text-align: center;
    min-height: 68px;
    box-shadow: none;
}

.portal-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding: 8px 4px 7px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    font-family: inherit;
    text-align: center;
    min-height: 68px;
}

.portal-nav-item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateY(-1px);
}

.portal-nav-item.selected {
    background: #dbeafe;
    border-color: #2563eb;
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.portal-nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(145deg, var(--cs-blue) 0%, var(--cs-green) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 4px 10px rgba(29, 78, 216, 0.22);
}

.portal-nav-icon.has-attachment-clip .attachment-clip-mark {
    position: absolute;
    left: -2px;
    bottom: -2px;
    font-size: 9px;
    color: #fff;
    background: var(--cs-green-dark);
    border-radius: 50%;
    padding: 2px;
    border: 1px solid #fff;
    line-height: 1;
}

.portal-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.25;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Legacy quick-access grid (fallback) */
.quick-access:not(.portal-sidebar) {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

/* For representatives: show 2 cards centered */
.quick-access:has(.quick-access-card[data-section="profile-faq-quick"]) {
    grid-template-columns: repeat(2, 1fr);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.quick-access-card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.quick-access-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 28px rgba(5, 150, 105, 0.22);
}

.card-icon {
    width: 80px;
    height: 80px;
    border-radius: 22px;
    background: linear-gradient(145deg, var(--cs-blue) 0%, var(--cs-green) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    box-shadow: 0 10px 24px rgba(29, 78, 216, 0.28);
    transition: all 0.3s ease;
    border: none;
    position: relative;
}

.card-icon.has-attachment-clip .attachment-clip-mark {
    position: absolute;
    left: -3px;
    bottom: -3px;
    font-size: 14px;
    color: #fff;
    background: var(--cs-green-dark);
    border-radius: 50%;
    padding: 4px;
    border: 1px solid #fff;
    line-height: 1;
}

.quick-access-card:hover .card-icon {
    transform: scale(1.08) rotate(-2deg);
    box-shadow: 0 14px 28px rgba(5, 150, 105, 0.35);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.user-details {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.user-role {
    font-size: 14px;
    color: #666;
    background: #f8f9fa;
    padding: 4px 12px;
    border-radius: 12px;
}

/* Header user info in a single row */
.header-right #userInfo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-right #userInfo .user-details {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
.header-right #userInfo .user-name {
    margin: 0;
}
.header-right #userInfo .user-role {
    margin: 0;
}
.content-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.section-header h2 {
    color: #333;
    font-size: 20px;
}

.section-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.section-controls .btn {
    white-space: nowrap;
}
.modal-content.modal-content-wide {
    max-width: min(1180px, 96vw);
    width: 96vw;
}
.rep-master-report-modal .modal-header h3 {
    font-family: Lalezar, Nazanin, "B Nazanin", Tahoma, sans-serif;
    font-weight: 400;
    font-size: 1.45rem;
}
.rep-master-report {
    font-family: Nazanin, "B Nazanin", BNazanin, Tahoma, sans-serif;
}
.rep-master-report-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}
.rep-master-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.15rem;
}
.rep-master-report-table-wrap {
    max-height: min(70vh, 640px);
    overflow: auto;
}
.rep-master-report-table {
    font-family: Nazanin, "B Nazanin", BNazanin, Tahoma, sans-serif;
}
.rep-master-report-table th:nth-child(1),
.rep-master-report-table td:nth-child(1) {
    width: 3.5rem;
    white-space: nowrap;
}
.rep-master-report-table th:nth-child(2),
.rep-master-report-table td:nth-child(2) {
    min-width: 9rem;
    white-space: nowrap;
}
.rep-master-report-cell {
    vertical-align: top;
    font-size: 0.88rem;
    line-height: 1.45;
}
.rep-master-report-line {
    margin: 0 0 0.35rem;
}
.rep-master-report-line:last-child {
    margin-bottom: 0;
}
.rep-master-report-branch {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: #0f766e;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Search Box */
.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Vazirmatn', sans-serif;
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.rep-filter-search-box {
    flex: 0 1 260px;
    min-width: 220px;
}

.searchable-select {
    position: relative;
    min-width: 180px;
}

.searchable-select-trigger {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    font-family: 'Vazirmatn', sans-serif;
    text-align: right;
    cursor: pointer;
}

.searchable-select-panel {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    padding: 8px;
}

.searchable-select.open .searchable-select-panel {
    display: block;
}

.searchable-select-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: 'Vazirmatn', sans-serif;
    margin-bottom: 8px;
}

.searchable-select-options {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.searchable-select-option {
    width: 100%;
    border: 0;
    border-radius: 6px;
    background: transparent;
    padding: 8px 10px;
    text-align: right;
    font-family: 'Vazirmatn', sans-serif;
    cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option.active {
    background: #f2f7ff;
}

/* Select Boxes */
select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Vazirmatn', sans-serif;
    background: white;
    min-width: 150px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #eee;
}

/* Bulk grid modal compact row spacing but taller inputs */
#bulkGridTable.data-table {
    border-collapse: collapse;
}
#bulkGridTable.data-table th,
#bulkGridTable.data-table td {
    padding: 4px 6px; /* minimal spacing between rows */
}
#bulkGridTable input[type="text"],
#bulkGridTable input[type="number"],
#bulkGridTable select {
    height: 40px; /* taller controls for easier editing */
    line-height: 40px;
}
#bulkGridTable input[type="file"] {
    height: 40px;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    direction: rtl;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
}

.pagination button:hover {
    background: #f8f9fa;
}

.pagination button.active {
    background: #0369a1;
    color: white;
    border-color: #0369a1;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.pagination-edge {
    box-sizing: border-box;
    min-width: 40px;
    width: 40px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    unicode-bidi: isolate;
}

.pagination button.pagination-step {
    box-sizing: border-box;
    min-width: 40px;
    height: 38px;
    padding: 8px 10px;
    font-size: 1rem;
    line-height: 1;
    unicode-bidi: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-green) 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(29, 78, 216, 0.28);
    border-radius: 12px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--cs-blue-dark) 0%, var(--cs-green-dark) 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(5, 150, 105, 0.35);
}

.btn-secondary {
    background: #64748b;
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: linear-gradient(135deg, var(--cs-green-soft) 0%, var(--cs-green) 100%);
    color: white;
}

.btn-success:hover {
    background: var(--cs-green-dark);
}

.btn-danger {
    background: var(--cs-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--cs-danger-dark);
}

.btn-outline {
    background: transparent;
    color: var(--cs-sky);
    border: 1px solid var(--cs-sky);
}

.btn-outline:hover {
    background: var(--cs-sky);
    color: white;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

.modal-content:has(.user-admin-form) {
    max-width: 920px;
}

.user-admin-form .form-row-4 {
    flex-wrap: nowrap;
    align-items: flex-end;
}
@media (max-width: 640px) {
    .user-admin-form .form-row-4 {
        flex-wrap: wrap;
    }
}
.user-admin-form .form-row-4 .form-group:not(.form-group-title) {
    flex: 1 1 0;
    min-width: 0;
}
.user-admin-form .form-row-4 .form-group-title,
.user-admin-form .form-row-4 .form-group-title.float-field {
    flex: 0 0 3.4rem;
    width: 3.4rem;
    max-width: 3.4rem;
    min-width: 0;
    overflow: hidden;
    margin-bottom: 1.1rem;
}
.user-admin-form .form-row-4 .form-group-title > label {
    display: block;
    position: static;
    transform: none;
    margin: 0 0 0.2rem;
    padding: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    background: none;
    z-index: auto;
}
.user-admin-form .form-row-4 .form-group-title select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.85rem 0.1rem;
    font-size: 0.78rem;
    text-overflow: ellipsis;
}
.user-admin-form .form-row-3 .form-group {
    flex: 1 1 0;
}

.access-modules-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1.15rem;
    margin: 0.35rem 0 1rem;
}
.access-modules-label {
    font-weight: 600;
    color: #334155;
    margin: 0;
    line-height: 1.25;
    white-space: nowrap;
}
.access-modules-row .access-check {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    font-weight: 500;
    color: #334155;
    line-height: 1.25;
    cursor: pointer;
}
.access-modules-row .access-check input[type="checkbox"] {
    margin: 0;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    position: relative;
    top: 0;
}
.automation-admin-fields {
    margin: 0.5rem 0 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.automation-admin-fields .form-hint {
    margin: 0 0 0.5rem;
}

#expertGroup {
    display: none;
}

#representativeFields {
    display: none;
}

.rep-master-data {
    margin-top: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.rep-master-block {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    background: #f8fafc;
}
.rep-master-title {
    margin: 0 0 0.25rem;
    font-size: 0.98rem;
    color: #0f172a;
}
.rep-master-subtitle {
    margin: 0 0 0.2rem;
    font-size: 0.9rem;
    color: #334155;
    font-weight: 600;
}
.rep-branch-panel {
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid #e2e8f0;
}
.rep-branch-panel:last-child {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
}
.rep-branch-heading { color: #0f766e; }
.rep-branch-name-field { margin-bottom: 0.4rem; }
.rep-branch-count-block {
    margin-top: 0.35rem;
    padding: 0.45rem 0.55rem;
    border-top: 1px dashed #cbd5e1;
}
.rep-branch-count-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.45rem 0.55rem;
}
.rep-branch-count-label {
    margin: 0;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    line-height: 1.25;
    flex: 0 0 auto;
}
.rep-branch-count-select,
.rep-branch-count-row select.rep-branch-count-select {
    width: 2.15rem !important;
    min-width: 2.15rem !important;
    max-width: 2.15rem !important;
    margin: 0;
    height: 2.2rem;
    padding: 0.2rem 0.05rem !important;
    font-size: 0.85rem;
    flex: 0 0 2.15rem;
    box-sizing: border-box;
}
.rep-branch-count-row .btn {
    height: 2.2rem;
    padding: 0 0.65rem;
    white-space: nowrap;
    line-height: 1.1;
    flex: 0 0 auto;
    margin: 0;
}
.rep-contract-add-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.2rem;
    margin-bottom: 0;
}
.rep-contract-add-actions [data-cancel-contract-edit][hidden],
.rep-contract-add [hidden] {
    display: none !important;
}
.rep-contract-add .form-row {
    margin-bottom: 0.4rem;
    gap: 0.4rem;
}
.rep-contract-add .form-group,
.rep-contract-add .form-group.float-field {
    margin-bottom: 0.35rem;
}
.rep-contract-add .form-hint {
    margin: 0 0 0.3rem;
}
.rep-contract-dates-row .form-group {
    flex: 1 1 0;
    min-width: 0;
}
.rep-contract-tier-field {
    flex: 0 1 8.5rem;
    max-width: 9.5rem;
}
.rep-contract-tiers-row {
    flex-wrap: nowrap;
    align-items: flex-end;
    width: 100%;
}
.rep-contract-tiers-row .rep-contract-num {
    flex: 1 1 0;
    width: auto;
    max-width: none;
    min-width: 0;
}
.rep-contract-tiers-row .rep-contract-num[hidden] {
    display: none !important;
    flex: 0 0 0;
    width: 0;
    max-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
}
.rep-contract-tiers-row .rep-contract-num input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding-inline: 0.45rem;
    font-size: 0.9rem;
}
.rep-contract-tiers-row .rep-contract-num > label {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}
.rep-contract-note {
    margin-bottom: 0.25rem !important;
}
.rep-master-list {
    max-height: 220px;
    overflow: auto;
    margin: 0.35rem 0 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.rep-master-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.rep-master-item-main { flex: 1; font-size: 0.9rem; color: #334155; }
.rep-master-sub { margin-top: 0.2rem; color: #475569; font-size: 0.84rem; }
.rep-master-note { margin-top: 0.15rem; color: #64748b; font-size: 0.8rem; }
.rep-master-empty { color: #94a3b8; font-size: 0.88rem; padding: 0.35rem 0; }
.rep-master-badge {
    display: inline-block;
    margin-right: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.75rem;
}
.rep-master-item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
  align-items: center;
}
.rep-master-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}
.rep-master-name-row .rep-master-name-field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.rep-master-name-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
  align-self: center;
  height: 2.5rem;
}
.rep-master-add {
  align-items: center;
  margin-bottom: 0;
}
#editRepresentativeFields {
  margin-bottom: 0.5rem;
}
#editRepresentativeFields > .form-row {
  margin-bottom: 0.55rem;
}
#editRepresentativeFields > .form-row > .form-group,
#editRepresentativeFields > .form-row > .form-group.float-field {
  margin-bottom: 0.35rem;
}
.rep-master-block > .form-hint {
  margin: 0 0 0.25rem;
}
.btn-xs {
    padding: 0.2rem 0.45rem;
    font-size: 0.75rem;
    line-height: 1.2;
}
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #999;
    opacity: 0.7;
}
.form-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #1d4ed8;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0369a1;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: white;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 15px 20px;
    margin-bottom: 10px;
    border-right: 4px solid #0369a1;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    border-right-color: #28a745;
}

.toast.error {
    border-right-color: #1d4ed8;
}

.toast.warning {
    border-right-color: #ffc107;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Profile Styles */
.balance-display {
    margin-bottom: 30px;
}

.balance-card {
    background: linear-gradient(135deg, #0369a1, #075985);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.balance-card h3 {
    margin-bottom: 15px;
    font-size: 18px;
}

.balance-amount {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 20px;
}

.balance-updated {
    margin-top: -10px;
    margin-bottom: 15px;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
}

/* Representative Balance Display (at top of page) */
/* Profile balance display - centered at top of profile section */
.profile-balance-display {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
}

.profile-balance-display .balance-card {
    display: inline-block;
    text-align: center;
    margin: 0 auto;
}

.representative-balance-display {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    width: 100%;
}

.representative-balance-display .balance-card {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    background: linear-gradient(135deg, #0369a1, #075985);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.representative-balance-display .balance-amount {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 15px;
    word-break: break-word;
}

.representative-balance-display .balance-updated {
    margin-top: -10px;
    margin-bottom: 20px;
    font-size: 13px;
    color: rgba(255,255,255,0.9);
}

/* Balance Warnings */
.balance-warnings {
    margin-top: 15px;
    max-width: 600px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.balance-warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
}

.balance-warning i {
    color: #ffc107;
    font-size: 18px;
    flex-shrink: 0;
}

.balance-warning span {
    flex: 1;
}

.profile-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 15px 25px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #0369a1;
}

.tab-btn.active {
    color: #0369a1;
    border-bottom-color: #0369a1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* FAQ Styles */
.faq-list {
    margin-bottom: 20px;
}

.faq-item {
    background: white;
    border: 1px solid #eee;
    border-radius: 5px;
    margin-bottom: 10px;
    overflow: hidden;
}

.faq-question {
    padding: 15px 20px;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

.faq-question:hover {
    background: #e9ecef;
}

.faq-question h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
}

.faq-icon {
    transition: transform 0.3s;
}

.faq-item.expanded .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #eee;
    display: none;
}

.faq-item.expanded .faq-answer {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
    }

    .header h1 {
        font-size: 17px;
    }

    .header-right {
        gap: 8px;
    }

    .btn-header-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }
    
    .nav {
        padding: 15px 20px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .section-controls {
        flex-direction: column;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .portal-layout {
        flex-direction: column;
    }

    .portal-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        overflow: visible;
    }

    .portal-nav-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .quick-access:not(.portal-sidebar) {
        grid-template-columns: 1fr;
    }
    
    /* For representatives on mobile: keep 2 columns if possible, otherwise 1 */
    .quick-access:has(.quick-access-card[data-section="profile-faq-quick"]) {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .profile-tabs {
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .tab-btn {
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .login-container {
        margin: 50px 20px;
        padding: 30px 20px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
    
    .toast {
        min-width: 250px;
        font-size: 14px;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.d-none {
    display: none;
}

.d-block {
    display: block;
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.gap-3 {
    gap: 1rem;
}

/* Persian Number Support */
.persian-number {
    font-family: 'Vazirmatn', sans-serif;
    direction: ltr;
    display: inline-block;
}

/* RTL Support */
[dir="rtl"] .search-box i {
    left: 15px;
    right: auto;
}

[dir="rtl"] .search-box input {
    padding: 10px 15px 10px 40px;
}

[dir="rtl"] .toast {
    border-left: 4px solid #0369a1;
    border-right: none;
}

[dir="rtl"] .toast.success {
    border-left-color: #28a745;
    border-right: none;
}

[dir="rtl"] .toast.error {
    border-left-color: #1d4ed8;
    border-right: none;
}

[dir="ltr"] .search-box i {
    right: 15px;
    left: auto;
}

[dir="ltr"] .search-box input {
    padding: 10px 40px 10px 15px;
}

.lang-switch {
    display: inline-flex;
    gap: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    margin-bottom: 0.85rem;
}

.lang-switch--header {
    margin-bottom: 0;
    margin-inline-end: 0.35rem;
    flex-shrink: 0;
}

.lang-switch-btn {
    border: 0;
    background: transparent;
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: #64748b;
    font-family: inherit;
}

.lang-switch-btn.is-active {
    background: #0f172a;
    color: #fff;
}

.login-container .lang-switch {
    position: absolute;
    top: 0.75rem;
    inset-inline-end: 0.75rem;
    margin-bottom: 0;
}

.login-container {
    position: relative;
}

.btn-link {
    background: none;
    color: #1d4ed8;
    text-decoration: underline;
    border: none;
    padding: 5px 10px;
    font-size: 14px;
    cursor: pointer;
}

.btn-link:hover {
    color: #1e40af;
    text-decoration: none;
}

/* Icon buttons for table actions */
.btn.btn-icon {
    background: transparent;
    border: none;
    color: #333;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 16px;
}
.btn.btn-icon:hover {
    color: #1d4ed8;
}
.btn.btn-icon.danger {
    color: #1d4ed8;
}

/* Disabled download label */
.disabled-link {
    color: #9aa0a6;
    cursor: not-allowed;
    text-decoration: none;
    opacity: 0.7;
}

.thumb-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: #fafafa;
}
.thumb-link i {
    font-size: 16px;
    color: #444;
}
.thumb-link:hover i {
    color: #0369a1;
}

/* Attachment editor UI */
.file-section {
    border: 1px solid #e6e6e6;
    background: #fafafa;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 8px;
}
.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.file-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #333;
}
.file-meta .att-name {
    font-weight: 600;
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-actions a {
    margin-inline-start: 8px;
}
.file-remove {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: #c0392b;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Narrow icon columns and widen description */
.data-table td.col-icon, .data-table th.col-icon {
    width: 56px;
    min-width: 56px;
    text-align: center;
}
.data-table td.col-ops, .data-table th.col-ops {
    width: 112px;
    min-width: 112px;
    text-align: center;
}
.data-table td.col-desc, .data-table th.col-desc {
    width: 40%;
}

.rep-name-link {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}

.rep-name-link:hover {
    text-decoration: none;
    color: #0a58ca;
    border-bottom-color: #0a58ca;
}

/* Representatives preview modal */
.rep-preview .muted { color: #777; font-size: 12px; margin-top: 4px; }
.rep-preview-body .loading { color: #555; }
.text-danger { color: #c0392b; }
.text-success { color: #2ecc71; }
.rep-preview-header h4 { display: flex; align-items: baseline; gap: 8px; }
.rep-preview-header .rep-balance { font-weight: 600; }
.rep-preview-header .rep-subline { color: #555; font-size: 12px; margin-top: 4px; }
.rep-preview-header .rep-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rep-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: #333; line-height: 1; }
.rep-close:hover { color: #000; }

/* Profile Ticket list */
#profileTicketList .ticket-item { border: 1px solid #eee; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
#profileTicketList .ticket-header { font-weight: 700; margin-bottom: 6px; }
#profileTicketList .ticket-content { margin-bottom: 6px; line-height: 1.8; }
#profileTicketList .ticket-response { border-top: 1px dashed #ddd; padding-top: 6px; color: #333; }

.login-options {
    text-align: center;
    margin-top: 15px;
}
.user-info {
    background: transparent;
    color: inherit;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.user-details {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.user-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
}

.user-role {
    font-size: 14px;
    opacity: 0.9;
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.btn-link {
    background: none;
    color: #1d4ed8;
    text-decoration: underline;
    border: none;
    padding: 5px 10px;
    font-size: 14px;
    cursor: pointer;
}

.btn-link:hover {
    color: #1e40af;
    text-decoration: none;
}

.login-options {
    text-align: center;
    margin-top: 15px;
}

.login-method-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
}

.login-method-tab {
    border: 1px solid #d0d7de;
    background: #f6f8fa;
    color: #444;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}

.login-method-tab.is-active {
    background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-green) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 18px rgba(29, 78, 216, 0.25);
}

.mobile-login-panel .form-hint {
    margin-bottom: 12px;
    color: #555;
    line-height: 1.7;
    font-size: 13px;
}

.mobile-login-accounts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 16px;
}

.mobile-login-account {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    background: #fff;
    text-align: right;
    width: 100%;
    font-family: inherit;
}

.mobile-login-account:hover,
.mobile-login-account.is-selected {
    border-color: #0284c7;
    background: #f5f8ff;
}

/* Profile Icons Grid */
.profile-icons-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.profile-icons-grid .icon-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform .2s, box-shadow .2s;
}
.profile-icons-grid .icon-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* Profile two-column info grid */
.profile-info-grid {
    display: grid;
    grid-template-columns: 0.85fr 1.65fr; /* ستون راست کمی کوتاه‌تر */
    margin-bottom: 20px;
    background: #ffffff; /* پس‌زمینهٔ اطلاعات پروفایل سفید */
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #f0f2f5; /* خطوط بیرونی با همان رنگ پس‌زمینه ستون راست */
}
.profile-info-grid .info-row {
    display: contents;
}
.profile-info-grid .info-label,
.profile-info-grid .info-value {
    padding: 12px 14px;
    font-size: 14px;
    border-bottom: 1px solid #f0f2f5; /* خط‌کشی افقی با رنگ پس‌زمینه ستون راست */
}
.profile-info-grid .info-label {
    color: #555;
    background: #f6f7fa; /* پس‌زمینه برای ستون راست (برچسب) */
}
.profile-info-grid .info-value {
    color: #222;
    font-weight: 600;
    background: #ffffff; /* ستون چپ سفید */
    border-left: 1px solid #f0f2f5; /* مرز عمودی با همان رنگ پس‌زمینه ستون راست */
}

/* Selected state for portal nav + legacy cards */
.profile-icons-grid .icon-card.selected,
.portal-nav-item.selected,
.quick-access .quick-access-card.selected {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* Disabled icon cards (empty sections) */
.profile-icons-grid .icon-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(50%);
}

tr.attachment-source-highlight {
    background: #fff4d8 !important;
    transition: background-color .2s ease;
}

/* Toggle switch for user active state */
.btn-toggle {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #e9ecef;
    padding: 0;
    margin-inline-end: 6px;
}
.btn-toggle span {
    position: absolute;
    top: 2px;
    right: 2px; /* RTL default */
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: all .2s ease;
}
.btn-toggle.on {
    background: #28a745;
    border-color: #28a745;
}
.btn-toggle.on span {
    right: 14px; /* move knob left in RTL when ON */
}
.btn-toggle.off {
    background: #e0e0e0;
}
.btn-toggle[disabled], .btn-toggle[aria-disabled="true"] {
    opacity: .5;
    cursor: not-allowed;
}

/* Inactive user row dimming */
.inactive-row {
    opacity: .7;
}

/* Lookup dropdown styles */
.lookup-container {
    position: relative;
}
.lookup-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    z-index: 1000;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}
.lookup-item {
    padding: 8px 10px;
    cursor: pointer;
}
.lookup-item:hover {
    background: #f6f7fa;
}

/* Inline field error */
.field-error {
    color: #1d4ed8;
    font-size: 12px;
    margin-top: 4px;
}

.input-error {
    border-color: #1d4ed8 !important;
}

/* Representative Profile Message List */
.message-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.message-item { padding: 12px 14px; background: #ffffff; border: 1px solid #eee; border-radius: 8px; border-bottom: 2px solid #e9ecef; }
.message-header { background: #f8f9fa; padding: 8px 10px; border-radius: 6px; }
.message-title { font-weight: 700; font-size: 15px; color: #222; }
.message-date { margin-top: 4px; font-size: 12px; color: #666; }
.message-content { margin-top: 8px; line-height: 1.9; color: #333; font-size: 14px; }

/* Superadmin backup / restore grids */
.backup-scope-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: flex-start;
    margin-top: 6px;
}
.backup-scope-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    cursor: pointer;
    user-select: none;
}
.backup-scope-option input {
    cursor: pointer;
}
.backup-scope-all {
    flex-basis: 100%;
    font-weight: 600;
}

.automation-devices-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.automation-device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}
.automation-device-item:last-child { border-bottom: none; }
.automation-device-meta { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.automation-device-id { color: #64748b; font-size: 0.75rem; }

/* OnlyOffice spreadsheet export editor */
.doc-editor-overlay { z-index: 20000; }
.doc-editor-modal {
    width: min(96vw, 1200px);
    max-width: none;
    height: 90vh;
    display: flex;
    flex-direction: column;
    margin: 2vh auto;
    padding: 0;
    overflow: hidden;
}
.doc-editor-modal .modal-header { flex-shrink: 0; }
.doc-editor-frame {
    flex: 1;
    min-height: 70vh;
    height: calc(90vh - 64px);
    width: 100%;
    position: relative;
}
.doc-editor-frame iframe { width: 100%; height: 100%; border: 0; }

/* Payment auto-import */
.payment-auto-import { display: flex; flex-direction: column; gap: 0.75rem; }
.payment-auto-import-result { margin-top: 0.5rem; }
.auto-pay-col-map { margin-top: 0.25rem; }
.auto-pay-col-map-title { margin: 0 0 0.35rem; font-weight: 600; color: #334155; }
.auto-pay-col-map-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem 0.75rem;
}
@media (min-width: 640px) {
  .auto-pay-col-map-grid { grid-template-columns: 1fr 1fr; }
}
.auto-pay-col-map-grid .form-group { margin: 0; }
.auto-pay-col-map-grid input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
}
.auto-pay-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
}
.auto-pay-table-wrap { max-height: 280px; overflow: auto; margin-top: 0.75rem; }
.auto-pay-issues { margin-top: 0.75rem; }
.auto-pay-issues h4 { margin: 0 0 0.35rem; font-size: 0.92rem; color: #9a3412; }
.auto-pay-issues ul { margin: 0; padding-right: 1.2rem; font-size: 0.85rem; color: #475569; max-height: 140px; overflow: auto; }

/* Access roles matrix */
.section-hint { color: var(--cs-muted, #475569); margin: 0 0 1rem; font-size: 0.92rem; }
.access-layout {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .access-layout { grid-template-columns: 1fr; }
}
.access-role-list { padding: 0.75rem; max-height: 70vh; overflow: auto; }
.access-role-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 12px;
  padding: 0.25rem 0.35rem 0.25rem 0.45rem;
  margin-bottom: 0.5rem;
  font-family: inherit;
}
.access-role-item-main {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  text-align: right;
  border: 0;
  background: transparent;
  padding: 0.45rem 0.4rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-radius: 8px;
}
.access-role-item:hover {
  background: #f8fafc;
}
.access-role-item.active {
  border-color: #1d4ed8;
  background: linear-gradient(135deg, rgba(29,78,216,0.08), rgba(5,150,105,0.08));
}
.access-role-item .badge {
  font-size: 0.72rem;
  color: #0369a1;
  background: #e0f2fe;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}
.access-role-item-tools {
  display: flex;
  gap: 0.1rem;
  flex-shrink: 0;
}
.access-ops-hint {
  font-size: 0.82rem;
  margin: 0 0 0.65rem;
  line-height: 1.45;
}
.access-perm-na {
  text-align: center;
  opacity: 0.4;
}
.access-role-editor { padding: 1rem 1.1rem 1.25rem; }
.access-layer-block {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  margin-top: 0.9rem;
  overflow: hidden;
}
.access-layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  font-weight: 700;
}
.access-section-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.access-section-table th,
.access-section-table td {
  border-top: 1px solid #e2e8f0;
  padding: 0.55rem 0.6rem;
  text-align: center;
}
.access-section-table th:first-child,
.access-section-table td:first-child {
  text-align: right;
}
.access-section-table thead th {
  background: #f1f5f9;
  font-weight: 600;
}
.access-actions-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.muted { color: #64748b; }

.access-layer-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.access-layer-bulk {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.access-layer-bulk .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.access-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  margin: 0.25rem 0 0.85rem;
  color: #475569;
  font-size: 0.86rem;
}
.access-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.access-legend i {
  width: 1.1rem;
  text-align: center;
  color: #1d4ed8;
}
.access-action-head {
  min-width: 64px;
}
.access-action-head i {
  display: block;
  margin: 0 auto 0.2rem;
  color: #1d4ed8;
}
.access-action-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
}
.access-perm-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  user-select: none;
}
.access-perm-toggle:hover:not(.disabled) {
  border-color: #1d4ed8;
  color: #1d4ed8;
  transform: translateY(-1px);
}
.access-perm-toggle.is-on {
  background: linear-gradient(145deg, #1d4ed8, #059669);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.25);
}
.access-perm-toggle.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.access-perm-toggle .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.access-perm-toggle.access-perm-delete.is-on {
  background: linear-gradient(145deg, #b91c1c, #dc2626);
  box-shadow: 0 6px 14px rgba(185, 28, 28, 0.25);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0;
  font-weight: 400;
  cursor: pointer;
}
.form-group-check {
  margin-bottom: 0.85rem;
}
.form-group-check .checkbox-field {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 500;
  color: #0f172a;
  line-height: 1.4;
  max-width: 100%;
}
.form-group-check .checkbox-field:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}
.form-group-check .checkbox-field:has(input:checked) {
  border-color: #0369a1;
  background: #e0f2fe;
}
.form-group-check .checkbox-field input[type="checkbox"],
.form-group-check .df-checkbox {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0.1rem 0 0;
  flex-shrink: 0;
  accent-color: #0369a1;
  cursor: pointer;
}
.form-group-check .checkbox-field span {
  user-select: none;
}
.form-fields-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.75rem 0 0.45rem;
}
.form-field-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  background: #f8fafc;
}
.form-field-card .form-row {
  gap: 8px;
  margin-bottom: 0;
  align-items: flex-end;
}
.form-field-card .form-group {
  margin-bottom: 0;
}
.form-field-card .form-group label {
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  line-height: 1.2;
}
.form-field-card .form-group input,
.form-field-card .form-group select,
.form-field-card .form-group textarea {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 4px;
}
.form-field-card .field-options-wrap,
.form-field-card .field-role-wrap {
  margin-top: 0.45rem;
}
.form-field-main-row .ff-label { flex: 1.4; min-width: 0; }
.form-field-main-row .ff-type { flex: 1.1; min-width: 0; }
.form-field-main-row .ff-key { flex: 0.7; min-width: 0; }
.form-field-main-row .ff-ph { flex: 1; min-width: 0; }
.form-field-main-row .ff-req {
  flex: 0 0 auto;
  width: 4.2rem;
}
.form-field-main-row .ff-remove {
  flex: 0 0 auto;
  width: 2.2rem;
  text-align: center;
}
.form-field-card .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0;
  min-height: 32px;
  font-size: 13px;
  font-weight: 400;
  color: #334155;
  cursor: pointer;
}
.form-field-card .inline-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #0369a1;
}
.form-field-card .ff-remove .btn.btn-icon {
  min-height: 32px;
  padding: 4px 6px;
}
#formBuilderEditor > .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0.15rem;
  font-size: 13px;
}
.ops-cell,
.col-ops { white-space: nowrap; }
.section-header-actions { display: flex; gap: 0.5rem; }

.ops-cargo-summary {
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 42rem;
}
.ops-agent-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-width: 12rem;
}
.ops-agent-inline select {
  min-width: 9rem;
  max-width: 14rem;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
}
.ops-detail .ops-block {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  background: #f8fafc;
}
.ops-detail .ops-block h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  color: #0f172a;
}
.ops-fleet-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.55rem;
  background: #fff;
}
.ops-fleet-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}
.ops-fleet-card h4 {
  margin: 0;
  font-size: 0.9rem;
  color: #0369a1;
}
.ops-route-map {
  height: 280px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin: 0.5rem 0 0.75rem;
  z-index: 1;
  background: #e2e8f0;
}
.ops-route-map-hint {
  font-size: 12px;
  color: #64748b;
  margin: 0 0 0.35rem;
}
.ops-map-search {
  position: relative;
  margin: 0 0 0.5rem;
  z-index: 5;
}
.ops-map-search-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}
.ops-map-search-input:focus {
  outline: none;
  border-color: #0369a1;
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}
.ops-map-search-results {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow: auto;
  z-index: 20;
}
.ops-map-search-results li {
  margin: 0;
}
.ops-map-search-item {
  display: block;
  width: 100%;
  text-align: start;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  color: #0f172a;
  cursor: pointer;
  line-height: 1.35;
}
.ops-map-search-item:hover,
.ops-map-search-item:focus {
  background: #e0f2fe;
  outline: none;
}
.ops-map-search-empty {
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  color: #64748b;
}
.ops-route-coords {
  font-size: 11px;
  color: #64748b;
  direction: ltr;
  unicode-bidi: embed;
}
