html[data-bs-theme="dark"] {
    --bs-body-bg: #272b30;
    --bs-body-bg-rgb: 39, 43, 48;
    --bs-body-color: #e5e7eb;
    --bs-body-color-rgb: 229, 231, 235;
    --bs-emphasis-color: #f8f9fa;
    --bs-emphasis-color-rgb: 248, 249, 250;
    --bs-secondary-color: #b8bfc6;
    --bs-secondary-color-rgb: 184, 191, 198;
    --bs-secondary-bg: #32373c;
    --bs-secondary-bg-rgb: 50, 55, 60;
    --bs-tertiary-bg: #2d3237;
    --bs-tertiary-bg-rgb: 45, 50, 55;
    --bs-border-color: #50575f;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.12);
    --bs-link-color: #9bc9ff;
    --bs-link-color-rgb: 155, 201, 255;
    --bs-link-hover-color: #c6e1ff;
    --bs-link-hover-color-rgb: 198, 225, 255;
    --app-body-bg: #272b30;
    --app-body-color: #e5e7eb;
    --app-topbar-bg: linear-gradient(180deg, #42484f, #32373c);
    --app-sidebar-bg: #32373c;
    --app-sidebar-border: #50575f;
    --app-sidebar-title: #b8bfc6;
    --app-sidebar-link: #e5e7eb;
    --app-sidebar-link-hover: #42494f;
    --app-panel-bg: #32373c;
    --app-panel-border: #50575f;
    --app-panel-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 20px rgba(0, 0, 0, 0.18);
    --app-muted-surface: #292e33;
    --app-image-border: #50575f;
    --app-code-bg: #202428;
    --app-code-color: #dce1e6;
}

html[data-bs-theme="dark"] .settlement-hero {
    background: linear-gradient(145deg, #42484f, #30353a);
    border-color: var(--app-panel-border);
    box-shadow: var(--app-panel-shadow);
}

html[data-bs-theme="dark"] .settlement-hero::after {
    background: rgba(255, 255, 255, 0.025);
}

html[data-bs-theme="dark"] .settlement-filter-card,
html[data-bs-theme="dark"] .settlement-panel,
html[data-bs-theme="dark"] .settlement-metric-card,
html[data-bs-theme="dark"] .settlement-compact-card,
html[data-bs-theme="dark"] .settlement-transfer-card,
html[data-bs-theme="dark"] .settlement-chart-card,
html[data-bs-theme="dark"] .settlement-member-card {
    background: var(--app-panel-bg);
    border-color: var(--app-panel-border);
    box-shadow: var(--app-panel-shadow);
}

html[data-bs-theme="dark"] .settlement-empty,
html[data-bs-theme="dark"] .settlement-kpi,
html[data-bs-theme="dark"] .settlement-checkbox-card {
    background: var(--app-muted-surface);
    border-color: var(--app-panel-border);
    color: var(--bs-body-color);
}

html[data-bs-theme="dark"] .settlement-title,
html[data-bs-theme="dark"] .settlement-panel-title,
html[data-bs-theme="dark"] .settlement-transfer-route {
    color: var(--bs-emphasis-color);
}

html[data-bs-theme="dark"] .settlement-subtitle,
html[data-bs-theme="dark"] .settlement-panel-desc,
html[data-bs-theme="dark"] .settlement-metric-foot,
html[data-bs-theme="dark"] .settlement-metric-label,
html[data-bs-theme="dark"] .settlement-kpi-label,
html[data-bs-theme="dark"] .settlement-table thead th,
html[data-bs-theme="dark"] .page-settings-label,
html[data-bs-theme="dark"] .editor-status {
    color: var(--bs-secondary-color);
}

html[data-bs-theme="dark"] .settlement-eyebrow,
html[data-bs-theme="dark"] .settlement-pill {
    background: #414b57;
    color: #d7e8fa;
}

html[data-bs-theme="dark"] .settlement-pill-fixed {
    background: #544534;
    color: #f4cf99;
}

html[data-bs-theme="dark"] .settlement-pill-recurring {
    background: #414458;
    color: #d6d5fa;
}

html[data-bs-theme="dark"] .settlement-compare-positive {
    color: #ffaaa6;
}

html[data-bs-theme="dark"] .settlement-compare-negative {
    color: #9bd8a9;
}

html[data-bs-theme="dark"] .btn-primary,
html[data-bs-theme="dark"] .btn-dark {
    --bs-btn-color: #f8f9fa;
    --bs-btn-bg: #454c54;
    --bs-btn-border-color: #626b75;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #555e68;
    --bs-btn-hover-border-color: #7b8794;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #373e46;
    --bs-btn-active-border-color: #9bc9ff;
    --bs-btn-disabled-color: #c0c6cc;
    --bs-btn-disabled-bg: #3a4047;
    --bs-btn-disabled-border-color: #50575f;
    background-image: linear-gradient(rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.06));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.18);
}

