/* ============================================
   DARK MODE THEME - Immo App
   Applied via [data-theme="dark"] on <html>
   ============================================ */

/* Dark mode variable overrides */
[data-theme="dark"] {
    /* Text Colors */
    --immo-text-primary: #F5F5F5;
    --immo-text-secondary: #A0A0B0;
    --immo-text-muted: #5A5A70;
    --immo-text-on-glass: #F5F5F5;
    --immo-heading: #F5F5F5;

    /* Background Colors — aligned with /design.json dark palette */
    --immo-bg-white: #13131A;      /* surface */
    --immo-bg-gray-50: #1C1C26;    /* surface-2 */
    --immo-bg-gray-100: #22222E;   /* surface-3 */
    --immo-bg-gray-200: #2A2A38;   /* elevated surface */
    --immo-bg-gray-light: #1C1C26;
    --table-header: rgba(255, 255, 255, 0.06);
    --immo-body-bg: #0B0B0F;       /* canvas */
    --immo-body-gradient: linear-gradient(135deg, rgba(255, 107, 74, 0.06) 0%, rgba(11, 11, 15, 0.4) 100%);
    --immo-card: #13131A;          /* surface */
    --immo-card-rgb: 19, 19, 26;   /* surface as rgb triplet, for rgba() overlays */
    --immo-side-menu: rgba(11, 11, 15, 0.97);

    /* Primary — brand coral (re-asserted for dark context) */
    --immo-primary: var(--brand-primary);
    --immo-primary-rgb: var(--brand-primary-rgb);

    /* Border Colors */
    --immo-border-light: rgba(255, 255, 255, 0.08);
    --immo-border-medium: rgba(255, 255, 255, 0.15);

    /* Shadows — stronger to stay visible on dark surfaces */
    --immo-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --immo-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --immo-shadow-lg: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
    --immo-shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.6);

    /* Glass effects for dark mode */
    --immo-glass-blue: rgba(var(--immo-blue-rgb), 0.2);
    --immo-glass-green: rgba(var(--immo-green-rgb), 0.2);
    --immo-glass-yellow: rgba(var(--immo-yellow-rgb), 0.2);
    --immo-glass-red: rgba(var(--immo-red-rgb), 0.2);
    --immo-glass-turquoise: rgba(var(--immo-turquoise-rgb), 0.2);
    --immo-glass-grey: rgba(var(--immo-grey-rgb), 0.2);

    /* Alert backgrounds — slightly more opaque for dark bg */
    --immo-alert-success-bg: rgba(var(--immo-green-rgb), 0.15);
    --immo-alert-danger-bg: rgba(var(--immo-red-rgb), 0.15);
    --immo-alert-warning-bg: rgba(var(--immo-yellow-rgb), 0.15);
    --immo-alert-info-bg: rgba(var(--immo-turquoise-rgb), 0.15);
}

/* ---- Body ---- */
[data-theme="dark"] body {
    background: var(--immo-body-gradient), var(--immo-body-bg);
    color: var(--immo-text-primary);
}

