/* ===== استایل مشترک اپ کارچین ===== */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e3e6ea;
    --text: #22262b;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f5a623;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Tahoma, sans-serif;
    margin: 0;
    padding: 0;
    direction: rtl;
}

h1 {
    font-size: 22px;
    margin: 0;
}

/* ===== هدر بالای صفحه ===== */
#topBar {
    position: sticky;
    top: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 500;
}

#menuButton {
    font-size: 26px;
    cursor: pointer;
    color: var(--text);
    line-height: 1;
    order: -1;
}

#topBar h1 {
    flex: 1;
    text-align: center;
}

#viewToggle {
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
    line-height: 1;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    user-select: none;
}

#viewToggle:active {
    background: var(--bg);
}

/* ===== منوی کناری (از چپ باز می‌شود) ===== */
#sideMenu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--surface);
    box-shadow: 5px 0 20px rgba(0,0,0,0.15);
    z-index: 2000;
    transition: 0.25s ease;
    display: flex;
    flex-direction: column;
}

#sideMenu.open {
    left: 0;
}

#sideMenuOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1999;
    display: none;
}

#sideMenuOverlay.open {
    display: block;
}

#sideMenuHeader {
    padding: 24px 20px;
    background: var(--primary);
    color: white;
}

#sideMenuHeader > .menu-brand {
    font-size: 18px;
    font-weight: bold;
}

#sideMenu nav {
    padding: 8px 0;
    overflow-y: auto;
}

#sideMenu nav a {
    display: block;
    padding: 16px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 17px;
    border-bottom: 1px solid var(--border);
}

#sideMenu nav a:active {
    background: var(--bg);
}

/* ===== محتوای اصلی ===== */
#mainContent {
    padding: 16px 16px 180px 16px;
    padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px));
}

/* فضای اضافه پایین شبکه تا آخرین کارت‌ها زیر دکمه‌ها نمانند */
.folder-grid,
.folder-compact,
.folder-list,
#itemList,
#folderList {
    padding-bottom: 24px;
    margin-bottom: 8px;
}

/* ===== کارت‌ها ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 16px;
    margin: 10px 0;
    border-radius: var(--radius);
    font-size: 18px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.card img.icon {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 10px;
    background: var(--bg);
}

.card .label {
    flex: 1;
}

.card .chevron {
    color: var(--text-muted);
    font-size: 20px;
}

/* ===== دکمه‌های پایین ثابت ===== */
#bottomButtons {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 500;
}

#bottomButtons button {
    flex: 1 1 40%;
    min-width: 120px;
    padding: 13px 10px;
    font-size: 15px;
    border-radius: 12px;
    border: none;
    color: white;
    cursor: pointer;
}

.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-danger  { background: var(--danger); }
.btn-neutral { background: #4b5563; color: #fff; border: 1px solid transparent; }
.btn-accent  { background: var(--accent); }

/* ===== ورودی‌ها ===== */
input, textarea, select {
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    font-size: 17px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}

textarea { height: 100px; }

/* ===== منوی راست‌کلیک/لمس‌طولانی ===== */
#contextMenu {
    position: fixed;
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    z-index: 3000;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    min-width: 160px;
}

#contextMenu div {
    padding: 12px 16px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
}

#contextMenu div:active {
    background: var(--bg);
}

#contextMenu div.danger {
    color: var(--danger);
}

/* ===== پنجره شناور تمام‌صفحه ===== */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--surface);
    z-index: 4000;
    overflow-y: auto;
    padding: 20px;
}

.overlay.open { display: block; }

.overlay-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 16px;
}

.overlay-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.overlay-actions button {
    flex: 1;
    padding: 15px;
    font-size: 17px;
    border-radius: 10px;
    border: none;
    color: white;
}

/* ===== حالت خالی ===== */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    font-size: 16px;
}

/* ===== ماشین‌حساب قیمت ===== */
#calcButtons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}

#calcButtons button {
    padding: 18px;
    font-size: 22px;
    border-radius: 10px;
    border: none;
    background: var(--bg);
    color: var(--text);
}

#calcButtons button.del { background: #fde68a; }
#calcButtons button.clear { background: #fecaca; }


/* ===== نمای شبکه (Grid) ===== */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.folder-grid .grid-card {
    flex-direction: column;
    text-align: center;
    padding: 14px 10px;
    margin: 0;
    gap: 8px;
}

.folder-grid .grid-icon {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 14px;
    background: var(--bg);
    margin: 0 auto;
}

.folder-grid .grid-label {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

.folder-grid .grid-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== نمای فشرده (Compact) ===== */
.folder-compact .compact-card {
    padding: 12px 14px;
    margin: 6px 0;
    gap: 10px;
}

.folder-compact .compact-card .label {
    font-size: 16px;
}

.folder-compact .compact-count {
    font-size: 14px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 3px 10px;
    border-radius: 20px;
    min-width: 28px;
    text-align: center;
}


/* ===== دکمه‌های هدر (جستجو / سورت / نما) ===== */
.topBarActions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topBarActions > div {
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    user-select: none;
}

.topBarActions > div:active {
    background: var(--bg);
}

#viewToggle {
    font-size: 22px;
}

/* ===== نوار جستجو ===== */
.search-bar {
    display: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 57px;
    z-index: 490;
}

.search-bar.open {
    display: flex;
}

.search-bar input {
    flex: 1;
    margin: 0;
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
}