html[data-bs-theme="dark"] .btn-outline-dark,
html[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: #dce1e6;
    --bs-btn-border-color: #737e89;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #4a525b;
    --bs-btn-hover-border-color: #9aa6b2;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #424a53;
    --bs-btn-active-border-color: #9bc9ff;
}

html[data-bs-theme="dark"] .btn-outline-danger {
    --bs-btn-color: #ffaaa6;
    --bs-btn-border-color: #bd6e6b;
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select {
    color: var(--bs-body-color);
    background-color: #23272b;
    border-color: #626c76;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18);
}

html[data-bs-theme="dark"] .form-control::placeholder {
    color: #a7b0b9;
}

html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
    border-color: #88b9ed;
    box-shadow: 0 0 0 0.2rem rgba(136, 185, 237, 0.18);
}

html[data-bs-theme="dark"] .form-control:disabled,
html[data-bs-theme="dark"] .form-select:disabled {
    background-color: #3b4147;
    color: #b8bfc6;
}

html[data-bs-theme="dark"] .form-check-input:checked {
    background-color: #557fa9;
    border-color: #88b9ed;
}

html[data-bs-theme="dark"] .calendar-page {
    --calendar-surface: #32373c;
    --calendar-surface-muted: #292e33;
    --calendar-border: #50575f;
    --calendar-text: #e5e7eb;
    --calendar-text-muted: #b8bfc6;
    --calendar-empty-bg: #292e33;
    --fc-border-color: #50575f;
    --fc-neutral-bg-color: #292e33;
    --fc-page-bg-color: #32373c;
    --fc-today-bg-color: rgba(155, 201, 255, 0.08);
    --fc-button-bg-color: #454c54;
    --fc-button-border-color: #626b75;
    --fc-button-hover-bg-color: #555e68;
    --fc-button-hover-border-color: #7b8794;
    --fc-button-active-bg-color: #373e46;
    --fc-button-active-border-color: #9bc9ff;
}

html[data-bs-theme="dark"] .calendar-btn-primary,
html[data-bs-theme="dark"] .calendar-btn-secondary {
    background: linear-gradient(180deg, #4b535c, #3a4149);
    border-color: #737e89;
    color: #f8f9fa !important;
}

html[data-bs-theme="dark"] .calendar-btn-primary:hover,
html[data-bs-theme="dark"] .calendar-btn-secondary:hover {
    background: #555e68;
}

html[data-bs-theme="dark"] #calendarModal .btn,
html[data-bs-theme="dark"] #eventModal .btn {
    color: var(--bs-btn-color);
    background-color: var(--bs-btn-bg, transparent);
    border-color: var(--bs-btn-border-color);
}

html[data-bs-theme="dark"] #calendarModal .btn:hover,
html[data-bs-theme="dark"] #eventModal .btn:hover {
    color: var(--bs-btn-hover-color);
    background-color: var(--bs-btn-hover-bg);
    border-color: var(--bs-btn-hover-border-color);
}

html[data-bs-theme="dark"] .event-time-panel,
html[data-bs-theme="dark"] .event-status-chip {
    color: var(--bs-body-color);
    background: var(--app-muted-surface);
    border-color: var(--app-panel-border);
}

