/* BiteBoard sitewide dark mode — toggle via html[data-theme="dark"] */

html[data-theme="dark"] {
    color-scheme: dark;
    --bb-bg: #0d1117;
    --bb-bg-soft: #111827;
    --bb-surface: #161b22;
    --bb-surface-2: #21262d;
    --bb-surface-hover: #1c2430;
    --bb-border: #30363d;
    --bb-border-soft: #3d444d;
    --bb-text: #e6edf3;
    --bb-text-secondary: #c9d1d9;
    --bb-muted: #8b949e;
    --bb-accent: #818cf8;
    --bb-accent-hover: #6366f1;
    --bb-accent-soft: rgba(129, 140, 248, 0.15);
    --bb-success: #3fb950;
    --bb-danger: #f85149;
    --bb-warning: #d29922;
    --bb-input-bg: #0d1117;
    --bb-shadow: rgba(0, 0, 0, 0.35);
}

/* ── Sidebar theme toggle (visible on sidebar hover only) ── */
.sidebar-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    color: #374151;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, background 0.15s, border-color 0.15s, color 0.15s;
}
.sidebar:hover .sidebar-theme-toggle {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.sidebar-theme-toggle:hover {
    background: #f3f4f6;
    color: #111827;
}
.sidebar-theme-toggle i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}
.theme-icon-when-dark { display: none; }
html[data-theme="dark"] .theme-icon-when-light { display: none; }
html[data-theme="dark"] .theme-icon-when-dark { display: inline-block; }
html[data-theme="dark"] .sidebar-theme-toggle {
    background: var(--bb-surface-2);
    border-color: var(--bb-border);
    color: var(--bb-text-secondary);
}
html[data-theme="dark"] .sidebar-theme-toggle:hover {
    background: var(--bb-surface-hover);
    color: var(--bb-text);
}

.sidebar.collapsed .sidebar-theme-toggle .theme-toggle-label { display: none; }
.sidebar.collapsed:hover .sidebar-theme-toggle .theme-toggle-label { display: inline; }
.sidebar.collapsed .sidebar-theme-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed:hover .sidebar-theme-toggle { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }

/* ── Global base ── */
html[data-theme="dark"] body {
    background: var(--bb-bg) !important;
    color: var(--bb-text) !important;
}

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
    border-color: var(--bb-accent) !important;
    box-shadow: 0 0 0 3px var(--bb-accent-soft) !important;
}