.search-clear {
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
}

/* ===== برچسب مرتب‌سازی ===== */
.sort-label {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 4px 8px;
    text-align: center;
}





/* ===== چک‌باکس انتخاب چندتایی ===== */
.check-box {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    background: var(--surface);
}

.check-box.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.card.selected {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.grid-card .check-box {
    position: absolute;
    top: 8px;
    right: 8px;
}

.grid-card {
    position: relative;
}

/* ===== نوار عملیات گروهی ===== */
.bulk-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    z-index: 600;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.bulk-bar.open {
    display: flex;
}

.bulk-bar #bulkCount {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.bulk-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.bulk-actions button {
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 10px;
    border: none;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.bulk-actions button.danger-btn {
    background: #fef2f2;
    color: var(--danger);
}

.bulk-actions button:active {
    opacity: 0.8;
}

/* ===== ستاره علاقه‌مندی ===== */
.mark-star {
    color: #f5a623;
    margin-left: 2px;
    font-size: 0.95em;
}


/* ===== آواتار مشتری ===== */
.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8eef7;
    font-size: 22px;
    border-radius: 10px;
}

.grid-icon.avatar-fallback {
    width: 64px;
    height: 64px;
    font-size: 32px;
    border-radius: 14px;
    margin: 0 auto;
}

.avatar-img {
    object-fit: cover;
}

.avatar-wrap {
    width: 100px;
    height: 100px;
    margin: 0 auto 16px;
    position: relative;
    cursor: pointer;
}

.avatar-wrap img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--border);
}

.avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #e8eef7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    border: 3px solid var(--border);
}

.avatar-hint {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}


/* ===== پروفایل مشتری ===== */
.profile-page {
    padding-bottom: 30px;
}

.profile-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.profile-avatar-wrap {
    flex-shrink: 0;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: #e8eef7;
}

.profile-avatar.avatar-fallback,
div.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    background: #e8eef7;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.profile-meta {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 3px;
    cursor: pointer;
}