html[data-bs-theme="dark"] .event-status-chip.is-active {
    color: #d7e8fa;
    background: #414b57;
    border-color: #88b9ed;
}

html[data-bs-theme="dark"] .viewer-content th,
html[data-bs-theme="dark"] .viewer-content td,
html[data-bs-theme="dark"] .viewer-content hr {
    border-color: var(--app-panel-border);
}

html[data-bs-theme="dark"] .viewer-content th {
    background: #41484f;
}

html[data-bs-theme="dark"] .viewer-content pre {
    background: var(--app-code-bg);
    color: var(--app-code-color);
}

html[data-bs-theme="dark"] .viewer-content .viewer-warning {
    background: #4c4233;
    color: #f4d6a7;
    border-color: #9e8356;
}

html[data-bs-theme="dark"] #notes-tree-root .rc-tree-node-selected,
html[data-bs-theme="dark"] .tree-add-btn,
html[data-bs-theme="dark"] .tree-node-add-btn {
    background: #414b57;
    color: #eef3f8;
    border-color: #737e89;
}

html[data-bs-theme="dark"] .tree-menu button:hover,
html[data-bs-theme="dark"] .editor-shortcut-btn:hover {
    background: #4a525b;
    color: #f8f9fa;
}

html[data-bs-theme="dark"] .tree-menu button.tree-menu-danger {
    color: #ffaaa6;
}

html[data-bs-theme="dark"] #noteEditor {
    --color-background-item-hover: #454e58;
    --color-border: #626c76;
    color: var(--bs-body-color);
}

html[data-bs-theme="dark"] #noteEditor .ce-toolbar__plus,
html[data-bs-theme="dark"] #noteEditor .ce-toolbar__settings-btn,
html[data-bs-theme="dark"] #noteEditor .ce-inline-toolbar,
html[data-bs-theme="dark"] #noteEditor .ce-conversion-toolbar,
html[data-bs-theme="dark"] #noteEditor .ce-popover,
html[data-bs-theme="dark"] #noteEditor .tc-popover {
    color: var(--bs-body-color);
    background: #3a4149;
    border-color: #626c76;
}

html[data-bs-theme="dark"] #noteEditor .ce-popover-item,
html[data-bs-theme="dark"] #noteEditor .ce-inline-tool,
html[data-bs-theme="dark"] #noteEditor .ce-conversion-tool {
    color: var(--bs-body-color);
}

html[data-bs-theme="dark"] #noteEditor .ce-popover-item:hover,
html[data-bs-theme="dark"] #noteEditor .ce-inline-tool:hover,
html[data-bs-theme="dark"] #noteEditor .ce-conversion-tool:hover,
html[data-bs-theme="dark"] #noteEditor .ce-block--selected .ce-block__content {
    background: #454e58;
}

html[data-bs-theme="dark"] #noteEditor .ce-popover-item__icon,
html[data-bs-theme="dark"] #noteEditor .ce-conversion-tool__icon,
html[data-bs-theme="dark"] #noteEditor .cdx-search-field {
    color: var(--bs-body-color);
    background: #292e33;
    border-color: #626c76;
}

html[data-bs-theme="dark"] #noteEditor .tc-cell {
    border-color: var(--app-panel-border);
}

html[data-bs-theme="dark"] #noteEditor .tc-table--heading .tc-row:first-child {
    background: #41484f;
}

html[data-bs-theme="dark"] .swal2-popup {
    color: var(--bs-body-color);
    background: var(--app-panel-bg);
    border: 1px solid var(--app-panel-border);
}

html[data-bs-theme="dark"] body.sage-diary {
    --diary-bg: #272b30;
    --diary-surface: #32373c;
    --diary-soft: #292e33;
    --diary-topbar: #32373c;
    --diary-ink: #e5e7eb;
    --diary-muted: #b8bfc6;
    --diary-border: #50575f;
    --diary-accent: #9bc9ff;
    --diary-accent-hover: #c6e1ff;
    --diary-on-accent: #202a35;
    --diary-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 20px rgba(0, 0, 0, 0.18);
}