/* ── Sidebar & nav ── */
html[data-theme="dark"] .sidebar {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .sidebar-brand {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .sidebar-brand a {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .sidebar-brand a i {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .sidebar-footer {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .app-tab {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .app-tab:hover {
    background: var(--bb-surface-2) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .app-tab i {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .app-tab:hover i {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .app-tab.active {
    background: var(--bb-accent-hover) !important;
    color: #fff !important;
}
html[data-theme="dark"] .app-tab.active i {
    color: #fff !important;
}
html[data-theme="dark"] .dashboard-tab {
    background: var(--bb-accent-hover) !important;
    color: #fff !important;
}
html[data-theme="dark"] .dashboard-tab:hover {
    background: var(--bb-accent) !important;
}
html[data-theme="dark"] .header-stat {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .header-stat p {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .sidebar-footer a[href="/staff/logout"] {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .sidebar-footer a[href="/staff/logout"]:hover {
    color: var(--bb-text) !important;
}

/* ── Main content / cards / tables ── */
html[data-theme="dark"] .main-wrap,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .main {
    color: var(--bb-text);
}
html[data-theme="dark"] .page-title {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .page-title i {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .list-card,
html[data-theme="dark"] .orders-wrap,
html[data-theme="dark"] .co-card,
html[data-theme="dark"] .login-card {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 1px 3px var(--bb-shadow) !important;
}
html[data-theme="dark"] th {
    background: var(--bb-surface-2) !important;
    color: var(--bb-muted) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] td {
    color: var(--bb-text-secondary) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] tbody tr.data-row:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] tr.data-row.expanded,
html[data-theme="dark"] .orders-wrap tbody tr.data-row.expanded {
    background: var(--bb-accent-soft) !important;
}
html[data-theme="dark"] tr.details-row td,
html[data-theme="dark"] .orders-wrap tr.details-row td {
    background: var(--bb-bg-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .details-inner {
    color: var(--bb-text-secondary);
}
html[data-theme="dark"] .detail-section h4,
html[data-theme="dark"] .order-info-group-title {
    color: var(--bb-muted) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .line-title,
html[data-theme="dark"] .line-price {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .line-sku,
html[data-theme="dark"] .line-meta,
html[data-theme="dark"] .order-date,
html[data-theme="dark"] .detail-empty {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .line-props li {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .line-props li strong {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .detail-line {
    border-color: var(--bb-border) !important;
}

/* ── Toolbar / buttons ── */
html[data-theme="dark"] .search-box input {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .search-box i {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .count-pill {
    background: var(--bb-accent-soft) !important;
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .btn-secondary {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .btn-ghost:hover,
html[data-theme="dark"] .btn-secondary:hover {
    background: var(--bb-surface-hover) !important;
    color: var(--bb-text) !important;
}

/* ── Order info panels ── */
html[data-theme="dark"] .order-info-panel {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .order-info-field label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .order-info-value,
html[data-theme="dark"] .order-info-note-input,
html[data-theme="dark"] .order-info-note-field,
html[data-theme="dark"] .order-info-note-raw,
html[data-theme="dark"] .order-info-attr-input {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .order-info-value.empty {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .order-info-note {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .info-kv {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .info-kv strong {
    color: var(--bb-muted) !important;
}

/* ── Customers page ── */
html[data-theme="dark"] .controls-bar {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .control-label,
html[data-theme="dark"] .filter-check {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .control-select,
html[data-theme="dark"] .cu-type-tag-select,
html[data-theme="dark"] .cu-edit-input,
html[data-theme="dark"] .cu-edit-textarea,
html[data-theme="dark"] .cu-edit-select {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .cu-type-tag-select.pending,
html[data-theme="dark"] .cu-edit-select.pending {
    background: rgba(210, 153, 34, 0.15) !important;
    border-color: rgba(210, 153, 34, 0.45) !important;
    color: #e3b341 !important;
}
html[data-theme="dark"] .cu-type-tag-select.conflict,
html[data-theme="dark"] .cu-type-tag-select.saving {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}

html[data-theme="dark"] .cust-table th,
html[data-theme="dark"] .cust-table th.col-name,
html[data-theme="dark"] .cust-table th.col-expand {
    background: var(--bb-surface-2) !important;
    color: var(--bb-muted) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cust-table td {
    color: var(--bb-text-secondary) !important;
    border-color: var(--bb-border) !important;
    background: transparent !important;
}
html[data-theme="dark"] .cust-table td.col-name,
html[data-theme="dark"] .cust-table td.col-expand {
    background: var(--bb-surface) !important;
}
html[data-theme="dark"] .cust-table tbody tr.cu-row:hover td,
html[data-theme="dark"] .cust-table tbody tr.cu-row:hover td.col-name,
html[data-theme="dark"] .cust-table tbody tr.cu-row:hover td.col-expand,
html[data-theme="dark"] .cust-table tbody tr:hover td {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .cust-table tbody tr.cu-row.expanded td,
html[data-theme="dark"] .cust-table tbody tr.cu-row.expanded td.col-name,
html[data-theme="dark"] .cust-table tbody tr.cu-row.expanded td.col-expand,
html[data-theme="dark"] .cust-table tbody tr.cu-row.expanded:hover td,
html[data-theme="dark"] .cust-table tbody tr.cu-row.expanded:hover td.col-name,
html[data-theme="dark"] .cust-table tbody tr.cu-row.expanded:hover td.col-expand {
    background: var(--bb-accent-soft) !important;
}
html[data-theme="dark"] .cust-table tbody tr.row-conflict td,
html[data-theme="dark"] .cust-table tbody tr.row-conflict td.col-name,
html[data-theme="dark"] .cust-table tbody tr.row-conflict td.col-expand {
    background: rgba(248, 81, 73, 0.08) !important;
}
html[data-theme="dark"] .cust-table tbody tr.row-conflict:hover td,
html[data-theme="dark"] .cust-table tbody tr.row-conflict:hover td.col-name,
html[data-theme="dark"] .cust-table tbody tr.row-conflict:hover td.col-expand {
    background: rgba(248, 81, 73, 0.14) !important;
}

html[data-theme="dark"] .cu-detail-row td {
    background: var(--bb-bg-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cu-edit-panel {
    background: transparent !important;
}
html[data-theme="dark"] .cu-edit-field label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .cu-edit-header {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cu-edit-header-title {
    color: var(--bb-text) !important;
}

html[data-theme="dark"] .cust-name {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .cust-email {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .conflict-icon {
    color: var(--bb-danger) !important;
}
html[data-theme="dark"] .type-tag-display .muted-tag {
    color: var(--bb-muted) !important;
}

html[data-theme="dark"] .tag-pill {
    background: var(--bb-surface-2) !important;
    color: var(--bb-text-secondary) !important;
    border: 1px solid var(--bb-border) !important;
}
html[data-theme="dark"] .tag-pill.type-pending {
    background: rgba(210, 153, 34, 0.15) !important;
    color: #e3b341 !important;
    border-color: rgba(210, 153, 34, 0.35) !important;
}
html[data-theme="dark"] .tag-pill.type-trade {
    background: rgba(88, 166, 255, 0.12) !important;
    color: #79c0ff !important;
    border-color: rgba(88, 166, 255, 0.3) !important;
}
html[data-theme="dark"] .tag-pill.type-end-customer {
    background: rgba(63, 185, 80, 0.12) !important;
    color: #3fb950 !important;
    border-color: rgba(63, 185, 80, 0.3) !important;
}
html[data-theme="dark"] .tag-pill.type-unassigned {
    background: var(--bb-surface-2) !important;
    color: var(--bb-muted) !important;
}

html[data-theme="dark"] .cu-expand-btn,
html[data-theme="dark"] .cu-view-orders-btn,
html[data-theme="dark"] .cu-orders-modal-close {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .cu-expand-btn:hover,
html[data-theme="dark"] .cu-view-orders-btn:hover,
html[data-theme="dark"] .cu-orders-modal-close:hover {
    background: var(--bb-surface-hover) !important;
    border-color: var(--bb-border-soft) !important;
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .cu-expand-btn[aria-expanded="true"] {
    background: var(--bb-accent-soft) !important;
    border-color: var(--bb-accent) !important;
    color: var(--bb-accent) !important;
}

html[data-theme="dark"] .empty-row,
html[data-theme="dark"] .state-msg {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .spinner {
    border-color: var(--bb-border) !important;
    border-top-color: var(--bb-accent) !important;
}
html[data-theme="dark"] .error-msg {
    color: var(--bb-danger) !important;
}
html[data-theme="dark"] .alert-banner {
    background: rgba(248, 81, 73, 0.12) !important;
    border-color: rgba(248, 81, 73, 0.35) !important;
    color: #ff7b72 !important;
}

/* Customer orders modal */
html[data-theme="dark"] .cu-orders-modal-panel {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 20px 50px var(--bb-shadow) !important;
}
html[data-theme="dark"] .cu-orders-modal-header {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cu-orders-modal-header h2 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .cu-orders-modal-body {
    background: var(--bb-surface) !important;
    color: var(--bb-text-secondary);
}
html[data-theme="dark"] .cu-orders-modal-body th {
    background: var(--bb-surface-2) !important;
    color: var(--bb-muted) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cu-orders-modal-body td {
    color: var(--bb-text-secondary) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cu-orders-modal-body tbody tr.data-row:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .cu-orders-modal-body tbody tr.data-row.expanded {
    background: var(--bb-accent-soft) !important;
}
html[data-theme="dark"] .cu-orders-modal-body tr.details-row td {
    background: var(--bb-bg-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .cu-orders-modal-body .order-chevron {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .cu-orders-modal-body .state-msg {
    color: var(--bb-muted) !important;
}

/* ── Artwork Updater ── */
html[data-theme="dark"] .main-content {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 1px 3px var(--bb-shadow) !important;
}
html[data-theme="dark"] .left-column,
html[data-theme="dark"] .right-column {
    background: var(--bb-bg-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .left-column {
    border-right-color: var(--bb-border) !important;
}
html[data-theme="dark"] .column-header,
html[data-theme="dark"] .upload-section h3 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .upload-section {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .file-list .loading-state {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .file-list .loading-spinner {
    border-color: var(--bb-border) !important;
    border-top-color: var(--bb-accent) !important;
}

html[data-theme="dark"] .upload-area {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border-soft) !important;
}
html[data-theme="dark"] .upload-area:hover {
    border-color: var(--bb-accent) !important;
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .upload-area.dragover {
    border-color: var(--bb-accent) !important;
    background: var(--bb-accent-soft) !important;
}
html[data-theme="dark"] .upload-area .upload-content i {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .upload-area .upload-content p {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .upload-area .upload-content small {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .upload-progress .progress-bar {
    background: var(--bb-border) !important;
}
html[data-theme="dark"] .upload-progress .progress-text {
    color: var(--bb-text-secondary) !important;
}

html[data-theme="dark"] .file-list .file-item {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .file-list .file-item:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .file-list .file-item .file-name {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .file-list .file-item .file-size,
html[data-theme="dark"] .file-list .file-item .file-type {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .file-list .file-item .file-actions .action-btn:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .file-list .file-item .file-actions .action-btn i {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .file-list .file-item .file-actions .action-btn.delete-btn:hover {
    background: rgba(248, 81, 73, 0.15) !important;
}
html[data-theme="dark"] .file-list .file-item .file-actions .action-btn.delete-btn i {
    color: var(--bb-danger) !important;
}

html[data-theme="dark"] .search-box {
    background: var(--bb-surface-2) !important;
}
html[data-theme="dark"] .search-input {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .refresh-btn:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .filter-select {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}

html[data-theme="dark"] .filename-popup,
html[data-theme="dark"] .terminal-popup {
    background: var(--bb-surface) !important;
    border: 1px solid var(--bb-border) !important;
    color: var(--bb-text) !important;
    box-shadow: 0 25px 50px var(--bb-shadow) !important;
}
html[data-theme="dark"] .filename-header,
html[data-theme="dark"] .terminal-header {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}

/* ── Product Creator (common surfaces) ── */
html[data-theme="dark"] .collapsible-section,
html[data-theme="dark"] .section-content,
html[data-theme="dark"] .form-section,
html[data-theme="dark"] .metafield-box,
html[data-theme="dark"] .price-manager-section,
html[data-theme="dark"] .field-finder-container {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .section-header,
html[data-theme="dark"] .metafield-header,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] label {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .section-header,
html[data-theme="dark"] .metafield-header {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .metafield-table input,
html[data-theme="dark"] .metafield-table td,
html[data-theme="dark"] .metafield-table th {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .metafield-table tr:nth-child(even) td {
    background: var(--bb-surface-2) !important;
}
html[data-theme="dark"] .metafield-table tr:hover td {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .media-upload-area,
html[data-theme="dark"] .file-list,
html[data-theme="dark"] #artworkGuidelinesLeft,
html[data-theme="dark"] #artworkGuidelinesRight {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .media-tab {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .media-tab.active {
    background: var(--bb-accent-hover) !important;
    color: #fff !important;
}
html[data-theme="dark"] .product-loading-popup {
    background: var(--bb-surface) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .result-message.success {
    background: rgba(63, 185, 80, 0.15) !important;
    color: var(--bb-success) !important;
}
html[data-theme="dark"] .result-message.error {
    background: rgba(248, 81, 73, 0.15) !important;
    color: var(--bb-danger) !important;
}

html[data-theme="dark"] .section-title,
html[data-theme="dark"] .parent-child-diagram-section h3 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-card {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 1px 3px var(--bb-shadow) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-card-header {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-card .parent-label,
html[data-theme="dark"] .parent-child-diagram .no-children {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-card .parent-title {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-card .children-list li {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-card .children-list li::before {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-edit-btn {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .parent-child-diagram .diagram-parent-edit-btn:hover {
    background: var(--bb-accent-soft) !important;
    border-color: var(--bb-accent) !important;
    color: var(--bb-accent) !important;
}

html[data-theme="dark"] .autocomplete-dropdown {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 8px 24px var(--bb-shadow) !important;
}
html[data-theme="dark"] .autocomplete-item {
    color: var(--bb-text-secondary) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .autocomplete-item:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .autocomplete-item .product-name {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .autocomplete-item .product-id {
    color: var(--bb-muted) !important;
}

html[data-theme="dark"] .media-preview-container {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .media-preview-header {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .media-count {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .media-preview-item {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .media-preview-item .media-info,
html[data-theme="dark"] .media-preview-item .media-name,
html[data-theme="dark"] .media-preview-item .media-size {
    background: var(--bb-surface) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .shopify-media-header,
html[data-theme="dark"] .shopify-media-item,
html[data-theme="dark"] .media-preview-container .shopify-media-container {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .shopify-media-filename,
html[data-theme="dark"] .shopify-media-meta {
    color: var(--bb-text-secondary) !important;
}

html[data-theme="dark"] .edit-modal-overlay,
html[data-theme="dark"] .duplicate-modal-overlay {
    background: rgba(0, 0, 0, 0.55) !important;
}
html[data-theme="dark"] .edit-modal-overlay > div,
html[data-theme="dark"] .duplicate-modal-overlay > div,
html[data-theme="dark"] .create-from-parent-modal-overlay > div {
    background: var(--bb-surface) !important;
    border: 1px solid var(--bb-border) !important;
    color: var(--bb-text) !important;
    box-shadow: 0 25px 50px var(--bb-shadow) !important;
}
html[data-theme="dark"] .edit-modal-overlay h3,
html[data-theme="dark"] .duplicate-modal-overlay h3,
html[data-theme="dark"] .create-from-parent-modal-overlay h3 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .create-from-parent-modal-overlay p {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] #create-from-parent-list {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
}

html[data-theme="dark"] .pc-image-picker-popup {
    background: var(--bb-surface) !important;
    border: 1px solid var(--bb-border) !important;
    color: var(--bb-text) !important;
    box-shadow: 0 25px 50px var(--bb-shadow) !important;
}
html[data-theme="dark"] .pc-image-picker-popup h3 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .pc-image-picker-option {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .pc-image-picker-popup .pc-image-picker-cancel {
    background: var(--bb-surface-2) !important;
    color: var(--bb-text-secondary) !important;
    border: 1px solid var(--bb-border) !important;
}

html[data-theme="dark"] #product-loading-overlay .product-loading-text {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] #product-loading-overlay .product-loading-spinner {
    border-color: var(--bb-border) !important;
    border-top-color: var(--bb-accent) !important;
}

html[data-theme="dark"] .muted {
    color: var(--bb-muted) !important;
}

/* ── Dashboard home ── */
html[data-theme="dark"] .tool-card {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .tool-card:hover {
    border-color: var(--bb-accent) !important;
    box-shadow: 0 4px 12px var(--bb-shadow) !important;
}
html[data-theme="dark"] .tool-card h3 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .tool-card p {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .loading {
    color: var(--bb-muted) !important;
}

/* ── Staff login ── */
html[data-theme="dark"] .brand,
html[data-theme="dark"] .login-card h1 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .login-card label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .error-msg {
    color: var(--bb-danger) !important;
}

/* ── Client portal ── */
html[data-theme="dark"] .co-tabs {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .co-tab-btn {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .co-tab-btn.co-tab-active {
    color: var(--bb-accent) !important;
    border-color: var(--bb-accent) !important;
}
html[data-theme="dark"] #co-panel-profile,
html[data-theme="dark"] #co-panel-orders {
    color: var(--bb-text);
}
html[data-theme="dark"] .co-profile-field label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .co-profile-field input {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}

/* ── Office tracking ── */
html[data-theme="dark"] .office-tracking {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .office-status-label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .office-status-step.done .office-status-label,
html[data-theme="dark"] .office-status-step.current .office-status-label {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .office-status-step.current .office-status-label {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .office-status-dot {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border-soft) !important;
}
html[data-theme="dark"] .office-status-step.done .office-status-dot,
html[data-theme="dark"] .office-status-step.current .office-status-dot {
    border-color: var(--bb-accent) !important;
}
html[data-theme="dark"] .office-status-step.done .office-status-dot {
    background: var(--bb-accent-hover) !important;
    color: #fff !important;
}
html[data-theme="dark"] .office-status-step.current .office-status-dot {
    background: var(--bb-accent-soft) !important;
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .office-status-connector {
    background: var(--bb-border) !important;
}
html[data-theme="dark"] .office-status-step.done .office-status-connector {
    background: var(--bb-accent-hover) !important;
}
html[data-theme="dark"] .office-file-row,
html[data-theme="dark"] .office-fe-row {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .office-file-name,
html[data-theme="dark"] .office-fe-name {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .office-file-section-title,
html[data-theme="dark"] .office-staff-status-label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .office-tracking-tab {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .office-tracking-tab:hover {
    background: var(--bb-surface-2) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .office-tracking-tab.active {
    color: var(--bb-accent) !important;
    border-color: var(--bb-accent) !important;
}
html[data-theme="dark"] .office-tracking-tabs {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .office-file-explorer {
    background: var(--bb-bg-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .office-fe-folder-head {
    background: var(--bb-surface-2) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .office-stage-select {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .office-upload-btn,
html[data-theme="dark"] .office-fe-refresh-btn {
    background: var(--bb-accent-soft) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .office-btn-changes {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .office-changes-modal-panel {
    background: var(--bb-surface) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .office-changes-modal-panel h3,
html[data-theme="dark"] .office-changes-modal-lead,
html[data-theme="dark"] .office-changes-modal-steps {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .office-changes-contact-or {
    color: var(--bb-text-muted) !important;
}
html[data-theme="dark"] .office-changes-contact-link {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .office-changes-modal-actions .office-btn-changes {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .office-changes-modal-actions .office-btn-set-stage,
html[data-theme="dark"] .office-changes-modal-actions .office-btn-email,
html[data-theme="dark"] .office-changes-modal-actions .office-btn-phone {
    background: var(--bb-accent) !important;
    border-color: var(--bb-accent) !important;
    color: #fff !important;
}

/* ── All Products table ── */
html[data-theme="dark"] .products-grid-wrap,
html[data-theme="dark"] .filter-panel,
html[data-theme="dark"] .product-card {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .product-card-title,
html[data-theme="dark"] .product-card-sku {
    color: var(--bb-text) !important;
}

html[data-theme="dark"] #ap-content .category-card {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 1px 3px var(--bb-shadow) !important;
}
html[data-theme="dark"] #ap-content .category-header {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] #ap-content .category-title {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] #ap-content .category-title.unassigned {
    color: var(--bb-warning) !important;
}
html[data-theme="dark"] #ap-content .category-title.misaligned,
html[data-theme="dark"] #ap-content .category-title.pc-gap {
    color: var(--bb-danger) !important;
}
html[data-theme="dark"] #ap-content .category-count {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] #ap-content .category-header .chev {
    color: var(--bb-muted) !important;
}

html[data-theme="dark"] #ap-content .ap-col-header {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] #ap-content .ap-col-header .col-label {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] #ap-content .ap-col-header .col-label.col-sku,
html[data-theme="dark"] #ap-content .ap-col-header .col-label.col-title,
html[data-theme="dark"] #ap-content .ap-col-header .col-label.col-action,
html[data-theme="dark"] #ap-content .cell-sku,
html[data-theme="dark"] #ap-content .cell-title,
html[data-theme="dark"] #ap-content .cell-action {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] #ap-content .cell-title,
html[data-theme="dark"] #ap-content .ap-col-header .col-label.col-title {
    box-shadow: 8px 0 12px -8px var(--bb-shadow) !important;
}
html[data-theme="dark"] #ap-content .product-row:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] #ap-content .product-row:hover .cell-sku,
html[data-theme="dark"] #ap-content .product-row:hover .cell-title,
html[data-theme="dark"] #ap-content .product-row:hover .cell-action {
    background: var(--bb-surface-hover) !important;
}

html[data-theme="dark"] #ap-content .subcategory-title {
    color: var(--bb-muted) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] #ap-content .subcategory-title .subcat-label {
    background: var(--bb-surface) !important;
}
html[data-theme="dark"] #ap-content .cell {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] #ap-content .cell.muted,
html[data-theme="dark"] #ap-content .cell-locked {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] #ap-content .product-name {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] #ap-content .product-sku.empty {
    color: var(--bb-muted) !important;
    background: var(--bb-surface-2) !important;
}

html[data-theme="dark"] #ap-content .col-edit-btn {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] #ap-content .col-edit-btn:hover,
html[data-theme="dark"] #ap-content .ap-col-header .col-label.editing .col-edit-btn {
    background: var(--bb-accent-soft) !important;
    border-color: var(--bb-accent) !important;
}
html[data-theme="dark"] #ap-content .ap-col-header .col-label.editing {
    color: var(--bb-accent) !important;
}

html[data-theme="dark"] .col-menu {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    box-shadow: 0 10px 30px var(--bb-shadow) !important;
}
html[data-theme="dark"] .col-menu-title {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .col-menu label {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .col-menu label:hover {
    background: var(--bb-surface-hover) !important;
}
html[data-theme="dark"] .col-menu label.locked {
    color: var(--bb-muted) !important;
}

html[data-theme="dark"] .ap-editbar {
    background: var(--bb-accent-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .ap-editbar .eb-label {
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .ap-editbar .eb-label b {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .ap-editbar .eb-hint {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .ap-edit-input,
html[data-theme="dark"] .ap-edit-select {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .ap-emoji-btn {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .ap-emoji-btn.selected {
    background: var(--bb-accent-soft) !important;
    border-color: var(--bb-accent) !important;
}
html[data-theme="dark"] .ap-filters-edit .fg-head {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .ap-filters-edit label {
    color: var(--bb-text-secondary) !important;
}

html[data-theme="dark"] .ap-hscroll-bar {
    background: rgba(13, 17, 23, 0.97) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .pc-gap-intro,
html[data-theme="dark"] .pc-gap-empty {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .pc-gap-group {
    background: rgba(210, 153, 34, 0.1) !important;
    border-color: rgba(210, 153, 34, 0.35) !important;
}
html[data-theme="dark"] .pc-gap-section-title,
html[data-theme="dark"] .pc-gap-group-key {
    color: var(--bb-warning) !important;
}
html[data-theme="dark"] .pc-gap-item {
    border-color: rgba(210, 153, 34, 0.2) !important;
}
html[data-theme="dark"] .pc-gap-item.pc-gap-parent {
    background: var(--bb-accent-soft) !important;
}

/* ── Sitewide modals & popups ── */
html[data-theme="dark"] .modal-overlay,
html[data-theme="dark"] [class*="-modal-overlay"]:not(.edit-modal-overlay):not(.duplicate-modal-overlay):not(.create-from-parent-modal-overlay) {
    background: rgba(0, 0, 0, 0.65) !important;
}
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] [class*="-modal-panel"] {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
    box-shadow: 0 25px 50px var(--bb-shadow) !important;
}
html[data-theme="dark"] .modal-content::before {
    opacity: 0.85;
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .modal-header h3 {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .modal-close {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .modal-close:hover {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .modal-body {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .status-text {
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .progress-bar {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
}

html[data-theme="dark"] .delete-popup {
    background: var(--bb-surface) !important;
    border: 1px solid var(--bb-border) !important;
    box-shadow: 0 25px 50px var(--bb-shadow) !important;
}
html[data-theme="dark"] .delete-content {
    background: var(--bb-surface) !important;
}
html[data-theme="dark"] .delete-message p {
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .file-to-delete {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .file-usage-warning {
    background: rgba(210, 153, 34, 0.12) !important;
    border-color: rgba(210, 153, 34, 0.35) !important;
}
html[data-theme="dark"] .warning-content p,
html[data-theme="dark"] .warning-icon {
    color: var(--bb-warning) !important;
}

/* ── Category editor ── */
html[data-theme="dark"] .category-card,
html[data-theme="dark"] .subcategory-item {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}

/* ── Files page ── */
html[data-theme="dark"] .of-search-box {
    background: var(--bb-input-bg) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .of-search-box:focus-within {
    border-color: var(--bb-accent) !important;
    box-shadow: 0 0 0 3px var(--bb-accent-soft) !important;
}
html[data-theme="dark"] .of-search-box i {
    color: var(--bb-muted) !important;
}
html[data-theme="dark"] .of-search-box input {
    background: transparent !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .of-search-box input::placeholder {
    color: var(--bb-muted) !important;
    opacity: 1;
}
html[data-theme="dark"] .of-panel {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .of-btn-ghost {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .of-btn-ghost:hover {
    background: var(--bb-surface-hover) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .of-stats,
html[data-theme="dark"] .page-desc { color: var(--bb-muted) !important; }
html[data-theme="dark"] .of-order-head:hover,
html[data-theme="dark"] .of-item-head:hover { background: var(--bb-surface-hover) !important; }
html[data-theme="dark"] .of-order-title,
html[data-theme="dark"] .page-title { color: var(--bb-text) !important; }
html[data-theme="dark"] .of-order-sub,
html[data-theme="dark"] .of-item-sub,
html[data-theme="dark"] .of-state { color: var(--bb-muted) !important; }
html[data-theme="dark"] .of-badge {
    background: var(--bb-accent-soft) !important;
    color: var(--bb-accent) !important;
}
html[data-theme="dark"] .of-item {
    background: var(--bb-bg-soft) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .of-file-row {
    background: var(--bb-surface) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .of-file-name { color: var(--bb-text-secondary) !important; }
html[data-theme="dark"] .of-file-link,
html[data-theme="dark"] .of-order-link {
    color: var(--bb-accent) !important;
    border-color: var(--bb-border) !important;
}
html[data-theme="dark"] .of-file-link:hover,
html[data-theme="dark"] .of-order-link:hover { background: var(--bb-accent-soft) !important; }
html[data-theme="dark"] .of-file-delete { color: var(--bb-danger) !important; }
html[data-theme="dark"] .of-file-delete:hover { background: rgba(248, 81, 73, 0.12) !important; }
html[data-theme="dark"] .of-delete-modal-panel {
    background: var(--bb-surface) !important;
    color: var(--bb-text) !important;
}
html[data-theme="dark"] .of-delete-modal-lead { color: var(--bb-text-secondary) !important; }
html[data-theme="dark"] .of-delete-modal-warning { color: var(--bb-danger) !important; }
html[data-theme="dark"] .of-btn-cancel {
    background: var(--bb-surface-2) !important;
    border-color: var(--bb-border) !important;
    color: var(--bb-text-secondary) !important;
}
html[data-theme="dark"] .of-order { border-color: var(--bb-border) !important; }
html[data-theme="dark"] .office-file-delete { color: var(--bb-danger) !important; }
html[data-theme="dark"] .office-delete-modal-warning { color: var(--bb-danger) !important; }
html[data-theme="dark"] .office-btn-danger { background: var(--bb-danger) !important; color: #fff !important; }

/* ── Scrollbars (webkit) ── */
html[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bb-bg);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--bb-border-soft);
    border-radius: 5px;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--bb-muted);
}