.profile-notes {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

.summary-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.summary-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.summary-value.neg { color: var(--danger); }
.summary-value.pos { color: var(--success); }

.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.qa-btn {
    flex: 1;
    min-width: 70px;
    padding: 10px 8px;
    font-size: 13px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.qa-btn:active {
    background: var(--bg);
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    font-size: 13px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
}

.tab.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.profile-item {
    align-items: flex-start;
}

.status-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    margin-right: 6px;
    vertical-align: middle;
}

.st-scheduled { background: #dbeafe; color: #1d4ed8; }
.st-progress { background: #fef3c7; color: #b45309; }
.st-done { background: #dcfce7; color: #15803d; }
.st-cancel { background: #fee2e2; color: #b91c1c; }

.item-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

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

.field-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin: 8px 0 4px;
}

.overlay select {
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    font-size: 17px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}


/* ===== فیلتر چیپ‌ها ===== */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 10px;
    margin-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.chip {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}


/* ===== نماها و رنگ کارها ===== */
.job-list-item.job-new,
.job-card.job-new { border-color: #e5e7eb; }

.job-list-item.job-done,
.job-card.job-done { border-color: #86efac; }

.job-list-item.job-postponed,
.job-card.job-postponed { border-color: #fde047; }

.job-list-item.job-cancelled,
.job-card.job-cancelled { border-color: #fca5a5; }

.status-badge.job-new { background: #f3f4f6; color: #374151; }
.status-badge.job-done { background: #dcfce7; color: #15803d; }
.status-badge.job-postponed { background: #fef9c3; color: #a16207; }
.status-badge.job-cancelled { background: #fee2e2; color: #b91c1c; }

.job-grid-sm {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.job-grid-lg {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.job-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
}

.job-card-sm {
    min-height: 90px;
}

.job-card-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 6px;
    line-height: 1.3;
}

.job-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.job-card-desc {
    font-size: 13px;
    margin-top: 8px;
    color: var(--text);
    line-height: 1.4;
}

.job-list-item {
    border-width: 1px;
    border-style: solid;
}

/* انتخاب مشتری در فرم */
.customer-pick-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.btn-pick {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.btn-pick.active-pick {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.pick-list {
    max-height: 180px;
    overflow-y: auto;
    margin: 8px 0;
}

/* رنگ‌ها */
.color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
}

.color-swatch.selected-swatch {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

/* انتخابگر تاریخ شمسی */
.jalali-row {
    display: flex;
    gap: 8px;
    margin: 8px 0 12px;
}

.jalali-row select {
    flex: 1;
    padding: 12px 8px;
    font-size: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}


/* ===== منوی زیرمجموعه‌دار ===== */
#sideMenu nav a.menu-link,
#sideMenu .menu-parent {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

#sideMenu nav a.active,
#sideMenu nav a.menu-link.active {
    background: var(--bg);
    font-weight: 600;
    color: var(--primary);
}

.menu-parent {
    justify-content: flex-start;
    user-select: none;
}

.menu-arrow {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 18px;
    color: var(--text-muted);
    width: 18px;
}

.menu-group.open > .menu-parent .menu-arrow {
    transform: rotate(-90deg);
}

.menu-children {
    display: none;
    background: #f8fafc;
}

.menu-group.open > .menu-children {
    display: block;
}

.menu-children a {
    display: block;
    padding: 12px 20px 12px 36px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}

.menu-children a:active {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.menu-plus {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 16px;
    text-align: center;
    border-radius: 4px;
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: bold;
    margin-left: 6px;
    vertical-align: middle;
}

.contract-price-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 12px;
    font-size: 15px;
    cursor: pointer;
}

.contract-price-label input {
    width: auto;
    margin: 0;
}


/* پوشه مورد علاقه‌ها */
.fav-folder-card {
    border-color: var(--accent) !important;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface)) !important;
}
.fav-folder-card .label,
.fav-folder-card .grid-label {
    font-weight: 600;
}


/* وضعیت در صف انجام */
.job-list-item.job-todo,
.job-card.job-todo { border-color: #93c5fd; }
.status-badge.job-todo { background: #dbeafe; color: #1d4ed8; }


/* وضعیت فاکتور در پروفایل */
.inv-card.inv-paid { border-color: #16a34a !important; background: #dcfce7 !important; }
.inv-card.inv-open { border-color: #d1d5db !important; background: #ffffff !important; }
.inv-card.inv-overdue { border-color: #dc2626 !important; background: #fee2e2 !important; }
.inv-card.st-progress { border-color: #f59e0b !important; background: #fef3c7 !important; }
.status-badge.inv-paid { background: #16a34a; color: #fff; }
.status-badge.inv-open { background: #e5e7eb; color: #374151; }
.status-badge.inv-overdue { background: #dc2626; color: #fff; }
.status-badge.st-progress { background: #f59e0b; color: #fff; }
.account-note {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin: -4px 0 12px;
    line-height: 1.4;
}


/* زیرپوشه در شبکه — هم‌اندازه آیتم‌ها */
.folder-grid .subfolder-card {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}
.folder-grid .grid-icon {
    width: 64px;
    height: 64px;
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
    margin: 0 auto 8px;
    display: block;
}
.folder-grid .grid-card {
    text-align: center;
    padding: 14px 10px;
    overflow: hidden;
}
.folder-grid .grid-label {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#contextMenu, #subFolderContextMenu {
    position: fixed;
    z-index: 2000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 180px;
    max-width: 90vw;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
#contextMenu > div, #subFolderContextMenu > div {
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}
#contextMenu > div:last-child, #subFolderContextMenu > div:last-child { border-bottom: none; }
#contextMenu > div:active, #subFolderContextMenu > div:active { background: var(--bg); }


/* لیست فاکتورها */
.inv-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    border-radius: 14px;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: transform .12s ease;
}
.inv-card:active { transform: scale(0.98); }
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0 4px;
}
.filter-chips .chip {
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
}
.filter-chips .chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}


.inv-card.inv-paid-discount { border-color: #8b5cf6 !important; background: #ede9fe !important; }
.status-badge.inv-paid-discount { background: #7c3aed; color: #fff; }




/* هدر پروفایل منوی کناری — دایره کوچک + نام */
#sideMenuHeader {
    padding: 12px 14px !important;
    background: var(--primary) !important;
    color: #fff !important;
    border-bottom: none !important;
}
#sideMenuHeader a.menu-user-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    text-decoration: none !important;
    color: #fff !important;
    padding: 6px 4px !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}
#sideMenuHeader a.menu-user-card img.menu-av-img {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
    flex-shrink: 0 !important;
    background: #e2e8f0 !important;
    border: 2px solid rgba(255,255,255,0.5) !important;
}
#sideMenuHeader .menu-av-fallback {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 20px !important;
    flex-shrink: 0 !important;
}
#sideMenuHeader .menu-user-meta {
    flex: 1 !important;
    min-width: 0 !important;
    text-align: right !important;
}
#sideMenuHeader .menu-user-name {
    font-weight: 700 !important;
    font-size: 15px !important;
    color: #fff !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
#sideMenuHeader .menu-user-tag {
    font-size: 11px !important;
    color: rgba(255,255,255,0.85) !important;
    margin-top: 2px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}


/* ===== THEME SYSTEM (optimized) ===== */
/* متغیرها فقط روی html — بقیه از var() ارث می‌برند */

html.theme-pro {
  --bg: #0e1624;
  --surface: #1a2538;
  --border: rgba(245,196,0,.22);
  --text: #f3f6fb;
  --text-muted: rgba(243,246,251,.82);
  --primary: #f5c400;
  --primary-dark: #d4a800;
  --accent: #f5c400;
  --danger: #ff5c5c;
  --success: #3ddc97;
  --topbar-bg: rgba(12,18,30,.94);
  --topbar-fg: #f5c400;
  --menu-bg: #121c2e;
  --menu-header: linear-gradient(135deg,#1a2538,#0f172a);
  --menu-header-fg: #f5c400;
  --card-bg: linear-gradient(160deg,#1e2b40,#162033);
}
html.theme-pro.mode-day {
  --bg: #e8eef8;
  --surface: #fff;
  --border: rgba(37,99,235,.12);
  --text: #152033;
  --text-muted: #475569;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --accent: #1d4ed8;
  --danger: #e11d48;
  --success: #059669;
  --topbar-bg: rgba(238,242,255,.96);
  --topbar-fg: #1d4ed8;
  --menu-bg: #f8fafc;
  --menu-header: linear-gradient(135deg,#1d4ed8,#2563eb);
  --menu-header-fg: #fff;
  --card-bg: #fff;
}

html.theme-neon {
  --bg: #0a0a12;
  --surface: #16122a;
  --border: rgba(168,85,247,.28);
  --text: #f8f7ff;
  --text-muted: rgba(248,247,255,.82);
  --primary: #a855f7;
  --primary-dark: #7c3aed;
  --accent: #22d3ee;
  --danger: #f472b6;
  --success: #4ade80;
  --topbar-bg: rgba(10,10,18,.95);
  --topbar-fg: #22d3ee;
  --menu-bg: #12101c;
  --menu-header: linear-gradient(135deg,#1e1033,#0f172a);
  --menu-header-fg: #e9d5ff;
  --card-bg: rgba(22,18,42,.95);
}
html.theme-neon.mode-day {
  --bg: #f5f3ff;
  --surface: #fff;
  --border: rgba(168,85,247,.18);
  --text: #1e1033;
  --text-muted: #4b5563;
  --primary: #6d28d9;
  --primary-dark: #5b21b6;
  --accent: #0e7490;
  --danger: #e11d48;
  --success: #059669;
  --topbar-bg: rgba(250,245,255,.96);
  --topbar-fg: #5b21b6;
  --menu-bg: #faf5ff;
  --menu-header: linear-gradient(135deg,#7c3aed,#a855f7);
  --menu-header-fg: #fff;
  --card-bg: #fff;
}

html.theme-ocean {
  --bg: #0b1c2c;
  --surface: #0f2940;
  --border: rgba(14,165,233,.28);
  --text: #f0f9ff;
  --text-muted: rgba(240,249,255,.84);
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --accent: #2dd4bf;
  --danger: #fb7185;
  --success: #2dd4bf;
  --topbar-bg: rgba(11,28,44,.95);
  --topbar-fg: #7dd3fc;
  --menu-bg: #0f2940;
  --menu-header: linear-gradient(135deg,#0c4a6e,#0e7490);
  --menu-header-fg: #e0f2fe;
  --card-bg: #0f2940;
}
html.theme-ocean.mode-day {
  --bg: #eef6f8;
  --surface: #fff;
  --border: rgba(14,116,144,.12);
  --text: #0f2940;
  --text-muted: #475569;
  --primary: #0369a1;
  --primary-dark: #0c4a6e;
  --accent: #0f766e;
  --danger: #f43f5e;
  --success: #14b8a6;
  --topbar-bg: #f0f9fb;
  --topbar-fg: #0e4c6a;
  --menu-bg: #f0f9fb;
  --menu-header: linear-gradient(135deg,#0c4a6e,#0e7490);
  --menu-header-fg: #e0f2fe;
  --card-bg: #fff;
}

/* بدنه — بدون background-attachment:fixed (سنگین روی موبایل) */
html.theme-pro body, html.theme-pro,
html.theme-neon body, html.theme-neon,
html.theme-ocean body, html.theme-ocean {
  background-color: var(--bg);
  color: var(--text);
}

html.theme-pro body {
  background-image:
    linear-gradient(rgba(245,196,0,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,196,0,.03) 1px, transparent 1px);
  background-size: 28px 28px;
}
html.theme-pro.mode-day body {
  background-image:
    linear-gradient(rgba(37,99,235,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.04) 1px, transparent 1px);
  background-size: 28px 28px;
}
html.theme-neon body {
  background-image: radial-gradient(ellipse 80% 40% at 20% 0%, rgba(168,85,247,.12), transparent 50%);
}
html.theme-neon.mode-day body {
  background-image: radial-gradient(ellipse 80% 40% at 20% 0%, rgba(168,85,247,.08), transparent 50%);
}
html.theme-ocean body {
  background-image: radial-gradient(ellipse 90% 50% at 0% 0%, rgba(14,165,233,.12), transparent 50%);
}
html.theme-ocean.mode-day body {
  background-image: radial-gradient(ellipse 90% 50% at 0% 0%, rgba(14,165,233,.08), transparent 50%);
}

/* هدر / منو / کارت / پایین — یک لایه با متغیر */
html[class*="theme-"] #topBar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: none; /* سنگین روی WebView */
}
html[class*="theme-"] #topBar h1,
html[class*="theme-"] #menuButton,
html[class*="theme-"] #viewToggle,
html[class*="theme-"] #searchToggle,
html[class*="theme-"] #sortToggle,
html[class*="theme-"] .topBarActions > div {
  color: var(--topbar-fg);
}

html[class*="theme-"] #sideMenu {
  background: var(--menu-bg);
  color: var(--text);
  box-shadow: 6px 0 24px rgba(0,0,0,.3);
}
html[class*="theme-"] #sideMenuHeader {
  background: var(--menu-header);
  color: var(--menu-header-fg);
  border-bottom: 2px solid var(--primary);
}
html[class*="theme-"] #sideMenuHeader .menu-user-name,
html[class*="theme-"] #sideMenuHeader .menu-user-tag {
  color: inherit;
}
html[class*="theme-"] #sideMenu nav a.menu-link,
html[class*="theme-"] #sideMenu .menu-parent {
  color: var(--text);
  border-bottom: none;
}
html[class*="theme-"] #sideMenu .menu-ico {
  color: var(--accent);
}
html[class*="theme-"] #sideMenu nav a.menu-link.active,
html[class*="theme-"] #sideMenu nav a.menu-link:active,
html[class*="theme-"] #sideMenu .menu-parent:active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}

html[class*="theme-"] .card,
html[class*="theme-"] .panel,
html[class*="theme-"] .list-card,
html[class*="theme-"] .grid-card,
html[class*="theme-"] .compact-card,
html[class*="theme-"] #itemList > div,
html[class*="theme-"] #folderList .card,
html[class*="theme-"] #customerList > div {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text);
}

html[class*="theme-"] #bottomButtons,
html[class*="theme-"] .bulk-bar,
html[class*="theme-"] .search-bar {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

html[class*="theme-"] #contextMenu,
html[class*="theme-"] .overlay,
html[class*="theme-"] .sheet,
html[class*="theme-"] .popup {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

html[class*="theme-"] input,
html[class*="theme-"] textarea,
html[class*="theme-"] select,
html[class*="theme-"] .search-bar input {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

html[class*="theme-"] .btn-primary {
  background: var(--primary);
  color: #0b1220;
}
html.theme-pro.mode-day .btn-primary,
html.theme-neon .btn-primary,
html.theme-ocean .btn-primary {
  color: #fff;
}
html.theme-pro:not(.mode-day) .btn-primary {
  color: #0b1220;
}
html.theme-neon:not(.mode-day) .btn-primary {
  background: linear-gradient(90deg,#a855f7,#6366f1);
  color: #fff;
}

html[class*="theme-"] .btn-neutral {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

html[class*="theme-"] .card.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}
html[class*="theme-"] .fav-folder-card {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
html[class*="theme-"] .folder-grid .subfolder-card {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

/* منوی کناری — چیدمان آیکون (سبک) */
#sideMenu nav a.menu-link,
#sideMenu .menu-parent {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  margin: 2px 10px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
#sideMenu .menu-label { flex: 1; text-align: right; }
#sideMenu .menu-ico {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#sideMenu .menu-ico svg { width: 20px; height: 20px; display: block; }
#sideMenu .menu-children { display: none; padding: 0 8px 6px; }
#sideMenu .menu-group.open > .menu-children { display: block; }
#sideMenu .menu-arrow { opacity: .55; transition: transform .15s; }
#sideMenu .menu-group.open > .menu-parent .menu-arrow { transform: rotate(-90deg); }
#sideMenu .menu-children a.menu-link {
  padding: 10px 14px;
  margin: 1px 6px 1px 18px;
  font-size: 13.5px;
  font-weight: 500;
}
#sideMenu .menu-plus { width: 18px; height: 18px; display: inline-flex; color: var(--primary); }
#sideMenu .menu-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border); flex-shrink: 0; margin: 0 6px;
}


/* ===== CONTRAST FIX ===== */
/* متن همیشه خوانا روی کارت و لیست */
html[class*="theme-"] .card,
html[class*="theme-"] .grid-card,
html[class*="theme-"] .compact-card,
html[class*="theme-"] .panel,
html[class*="theme-"] .list-card,
html[class*="theme-"] .label,
html[class*="theme-"] .grid-label,
html[class*="theme-"] .menu-label {
  color: var(--text) !important;
}
html[class*="theme-"] .grid-count,
html[class*="theme-"] .compact-count,
html[class*="theme-"] .sort-label,
html[class*="theme-"] .chevron,
html[class*="theme-"] small,
html[class*="theme-"] .text-muted {
  color: var(--text-muted) !important;
  opacity: 1;
}

/* دکمه برگشت / خنثی — واضح و پررنگ */
html[class*="theme-"] .btn-neutral {
  background: color-mix(in srgb, var(--text) 14%, var(--surface)) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  font-weight: 700 !important;
  opacity: 1 !important;
}
html.theme-pro:not(.mode-day) .btn-neutral,
html.theme-neon:not(.mode-day) .btn-neutral,
html.theme-ocean:not(.mode-day) .btn-neutral {
  background: rgba(255,255,255,0.12) !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255,255,255,0.22) !important;
}
html.theme-pro.mode-day .btn-neutral,
html.theme-neon.mode-day .btn-neutral,
html.theme-ocean.mode-day .btn-neutral {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

/* جلوگیری از سفید روی سفید در المان‌های ثابت قدیمی */
html[class*="theme-"] #bottomButtons button {
  opacity: 1;
}
html[class*="theme-"] .btn-primary {
  font-weight: 700;
}
/* متن دکمه primary روی زرد ادیسون شب تیره بماند */
html.theme-pro:not(.mode-day) .btn-primary {
  color: #0b1220 !important;
}
/* primary روشن با متن سفید */
html.theme-pro.mode-day .btn-primary,
html.theme-ocean .btn-primary {
  color: #fff !important;
}
html.theme-neon .btn-primary {
  color: #fff !important;
}

/* اورلی و منوی زمینه */
html[class*="theme-"] .overlay,
html[class*="theme-"] .overlay-header,
html[class*="theme-"] #contextMenu,
html[class*="theme-"] #contextMenu div {
  color: var(--text) !important;
}
html[class*="theme-"] #contextMenu div.danger {
  color: var(--danger) !important;
}

/* ورودی‌ها */
html[class*="theme-"] input,
html[class*="theme-"] textarea,
html[class*="theme-"] select {
  color: var(--text) !important;
  background: var(--bg) !important;
}
html[class*="theme-"] input::placeholder,
html[class*="theme-"] textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.85;
}

/* لینک‌ها و عناوین */
html[class*="theme-"] a:not(.tool):not(.menu-link) {
  color: var(--primary);
}
html[class*="theme-"] h1,
html[class*="theme-"] h2,
html[class*="theme-"] h3 {
  color: inherit;
}


/* ===== JOB CARDS + MENU NIGHT FIX ===== */
/* روز / بدون تم: متن تیره روی کارت‌های پاستلی */
html:not([class*="theme-"]) .job-card,
html:not([class*="theme-"]) .job-list-item.card,
html:not([class*="theme-"]) .card.job-list-item,
html.mode-day .job-card,
html.mode-day .job-list-item.card,
html.mode-day .card.job-list-item {
  color: #0f172a !important;
}
html:not([class*="theme-"]) .job-card .job-card-title,
html:not([class*="theme-"]) .job-list-item .label,
html:not([class*="theme-"]) .job-list-item .label strong,
html.mode-day .job-card .job-card-title,
html.mode-day .job-list-item .label,
html.mode-day .job-list-item .label strong {
  color: #0f172a !important;
}
html:not([class*="theme-"]) .job-card .job-card-meta,
html:not([class*="theme-"]) .job-card .job-card-desc,
html:not([class*="theme-"]) .job-list-item small,
html.mode-day .job-card .job-card-meta,
html.mode-day .job-card .job-card-desc,
html.mode-day .job-list-item small {
  color: #334155 !important;
}
/* شب: کارت تیره → متن روشن */
html.theme-pro:not(.mode-day) .job-card,
html.theme-neon:not(.mode-day) .job-card,
html.theme-ocean:not(.mode-day) .job-card,
html.theme-pro:not(.mode-day) .job-list-item,
html.theme-neon:not(.mode-day) .job-list-item,
html.theme-ocean:not(.mode-day) .job-list-item,
html.theme-pro:not(.mode-day) .card.job-list-item,
html.theme-neon:not(.mode-day) .card.job-list-item,
html.theme-ocean:not(.mode-day) .card.job-list-item {
  color: var(--text) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
html.theme-pro:not(.mode-day) .job-card .job-card-title,
html.theme-neon:not(.mode-day) .job-card .job-card-title,
html.theme-ocean:not(.mode-day) .job-card .job-card-title,
html.theme-pro:not(.mode-day) .job-list-item .label,
html.theme-neon:not(.mode-day) .job-list-item .label,
html.theme-ocean:not(.mode-day) .job-list-item .label,
html.theme-pro:not(.mode-day) .job-list-item .label strong,
html.theme-neon:not(.mode-day) .job-list-item .label strong,
html.theme-ocean:not(.mode-day) .job-list-item .label strong {
  color: var(--text) !important;
}
html.theme-pro:not(.mode-day) .job-card .job-card-meta,
html.theme-neon:not(.mode-day) .job-card .job-card-meta,
html.theme-ocean:not(.mode-day) .job-card .job-card-meta,
html.theme-pro:not(.mode-day) .job-card .job-card-desc,
html.theme-neon:not(.mode-day) .job-card .job-card-desc,
html.theme-ocean:not(.mode-day) .job-card .job-card-desc,
html.theme-pro:not(.mode-day) .job-list-item small,
html.theme-neon:not(.mode-day) .job-list-item small,
html.theme-ocean:not(.mode-day) .job-list-item small {
  color: var(--text-muted) !important;
}
/* بج وضعیت: همیشه متن تیره روی پس‌زمینه پاستلی */
.status-badge {
  font-weight: 700;
}
html[class*="theme-"]:not(.mode-day) .status-badge.job-new,
html[class*="theme-"]:not(.mode-day) .status-badge.job-todo { background: #93c5fd; color: #0f172a !important; }
html[class*="theme-"]:not(.mode-day) .status-badge.job-done { background: #86efac; color: #14532d !important; }
html[class*="theme-"]:not(.mode-day) .status-badge.job-postponed { background: #fde047; color: #713f12 !important; }
html[class*="theme-"]:not(.mode-day) .status-badge.job-cancelled { background: #fca5a5; color: #7f1d1d !important; }


/* زیرمنوی همبرگری — هرگز سفید مطلق در تم شب */
html[class*="theme-"] #sideMenu .menu-children,
html[class*="theme-"] #sideMenu .menu-children a.menu-link,
html[class*="theme-"] #sideMenu .menu-group.open > .menu-children {
  background: transparent !important;
  color: var(--text) !important;
}
html[class*="theme-"] #sideMenu .menu-children a.menu-link {
  background: transparent !important;
  color: var(--text) !important;
}
html[class*="theme-"] #sideMenu .menu-children a.menu-link:active,
html[class*="theme-"] #sideMenu .menu-children a.menu-link.active {
  background: color-mix(in srgb, var(--primary) 16%, transparent) !important;
  color: var(--primary) !important;
}
/* جلوگیری از پس‌زمینه سفید ارثی */
#sideMenu .menu-children a,
#sideMenu .menu-children a:visited {
  background: transparent !important;
  color: inherit !important;
}
html.theme-pro:not(.mode-day) #sideMenu .menu-children a.menu-link,
html.theme-neon:not(.mode-day) #sideMenu .menu-children a.menu-link,
html.theme-ocean:not(.mode-day) #sideMenu .menu-children a.menu-link {
  color: var(--text) !important;
  background: transparent !important;
}
html.theme-pro:not(.mode-day) #sideMenu .menu-children a.menu-link:active,
html.theme-neon:not(.mode-day) #sideMenu .menu-children a.menu-link:active,
html.theme-ocean:not(.mode-day) #sideMenu .menu-children a.menu-link:active,
html.theme-pro:not(.mode-day) #sideMenu .menu-children a.menu-link.active,
html.theme-neon:not(.mode-day) #sideMenu .menu-children a.menu-link.active,
html.theme-ocean:not(.mode-day) #sideMenu .menu-children a.menu-link.active {
  background: rgba(245,196,0,0.12) !important;
  color: var(--primary) !important;
}

/* === NIGHT CONTRAST FIX v3 === */
/*
 * حالت شب پایدار:
 * - html/body[data-mode="night"] و .mode-night
 * - متغیرها از theme.js با setProperty هم ست می‌شوند
 */

html[data-mode="night"],
html.mode-night {
  color-scheme: dark;
}

/* متن پایه */
html[data-mode="night"] body,
html.mode-night body,
body[data-mode="night"],
body.mode-night {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}

html[data-mode="night"] body *,
html.mode-night body *,
body[data-mode="night"] *,
body.mode-night * {
  border-color: color-mix(in srgb, var(--border) 100%, transparent);
}

/* تیترها و متن‌های اصلی */
html[data-mode="night"] h1,
html[data-mode="night"] h2,
html[data-mode="night"] h3,
html[data-mode="night"] h4,
html[data-mode="night"] .header h1,
html[data-mode="night"] .overlay-header,
html[data-mode="night"] .field-label,
html[data-mode="night"] label,
html[data-mode="night"] .label,
html[data-mode="night"] .sec-title,
html[data-mode="night"] strong,
html[data-mode="night"] b,
html[data-mode="night"] .card,
html[data-mode="night"] .panel,
html[data-mode="night"] .list-card,
html[data-mode="night"] p,
html[data-mode="night"] span,
html[data-mode="night"] div,
html.mode-night h1,
html.mode-night h2,
html.mode-night h3,
html.mode-night .header h1,
html.mode-night .card,
html.mode-night label,
html.mode-night .label,
html.mode-night .sec-title {
  color: var(--text);
}

/* muted */
html[data-mode="night"] small,
html[data-mode="night"] .muted,
html[data-mode="night"] .text-muted,
html[data-mode="night"] .hint,
html[data-mode="night"] .meta,
html[data-mode="night"] .sub,
html[data-mode="night"] .empty,
html.mode-night small,
html.mode-night .muted,
html.mode-night .text-muted {
  color: var(--text-muted) !important;
}

/* هدر */
html[data-mode="night"] .header,
html.mode-night .header {
  background: var(--topbar-bg) !important;
  border-bottom: 1px solid var(--border) !important;
}
html[data-mode="night"] .header h1,
html[data-mode="night"] .header .icon-btn,
html.mode-night .header h1,
html.mode-night .header .icon-btn {
  color: var(--topbar-fg) !important;
  opacity: 1 !important;
}

/* کارت‌ها */
html[data-mode="night"] .card,
html[data-mode="night"] .panel,
html[data-mode="night"] .list-card,
html[data-mode="night"] .grid-card,
html[data-mode="night"] .compact-card,
html[data-mode="night"] .inv-card,
html[data-mode="night"] .job-card,
html[data-mode="night"] .job-list-item,
html[data-mode="night"] .customer-card,
html.mode-night .card,
html.mode-night .inv-card,
html.mode-night .job-card,
html.mode-night .job-list-item {
  background: var(--card-bg) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
html[data-mode="night"] .job-card .job-card-title,
html[data-mode="night"] .job-list-item .label,
html[data-mode="night"] .job-list-item .label strong,
html[data-mode="night"] .job-card .job-card-meta,
html[data-mode="night"] .job-card .job-card-desc,
html[data-mode="night"] .job-list-item small,
html.mode-night .job-card .job-card-title,
html.mode-night .job-list-item .label {
  color: var(--text) !important;
}
html[data-mode="night"] .job-card .job-card-meta,
html[data-mode="night"] .job-list-item small,
html.mode-night .job-card-meta {
  color: var(--text-muted) !important;
}

/* فاکتور وضعیت‌ها در شب */
html[data-mode="night"] .inv-card.inv-open {
  background: var(--card-bg) !important;
  color: var(--text) !important;
}
html[data-mode="night"] .inv-card.inv-paid {
  background: color-mix(in srgb, #16a34a 25%, var(--surface)) !important;
  color: var(--text) !important;
}
html[data-mode="night"] .inv-card.inv-overdue {
  background: color-mix(in srgb, #dc2626 25%, var(--surface)) !important;
  color: var(--text) !important;
}
html[data-mode="night"] .inv-card.st-progress,
html[data-mode="night"] .inv-card.inv-partial {
  background: color-mix(in srgb, #f59e0b 25%, var(--surface)) !important;
  color: var(--text) !important;
}

/* اینپوت */
html[data-mode="night"] input,
html[data-mode="night"] textarea,
html[data-mode="night"] select,
html.mode-night input,
html.mode-night textarea,
html.mode-night select {
  background: var(--bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
html[data-mode="night"] input::placeholder,
html[data-mode="night"] textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 1;
}

/* منو / اورلی */
html[data-mode="night"] #sideMenu,
html[data-mode="night"] #contextMenu,
html[data-mode="night"] .overlay,
html[data-mode="night"] .sheet,
html[data-mode="night"] .popup,
html.mode-night #sideMenu,
html.mode-night .overlay,
html.mode-night #contextMenu {
  background: var(--menu-bg, var(--surface)) !important;
  color: var(--text) !important;
}
html[data-mode="night"] #sideMenu .menu-label,
html[data-mode="night"] #sideMenu .menu-parent,
html[data-mode="night"] #sideMenu a.menu-link,
html[data-mode="night"] #contextMenu div {
  color: var(--text) !important;
}

/* چیپ */
html[data-mode="night"] .chip,
html[data-mode="night"] .tab-btn {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* دکمه‌ها */
html[data-mode="night"] .btn-neutral {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
html[data-mode="night"] .btn-primary {
  color: #0b1220 !important;
}
html.theme-neon[data-mode="night"] .btn-primary,
html.theme-ocean[data-mode="night"] .btn-primary {
  color: #fff !important;
}

/* شکستن رنگ‌های هاردکد رایج در حالت شب */
html[data-mode="night"] [style*="color:#111"],
html[data-mode="night"] [style*="color: #111"],
html[data-mode="night"] [style*="color:#111827"],
html[data-mode="night"] [style*="color: #111827"],
html[data-mode="night"] [style*="color:#0f172a"],
html[data-mode="night"] [style*="color: #0f172a"],
html[data-mode="night"] [style*="color:#1e293b"],
html[data-mode="night"] [style*="color: #1e293b"],
html[data-mode="night"] [style*="color:#152033"],
html[data-mode="night"] [style*="color:#222"],
html[data-mode="night"] [style*="color:#333"],
html[data-mode="night"] [style*="color:#374151"],
html[data-mode="night"] [style*="color: #374151"] {
  color: var(--text) !important;
}
html[data-mode="night"] [style*="color:#666"],
html[data-mode="night"] [style*="color: #666"],
html[data-mode="night"] [style*="color:#6b7280"],
html[data-mode="night"] [style*="color: #6b7280"],
html[data-mode="night"] [style*="color:#64748b"],
html[data-mode="night"] [style*="color: #64748b"],
html[data-mode="night"] [style*="color:#94a3b8"],
html[data-mode="night"] [style*="color: #94a3b8"],
html[data-mode="night"] [style*="color:#9ca3af"],
html[data-mode="night"] [style*="color: #9ca3af"] {
  color: var(--text-muted) !important;
}
html[data-mode="night"] [style*="background:#fff"],
html[data-mode="night"] [style*="background: #fff"],
html[data-mode="night"] [style*="background:#ffffff"],
html[data-mode="night"] [style*="background: #ffffff"],
html[data-mode="night"] [style*="background:white"],
html[data-mode="night"] [style*="background: white"] {
  background: var(--surface) !important;
  color: var(--text) !important;
}
html[data-mode="night"] [style*="border-bottom:1px solid #e5e7eb"],
html[data-mode="night"] [style*="border-bottom: 1px solid #e5e7eb"] {
  border-bottom-color: var(--border) !important;
}

/* بج وضعیت — متن تیره روی پاستل */
html[data-mode="night"] .status-badge.job-new,
html[data-mode="night"] .status-badge.job-todo { background: #93c5fd !important; color: #0f172a !important; }
html[data-mode="night"] .status-badge.job-done { background: #86efac !important; color: #14532d !important; }
html[data-mode="night"] .status-badge.job-postponed { background: #fde047 !important; color: #713f12 !important; }
html[data-mode="night"] .status-badge.job-cancelled { background: #fca5a5 !important; color: #7f1d1d !important; }

/* لیست دستمزد */
html[data-mode="night"] #folderList .label,
html[data-mode="night"] #folderList .grid-label,
html[data-mode="night"] #itemList .label {
  color: var(--text) !important;
}
html[data-mode="night"] #folderList small,
html[data-mode="night"] #itemList small,
html[data-mode="night"] #folderList .grid-count {
  color: var(--text-muted) !important;
}


/* bottom-nav sheet fix */
.sheet-overlay, .sheet-overlay.open { z-index: 12000 !important; }
body.sheet-open .ost-bottom-nav { display: none !important; }


/* ctx-menu-fix */
.card, .grid-card, .compact-card, .list-card, .job-card, .job-list-item,
.customer-card, .worker-card, .inv-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#contextMenu, #subFolderContextMenu, .context-menu {
  z-index: 15000 !important;
  max-height: min(70vh, 420px) !important;
  overflow-y: auto !important;
}


/* فاکتور چاپی از تم شب مستثنی */
html.mode-night body.inv-view-print-only #doc .inv-print,
html.mode-night body.inv-view-print-only #doc .invoice-box,
html[data-mode="night"] body.inv-view-print-only #doc .inv-print,
html[data-mode="night"] body.inv-view-print-only #doc .invoice-box {
  color: #0f172a !important;
  background: #fff !important;
}
html.mode-night body.inv-view-print-only #doc .inv-print *,
html.mode-night body.inv-view-print-only #doc .invoice-box *,
html[data-mode="night"] body.inv-view-print-only #doc .inv-print *,
html[data-mode="night"] body.inv-view-print-only #doc .invoice-box * {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  opacity: 1 !important;
}
html.mode-night body.inv-view-print-only #doc .inv-print [style*="color:#fff"],
html.mode-night body.inv-view-print-only #doc .inv-print [style*="color: #fff"],
html[data-mode="night"] body.inv-view-print-only #doc .inv-print [style*="color:#fff"],
html[data-mode="night"] body.inv-view-print-only #doc .inv-print [style*="color: #fff"] {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}