/* ---- Main Content Area ---- */
[data-theme="dark"] .immo-main {
    background:
        radial-gradient(ellipse at 0% 0%, rgba(255, 107, 74, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(255, 107, 74, 0.04) 0%, transparent 50%),
        #0B0B0F;
}

/* ---- Cards ----
   .immo-card needs no dark override: its light rule reads --immo-card /
   --immo-border-light / --immo-shadow*, all overridden in this file. */

/* ---- Bootstrap badge overrides ---- */
[data-theme="dark"] .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .badge.bg-light.text-dark {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .bg-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* ---- Detail Page Cards (all *-details-card) ---- */
[data-theme="dark"] .contract-details-card,
[data-theme="dark"] .property-details-card,
[data-theme="dark"] .tenant-details-card,
[data-theme="dark"] .cost-details-card,
[data-theme="dark"] .company-details-card {
    background: var(--immo-bg-white) !important;
    border-color: var(--immo-border-light) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .section-title {
    color: var(--immo-text-muted) !important;
    border-bottom-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .detail-label {
    color: var(--immo-text-secondary) !important;
}

[data-theme="dark"] .detail-value {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .detail-row {
    border-bottom-color: var(--immo-border-light) !important;
}

/* Card side strips — keep colorful on both themes */
[data-theme="dark"] .card-neutral::before {
    background: var(--immo-secondary);
}

/* ---- Bootstrap Cards ---- */
[data-theme="dark"] .card {
    background-color: var(--immo-bg-white) !important;
    border-color: var(--immo-border-light) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .card-header {
    background-color: var(--immo-bg-gray-100) !important;
    border-bottom-color: var(--immo-border-light) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .card-body {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .card-footer {
    background-color: var(--immo-bg-gray-50) !important;
    border-top-color: var(--immo-border-light) !important;
}

/* ---- Bootstrap Solid Buttons (table action buttons, etc.) ---- */
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .immo-btn.btn-secondary {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .immo-btn.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.18) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .btn-info,
[data-theme="dark"] .immo-btn.btn-info {
    background-color: rgba(var(--immo-turquoise-rgb), 0.2) !important;
    border-color: rgba(var(--immo-turquoise-rgb), 0.4) !important;
    color: rgb(var(--immo-turquoise-rgb)) !important;
}

[data-theme="dark"] .btn-info:hover,
[data-theme="dark"] .immo-btn.btn-info:hover {
    background-color: rgba(var(--immo-turquoise-rgb), 0.3) !important;
    border-color: rgb(var(--immo-turquoise-rgb)) !important;
}

/* ---- Tables ---- */
[data-theme="dark"] .immo-table {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
}

[data-theme="dark"] .immo-table th {
    background-color: var(--table-header);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .immo-table td {
    color: var(--immo-text-primary);
    border-bottom: 1px solid var(--immo-border-light);
}

[data-theme="dark"] .immo-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .immo-table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Tree mode in dark theme */
[data-theme="dark"] .tree-toggle {
    color: var(--immo-text-secondary);
}

[data-theme="dark"] .tree-toggle:hover,
[data-theme="dark"] .tree-toggle:focus-visible {
    color: var(--immo-primary);
    background-color: rgba(var(--brand-primary-rgb), 0.15);
}

[data-theme="dark"] .table-tree .tree-child > .tree-cell-first::before {
    background-color: rgba(255, 255, 255, 0.12);
}

/* Bootstrap table-hover override */
[data-theme="dark"] .table-hover tbody tr:hover,
[data-theme="dark"] .table-hover>tbody>tr:hover>* {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: var(--immo-text-primary) !important;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
    --bs-table-accent-bg: rgba(255, 255, 255, 0.06);
}

/* Bootstrap table general */
[data-theme="dark"] .table,
[data-theme="dark"] .table> :not(caption)>*>* {
    color: var(--immo-text-primary);
    border-bottom-color: var(--immo-border-light);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .table>thead {
    color: var(--immo-text-primary);
}

[data-theme="dark"] .table-striped>tbody>tr:nth-of-type(odd)>* {
    background-color: rgba(255, 255, 255, 0.02);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
}

/* ---- Tabulator (Setup Hub spreadsheet) ---- */
[data-theme="dark"] .tabulator {
    background-color: var(--immo-bg-white) !important;
    border-color: var(--immo-border-light) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-header,
[data-theme="dark"] .tabulator-header .tabulator-col {
    background-color: var(--immo-bg-gray-100) !important;
    border-color: var(--immo-border-light) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-row,
[data-theme="dark"] .tabulator-row.tabulator-row-even,
[data-theme="dark"] .tabulator-row.tabulator-row-odd {
    background-color: var(--immo-bg-white) !important;
    border-bottom-color: var(--immo-border-light) !important;
    color: var(--immo-text-primary) !important;
}

/* Override bootstrap5 theme hover (.tabulator-row.tabulator-selectable:hover sets #ced4da) */
html[data-theme="dark"] .tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover,
html[data-theme="dark"] .tabulator-row:hover,
html[data-theme="dark"] .tabulator-row.tabulator-selectable:hover,
html[data-theme="dark"] .tabulator-row.tabulator-selectable.tabulator-row-even:hover,
html[data-theme="dark"] .tabulator-row.tabulator-selectable.tabulator-row-odd:hover,
html[data-theme="dark"] .tabulator-row.tabulator-row-even:hover,
html[data-theme="dark"] .tabulator-row.tabulator-row-odd:hover {
    background-color: #22222E !important;
    color: var(--immo-text-primary) !important;
}

html[data-theme="dark"] .tabulator-row:hover .tabulator-cell,
html[data-theme="dark"] .tabulator-row.tabulator-selectable:hover .tabulator-cell,
html[data-theme="dark"] .tabulator.table .tabulator-row:hover .tabulator-cell {
    background-color: transparent !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-cell {
    color: var(--immo-text-primary) !important;
    border-right-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .tabulator-cell.tabulator-editing {
    border-color: var(--immo-primary) !important;
    background-color: var(--immo-bg-gray-100) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-cell.tabulator-editing input,
[data-theme="dark"] .tabulator-cell.tabulator-editing select,
[data-theme="dark"] .tabulator-cell.tabulator-editing textarea {
    background-color: var(--immo-bg-gray-100) !important;
    color: var(--immo-text-primary) !important;
    border-color: var(--immo-border-medium) !important;
}

/* Tabulator wraps some editors (e.g. list/autocomplete) in nested elements */
[data-theme="dark"] .tabulator-cell.tabulator-editing .tabulator-input-editor,
[data-theme="dark"] .tabulator-cell.tabulator-editing .tabulator-input-editor input {
    background-color: var(--immo-bg-gray-100) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-popup,
[data-theme="dark"] .tabulator-edit-list,
[data-theme="dark"] .tabulator-edit-list .tabulator-edit-list-item {
    background-color: var(--immo-bg-gray-100) !important;
    color: var(--immo-text-primary) !important;
    border-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .tabulator-edit-list .tabulator-edit-list-item.active,
[data-theme="dark"] .tabulator-edit-list .tabulator-edit-list-item:hover {
    background-color: var(--immo-bg-gray-200) !important;
}

[data-theme="dark"] .tabulator-cell.cell-saving {
    background-color: rgba(var(--immo-green-rgb), 0.15) !important;
}

[data-theme="dark"] .tabulator-cell.cell-error {
    background-color: rgba(var(--immo-red-rgb), 0.15) !important;
}

[data-theme="dark"] .tabulator-cell.cell-missing {
    background-color: rgba(var(--immo-yellow-rgb), 0.15) !important;
}

[data-theme="dark"] .tabulator-footer {
    background-color: var(--immo-bg-gray-50) !important;
    border-top-color: var(--immo-border-light) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .tabulator-tableholder {
    background-color: var(--immo-bg-white) !important;
}

/* ---- Setup Hub specific ---- */
[data-theme="dark"] .setup-tabs {
    background: var(--immo-bg-white) !important;
    border-bottom-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .setup-tab {
    color: var(--immo-text-secondary) !important;
}

[data-theme="dark"] .setup-tab:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .setup-tab.active {
    color: white !important;
}

[data-theme="dark"] .setup-tab .tab-badge.empty {
    background: var(--immo-bg-gray-200) !important;
    color: var(--immo-text-muted) !important;
}

[data-theme="dark"] .setup-toolbar {
    background: var(--immo-bg-white) !important;
    border-bottom-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .toolbar-divider {
    background: var(--immo-border-medium) !important;
}

[data-theme="dark"] .spreadsheet-container {
    background: var(--immo-bg-white) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .setup-hint {
    background: linear-gradient(135deg, rgba(var(--immo-yellow-rgb), 0.15), rgba(var(--immo-yellow-rgb), 0.08)) !important;
    border-left-color: rgb(var(--immo-yellow-rgb)) !important;
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .empty-state {
    color: var(--immo-text-muted) !important;
}

[data-theme="dark"] .cell-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .cell-action-btn.delete {
    color: rgb(var(--immo-red-rgb)) !important;
}

[data-theme="dark"] .cell-action-btn.duplicate {
    color: rgb(var(--immo-blue-rgb)) !important;
}

/* Cell validation warning in dark mode */
[data-theme="dark"] .cell-validation-warning {
    background-color: rgba(var(--immo-yellow-rgb), 0.1) !important;
    border-left-color: rgb(var(--immo-yellow-rgb)) !important;
}

/* Table filter controls */
[data-theme="dark"] .table-search-input,
[data-theme="dark"] .table-filter-select {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-medium);
    color: var(--immo-text-primary);
}

/* ---- Forms ---- */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-medium);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-textarea:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-control:focus {
    border-color: var(--immo-primary);
    box-shadow: 0 0 0 3px rgba(var(--immo-primary-rgb), 0.2);
}

[data-theme="dark"] .form-input:disabled,
[data-theme="dark"] .form-textarea:disabled,
[data-theme="dark"] .form-select:disabled {
    background-color: var(--immo-bg-gray-50);
    color: var(--immo-text-muted);
}

[data-theme="dark"] .form-label {
    color: var(--immo-heading);
}

[data-theme="dark"] .form-checkbox {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-medium);
}

/* ---- Buttons ---- */
[data-theme="dark"] .immo-btn {
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .btn-outline-primary {
    border-color: rgba(var(--immo-blue-rgb), 0.5);
}

/* ---- Modals ---- */
[data-theme="dark"] .modal-dialog {
    background: var(--immo-bg-white);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: var(--immo-border-light);
}

[data-theme="dark"] .modal-footer {
    border-top-color: var(--immo-border-light);
}

/* ---- Navigation ---- */
[data-theme="dark"] .immo-sidenav {
    background: var(--immo-side-menu);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* ---- Breadcrumb ---- */
[data-theme="dark"] .immo-breadcrumb {
    background-color: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--immo-border-light);
}

[data-theme="dark"] .breadcrumb-item a {
    color: var(--immo-text-secondary);
}

[data-theme="dark"] .breadcrumb-item.active {
    color: var(--immo-text-primary);
}

/* ---- Bootstrap Overrides ---- */
[data-theme="dark"] .text-dark {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .text-muted {
    color: var(--immo-text-muted) !important;
}

[data-theme="dark"] .text-secondary {
    color: var(--immo-text-secondary) !important;
}

[data-theme="dark"] .bg-white {
    background-color: var(--immo-bg-white) !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--immo-bg-gray-50) !important;
}

[data-theme="dark"] .border {
    border-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .border-bottom {
    border-bottom-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .border-top {
    border-top-color: var(--immo-border-light) !important;
}

[data-theme="dark"] .card {
    background-color: var(--immo-card);
    border-color: var(--immo-border-light);
}

/* ---- Inline style overrides (settings, etc.) ---- */
[data-theme="dark"] [style*="background-color: white"],
[data-theme="dark"] [style*="background: white"] {
    background-color: var(--immo-bg-white) !important;
    background: var(--immo-bg-white) !important;
}

/* Toggle switches in settings */
[data-theme="dark"] .slider {
    background-color: var(--immo-slider-bg);
}

[data-theme="dark"] .slider:before {
    background-color: var(--immo-slider-thumb);
}

/* Reminder items in settings */
[data-theme="dark"] .reminder-item {
    background: var(--immo-bg-white);
}

[data-theme="dark"] .reminder-item:hover {
    background: var(--immo-bg-gray-50);
}

/* ---- Alerts ---- */
[data-theme="dark"] .immo-alert {
    border-color: rgba(255, 255, 255, 0.08);
}

/* ---- Scrollbar ---- */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--immo-bg-white);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--immo-slider-bg);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--immo-text-muted);
}

/* ---- Selection ---- */
[data-theme="dark"] ::selection {
    background: rgba(var(--immo-primary-rgb), 0.3);
    color: #fff;
}

/* ---- Glass Control (Back, Search, Feedback buttons in header) ---- */
[data-theme="dark"] .glass-control {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.2) !important;
    color: var(--immo-text-primary);
}

[data-theme="dark"] .glass-control:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06)) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .glass-control i,
[data-theme="dark"] .glass-control svg {
    color: var(--immo-text-primary) !important;
}

/* ---- Global Search Results Dropdown ---- */
[data-theme="dark"] #global-search-results {
    background-color: var(--immo-bg-white) !important;
    border-color: var(--immo-border-light) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .search-item {
    color: var(--immo-text-primary);
    border-bottom: 1px solid var(--immo-border-light);
}

[data-theme="dark"] .search-item:hover,
[data-theme="dark"] .search-item.active {
    background-color: var(--immo-bg-gray-50);
}

[data-theme="dark"] .search-item .text-dark,
[data-theme="dark"] .search-item .fw-medium {
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .search-item .text-muted {
    color: var(--immo-text-muted) !important;
}

/* ---- Bootstrap Outline Buttons ---- */
[data-theme="dark"] .btn-outline-primary {
    color: rgb(var(--immo-primary-rgb));
    border-color: rgba(var(--immo-primary-rgb), 0.5);
}

[data-theme="dark"] .btn-outline-primary:hover {
    background-color: rgba(var(--immo-primary-rgb), 0.15);
    color: rgb(var(--immo-primary-rgb));
    border-color: rgb(var(--immo-primary-rgb));
}

[data-theme="dark"] .btn-outline-secondary {
    color: var(--immo-text-secondary);
    border-color: var(--immo-border-medium);
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--immo-text-primary);
    border-color: var(--immo-text-secondary);
}

[data-theme="dark"] .btn-outline-success {
    color: rgb(var(--immo-green-rgb));
    border-color: rgba(var(--immo-green-rgb), 0.5);
}

[data-theme="dark"] .btn-outline-success:hover {
    background-color: rgba(var(--immo-green-rgb), 0.15);
    color: rgb(var(--immo-green-rgb));
    border-color: rgb(var(--immo-green-rgb));
}

[data-theme="dark"] .btn-outline-danger {
    color: rgb(var(--immo-red-rgb));
    border-color: rgba(var(--immo-red-rgb), 0.5);
}

[data-theme="dark"] .btn-outline-danger:hover {
    background-color: rgba(var(--immo-red-rgb), 0.15);
    color: rgb(var(--immo-red-rgb));
    border-color: rgb(var(--immo-red-rgb));
}

[data-theme="dark"] .btn-outline-warning {
    color: rgb(var(--immo-yellow-rgb));
    border-color: rgba(var(--immo-yellow-rgb), 0.5);
}

[data-theme="dark"] .btn-outline-warning:hover {
    background-color: rgba(var(--immo-yellow-rgb), 0.15);
    color: rgb(var(--immo-yellow-rgb));
    border-color: rgb(var(--immo-yellow-rgb));
}

/* ---- Close Button (modals, alerts) ---- */
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ---- Table Action Buttons ---- */
[data-theme="dark"] .table-actions .immo-btn {
    color: var(--immo-text-primary);
}

[data-theme="dark"] .table-actions .immo-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* ---- Notifications btn-action ---- */
[data-theme="dark"] .btn-action {
    color: var(--immo-text-secondary);
    border-color: var(--immo-border-medium);
}

[data-theme="dark"] .btn-action:hover {
    color: var(--immo-text-primary);
    background-color: rgba(255, 255, 255, 0.08);
}

/* ---- Bootstrap btn-link ---- */
[data-theme="dark"] .btn-link {
    color: rgb(var(--immo-primary-rgb));
}

/* ---- Command Palette (comprehensive overrides for hardcoded colors) ---- */
[data-theme="dark"] .command-palette-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .command-palette,
[data-theme="dark"] .command-palette-modal,
[data-theme="dark"] .cp-container,
[data-theme="dark"] .cp-modal,
[data-theme="dark"] .cp-dropdown,
[data-theme="dark"] .entry-form-modal,
[data-theme="dark"] .entry-form-container,
[data-theme="dark"] .query-modal,
[data-theme="dark"] .query-container,
[data-theme="dark"] .ai-assistant-modal,
[data-theme="dark"] .ai-chat-container {
    background: var(--immo-bg-white) !important;
    border-color: var(--immo-border-light);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .command-palette-input,
[data-theme="dark"] #command-palette-input,
[data-theme="dark"] .command-input-container textarea,
[data-theme="dark"] .cp-input,
[data-theme="dark"] .cp-search-input,
[data-theme="dark"] .entry-form-input,
[data-theme="dark"] .query-input,
[data-theme="dark"] .ai-chat-input {
    background: var(--immo-bg-gray-50) !important;
    border-color: var(--immo-border-medium);
    color: var(--immo-text-primary) !important;
}

[data-theme="dark"] .command-palette-result:hover,
[data-theme="dark"] .command-palette-result.active,
[data-theme="dark"] .cp-result:hover,
[data-theme="dark"] .cp-result.active {
    background: var(--immo-bg-gray-50);
}

/* Override all hardcoded #1f2937 text in command palette */
[data-theme="dark"] .cp-title,
[data-theme="dark"] .cp-label,
[data-theme="dark"] .cp-heading,
[data-theme="dark"] .cp-result-title,
[data-theme="dark"] .entry-form-label,
[data-theme="dark"] .entry-form-title,
[data-theme="dark"] .query-title,
[data-theme="dark"] .ai-message,
[data-theme="dark"] .command-palette h3,
[data-theme="dark"] .command-palette h4,
[data-theme="dark"] .command-palette label {
    color: var(--immo-text-primary) !important;
}

/* Override all hardcoded #6b7280 / #4b5563 muted text */
[data-theme="dark"] .cp-subtitle,
[data-theme="dark"] .cp-description,
[data-theme="dark"] .cp-hint,
[data-theme="dark"] .cp-result-subtitle,
[data-theme="dark"] .entry-form-hint,
[data-theme="dark"] .query-hint,
[data-theme="dark"] .ai-timestamp,
[data-theme="dark"] .command-palette .text-muted,
[data-theme="dark"] .command-palette small {
    color: var(--immo-text-muted) !important;
}

/* Override hardcoded white backgrounds in AI chat */
[data-theme="dark"] .ai-message-bubble,
[data-theme="dark"] .ai-response-content,
[data-theme="dark"] .entry-form-preview {
    background: var(--immo-bg-gray-50) !important;
    color: var(--immo-text-primary);
    border-color: var(--immo-border-light);
}

/* ---- Breadcrumb (comprehensive overrides for hardcoded colors) ---- */
[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-item+.breadcrumb-item::before {
    color: var(--immo-text-muted);
}

[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-link {
    color: rgb(var(--immo-primary-rgb));
}

[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-link:hover {
    color: var(--brand-primary-light);
}

[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-item.active,
[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-current-text {
    color: var(--immo-text-primary);
}

[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-dropdown-toggle {
    color: rgb(var(--immo-primary-rgb));
}

[data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-dropdown-toggle:hover {
    background-color: rgb(var(--immo-primary-rgb));
    color: white;
}

[data-theme="dark"] .breadcrumb-dropdown-menu {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .breadcrumb-dropdown-menu .dropdown-item {
    color: var(--immo-text-primary);
}

[data-theme="dark"] .breadcrumb-dropdown-menu .dropdown-item:hover {
    background-color: var(--immo-bg-gray-50);
    color: rgb(var(--immo-primary-rgb));
}

[data-theme="dark"] .breadcrumb-dropdown-menu .dropdown-item:active {
    background-color: rgb(var(--immo-primary-rgb));
    color: white;
}

[data-theme="dark"] .breadcrumb-dropdown-menu .dropdown-item-current {
    color: rgb(var(--immo-primary-rgb));
    border-bottom-color: var(--immo-border-light);
    background-color: var(--immo-bg-gray-50);
}

[data-theme="dark"] .breadcrumb-sharing-context {
    background-color: var(--immo-bg-white);
    border-left-color: rgb(var(--immo-primary-rgb));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .sharing-info small {
    color: var(--immo-text-secondary);
}

/* Mobile breadcrumb active items */
@media (max-width: 768px) {

    [data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-item.active,
    [data-theme="dark"] .immo-breadcrumb-nav .breadcrumb-item.active .breadcrumb-current-text {
        color: var(--immo-text-primary);
    }
}

/* Breadcrumb scrollbar */
[data-theme="dark"] .breadcrumb-dropdown-menu {
    scrollbar-color: var(--immo-slider-bg) var(--immo-bg-white);
}

[data-theme="dark"] .breadcrumb-dropdown-menu::-webkit-scrollbar-track {
    background: var(--immo-bg-white);
}

[data-theme="dark"] .breadcrumb-dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--immo-slider-bg);
}

[data-theme="dark"] .breadcrumb-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: var(--immo-text-muted);
}

/* ---- Breadcrumb detail views ---- */
[data-theme="dark"] .breadcrumb-detail,
[data-theme="dark"] .breadcrumb-unit-info {
    background-color: var(--immo-bg-white) !important;
    color: var(--immo-text-primary);
}

/* ---- Misc hardcoded backgrounds ---- */
[data-theme="dark"] .container-fluid {
    color: var(--immo-text-primary);
}

/* Notification dropdown */
[data-theme="dark"] .notification-dropdown {
    background: var(--immo-bg-white);
    border: 1px solid var(--immo-border-light);
    box-shadow: var(--immo-shadow);
}

[data-theme="dark"] .notification-item {
    border-bottom-color: var(--immo-border-light);
}

[data-theme="dark"] .notification-item:hover {
    background: var(--immo-bg-gray-50);
}

/* Form error/help backgrounds */
[data-theme="dark"] .form-error-danger {
    background-color: rgba(254, 74, 73, 0.15);
    border-color: rgba(254, 74, 73, 0.25);
}

[data-theme="dark"] .form-error-warning {
    background-color: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.25);
}

[data-theme="dark"] .form-error-info {
    background-color: rgba(57, 162, 174, 0.15);
    border-color: rgba(57, 162, 174, 0.25);
}

[data-theme="dark"] .form-help {
    background-color: rgba(57, 162, 174, 0.08);
    border-color: rgba(57, 162, 174, 0.15);
}

/* ---- Links ---- */
[data-theme="dark"] a {
    color: rgb(var(--immo-primary-rgb));
}

[data-theme="dark"] a:hover {
    color: var(--brand-primary-light);
}

/* ---- Dropdown menus (Bootstrap) ---- */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
    box-shadow: var(--immo-shadow);
}

[data-theme="dark"] .dropdown-item {
    color: var(--immo-text-primary);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--immo-bg-gray-50);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .dropdown-divider {
    border-top-color: var(--immo-border-light);
}

/* ---- Pagination ---- */
[data-theme="dark"] .page-link {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: rgb(var(--immo-primary-rgb));
    border-color: rgb(var(--immo-primary-rgb));
}

/* ---- Tooltips ---- */
[data-theme="dark"] .tooltip-inner {
    background-color: var(--immo-bg-gray-50);
    color: var(--immo-text-primary);
}

/* ---- Detail page hero sections ---- */
[data-theme="dark"] .detail-header,
[data-theme="dark"] .unit-header,
[data-theme="dark"] .contract-header,
[data-theme="dark"] .tenant-header,
[data-theme="dark"] .cost-header {
    color: var(--immo-text-primary);
}

[data-theme="dark"] .detail-header h1,
[data-theme="dark"] .detail-header h2,
[data-theme="dark"] .unit-header h1,
[data-theme="dark"] .contract-header h1,
[data-theme="dark"] .tenant-header h1 {
    color: var(--immo-heading);
}

/* ---- Info lists in detail pages ---- */
[data-theme="dark"] .info-label,
[data-theme="dark"] .detail-label,
[data-theme="dark"] dt {
    color: var(--immo-text-secondary);
}

[data-theme="dark"] .info-value,
[data-theme="dark"] .detail-value,
[data-theme="dark"] dd {
    color: var(--immo-text-primary);
}

/* ---- List groups (Bootstrap) ---- */
[data-theme="dark"] .list-group-item {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
    color: var(--immo-text-primary);
}

/* ---- Nav tabs / pills ---- */
[data-theme="dark"] .nav-tabs .nav-link {
    color: var(--immo-text-secondary);
}

[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
    color: var(--immo-text-primary);
}

/* ---- Strong/bold text ---- */
[data-theme="dark"] strong,
[data-theme="dark"] b {
    color: var(--immo-heading);
}

/* ---- HR ---- */
[data-theme="dark"] hr {
    border-color: var(--immo-border-light);
    opacity: 1;
}

/* ---- Modal content (Bootstrap) ---- */
[data-theme="dark"] .modal-content {
    background-color: var(--immo-bg-white);
    border-color: var(--immo-border-light);
    color: var(--immo-text-primary);
}

[data-theme="dark"] .modal-title {
    color: var(--immo-heading);
}

/* ---- Placeholder text ---- */
[data-theme="dark"] ::placeholder {
    color: var(--immo-text-muted) !important;
    opacity: 0.7;
}

/* ---- Bento Grid Dashboard ---- */
[data-theme="dark"] .bento-cell {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .bento-cell:hover {
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.35);
}

/* Tinted stat cards in dark mode — stronger tint for visibility */
[data-theme="dark"] .bento-stat.stat-primary {
    background: linear-gradient(135deg, rgba(var(--brand-primary-rgb), 0.15), rgba(var(--brand-primary-rgb), 0.04));
    border-color: rgba(var(--brand-primary-rgb), 0.2);
}
[data-theme="dark"] .bento-stat.stat-green {
    background: linear-gradient(135deg, rgba(var(--immo-green-rgb), 0.15), rgba(var(--immo-green-rgb), 0.04));
    border-color: rgba(var(--immo-green-rgb), 0.2);
}
[data-theme="dark"] .bento-stat.stat-blue {
    background: linear-gradient(135deg, rgba(var(--immo-blue-rgb), 0.15), rgba(var(--immo-blue-rgb), 0.04));
    border-color: rgba(var(--immo-blue-rgb), 0.2);
}
[data-theme="dark"] .bento-stat.stat-yellow {
    background: linear-gradient(135deg, rgba(var(--immo-yellow-rgb), 0.15), rgba(var(--immo-yellow-rgb), 0.04));
    border-color: rgba(var(--immo-yellow-rgb), 0.2);
}
[data-theme="dark"] .bento-stat.stat-grey {
    background: linear-gradient(135deg, rgba(var(--immo-grey-rgb), 0.15), rgba(var(--immo-grey-rgb), 0.04));
    border-color: rgba(var(--immo-grey-rgb), 0.2);
}
[data-theme="dark"] .bento-stat.stat-turquoise {
    background: linear-gradient(135deg, rgba(var(--immo-turquoise-rgb), 0.15), rgba(var(--immo-turquoise-rgb), 0.04));
    border-color: rgba(var(--immo-turquoise-rgb), 0.2);
}

[data-theme="dark"] .finance-item {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .quick-action:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .share-url-row {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .share-url-row input {
    background: rgba(255, 255, 255, 0.06);
    color: var(--immo-text-secondary);
}

[data-theme="dark"] .mini-marker {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* ---- Map View ---- */
[data-theme="dark"] .map-wrap {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .hover-card-inner {
    background: var(--immo-bg-white);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .hover-card-name {
    color: var(--immo-heading);
}

[data-theme="dark"] .hover-card-stat {
    background: rgba(255, 255, 255, 0.08);
    color: var(--immo-text-secondary);
}

[data-theme="dark"] .hover-card-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .hover-card-photo-placeholder.building { background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(37,99,235,0.08)); }
[data-theme="dark"] .hover-card-photo-placeholder.unit { background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.08)); }
[data-theme="dark"] .hover-card-photo-placeholder.company { background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(124,58,237,0.08)); }

[data-theme="dark"] .map-marker {
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .map-marker-count {
    border-color: var(--immo-bg-white);
}

[data-theme="dark"] .map-hover-card {
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.4));
}