/* new_UI 加深夜模式：對齊主站 [data-theme="dark"] 的深綠黑調 */

html[data-theme="dark"] {
    color-scheme: dark;
    --ui-bg: #0e1210;
    --ui-surface: #19211e;
    --ui-text: #e6e6e6;
    --ui-muted: #b7b7b7;
    --ui-border: rgba(255, 255, 255, 0.18);
    --ui-accent: #54b963;
    --ui-accent-soft: rgba(84, 185, 99, 0.18);
    --ui-on-accent: #ffffff;
    --ui-tint: #131917;
    --ui-hover: #1e2824;
    --ui-input-bg: #121816;
    --ui-mobile-bg: #0e1210;
    --ui-header-bg: #080a09;
    --ui-header-text: #ffffff;
    --ui-warn: #fbbf24;
    --ui-warn-bg: rgba(245, 158, 11, 0.16);
    --ui-warn-text: #fcd34d;
    --ui-info-bg: rgba(6, 182, 212, 0.14);
    --ui-info-text: #67e8f9;
    --ui-success-bg: rgba(84, 185, 99, 0.16);
    --ui-success-text: #86efac;
    --ui-danger-bg: rgba(220, 38, 38, 0.16);
    --ui-danger-text: #fca5a5;
}

html[data-theme="dark"] body {
    background: var(--ui-bg);
    color: var(--ui-text);
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4 {
    color: #ffffff;
}

html[data-theme="dark"] .ui-site-header {
    background: rgba(8, 10, 9, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .ui-site-header .mode-container {
    color: #ffffff;
}

@media (max-width: 960px) {
    html[data-theme="dark"] .ui-nav.is-open {
        background: var(--ui-tint);
    }
}

html[data-theme="dark"] .ui-hero-dot {
    background: rgba(255, 255, 255, 0.28);
}

html[data-theme="dark"] .ui-price-card {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .ui-price-card:hover {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .ui-price-table__row--sub {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .ui-tabbar {
    background: var(--ui-header-bg);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

/* 表單、表格、按鈕：吃掉各頁硬編碼白底 */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background-color: var(--ui-input-bg);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
    background-color: var(--ui-input-bg);
    color: var(--ui-text);
    border-color: var(--ui-accent);
    box-shadow: 0 0 0 3px rgba(84, 185, 99, 0.22);
}

html[data-theme="dark"] .table,
html[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .ui-table thead th {
    background: var(--ui-tint);
    color: var(--ui-muted);
}

html[data-theme="dark"] .ui-table tbody tr:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .ui-tools-btn,
html[data-theme="dark"] .ui-tab,
html[data-theme="dark"] .ui-page-btn,
html[data-theme="dark"] .ui-btn.secondary {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .ui-tab.active,
html[data-theme="dark"] .ui-page-btn.active {
    background: var(--ui-accent);
    color: var(--ui-on-accent);
    border-color: var(--ui-accent);
}

html[data-theme="dark"] .ui-remark {
    background: var(--ui-warn-bg);
    color: var(--ui-warn-text);
}

html[data-theme="dark"] .ui-remark-text {
    color: var(--ui-text);
}

html[data-theme="dark"] .ui-remark-secondary {
    background: var(--ui-info-bg);
    color: var(--ui-info-text);
}

html[data-theme="dark"] .ui-table-card-img img,
html[data-theme="dark"] .ui-mobile-card-media img {
    background: var(--ui-tint);
}

html[data-theme="dark"] .ui-mobile-card {
    background: var(--ui-tint);
}

html[data-theme="dark"] .ui-mobile-card__foot {
    background: rgba(8, 10, 9, 0.55);
    border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .ui-mobile-meta a {
    background: var(--ui-hover);
    color: var(--ui-muted);
}

html[data-theme="dark"] .ui-mobile-meta > span:last-of-type {
    color: var(--ui-warn-text);
    background: var(--ui-warn-bg);
}

html[data-theme="dark"] .ui-mobile-remark {
    color: var(--ui-warn-text);
}

html[data-theme="dark"] .ui-mobile-remark--alt {
    color: var(--ui-info-text);
}

html[data-theme="dark"] .ui-image-lightbox__img,
html[data-theme="dark"] .ui-image-lightbox__close {
    background: var(--ui-surface);
    color: var(--ui-text);
}

html[data-theme="dark"] .ui-image-lightbox__close:hover {
    background: var(--ui-hover);
}

/* card_admin / order / payment / user / car */
html[data-theme="dark"] .user-hero-card,
html[data-theme="dark"] .card-admin-page .ca-toolbar,
html[data-theme="dark"] .ca-card,
html[data-theme="dark"] .ca-panel,
html[data-theme="dark"] .ca-modal,
html[data-theme="dark"] .ca-modal__panel,
html[data-theme="dark"] .order_additional_charge_status_select,
html[data-theme="dark"] .status_select {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .order_additional_charge_status_select.is-need-charge {
    background: var(--ui-warn-bg);
    border-color: rgba(251, 191, 36, 0.45);
    color: var(--ui-warn-text);
}

html[data-theme="dark"] [class*="is-need-charge"]:focus {
    background: var(--ui-warn-bg);
    border-color: var(--ui-warn);
}

html[data-theme="dark"] .ca-tab,
html[data-theme="dark"] button.ca-tab {
    background: var(--ui-tint);
    color: var(--ui-text);
}

html[data-theme="dark"] .ca-tab:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .ca-tab.is-active,
html[data-theme="dark"] .ca-tab.active {
    background: var(--ui-accent);
    color: var(--ui-on-accent);
}

html[data-theme="dark"] .ca-field input,
html[data-theme="dark"] .ca-field select,
html[data-theme="dark"] .ca-field textarea {
    background: var(--ui-input-bg);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .is-ok,
html[data-theme="dark"] .user-msg-ok,
html[data-theme="dark"] .ok {
    background: var(--ui-success-bg);
    color: var(--ui-success-text);
    border-color: rgba(134, 239, 172, 0.35);
}

html[data-theme="dark"] .is-err,
html[data-theme="dark"] .user-msg-err,
html[data-theme="dark"] .err {
    background: var(--ui-danger-bg);
    color: var(--ui-danger-text);
    border-color: rgba(252, 165, 165, 0.35);
}

html[data-theme="dark"] .user-danger,
html[data-theme="dark"] .text-danger,
html[data-theme="dark"] .is-danger {
    color: var(--ui-danger-text);
}

html[data-theme="dark"] .user-ok,
html[data-theme="dark"] .text-success {
    color: var(--ui-success-text);
}

html[data-theme="dark"] .card-demo-banner {
    background: rgba(84, 185, 99, 0.12);
    border-bottom-color: var(--ui-border);
    color: var(--ui-accent);
}

html[data-theme="dark"] .log-alert,
html[data-theme="dark"] .osl-alert {
    background: var(--ui-danger-bg);
    color: var(--ui-danger-text);
    border-color: rgba(252, 165, 165, 0.35);
}

html[data-theme="dark"] .osl-chip,
html[data-theme="dark"] .log-chip {
    background: var(--ui-tint);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .osl-chip.is-success {
    background: var(--ui-success-bg);
    color: var(--ui-success-text);
    border-color: rgba(134, 239, 172, 0.35);
}

html[data-theme="dark"] .osl-chip.is-warn {
    background: var(--ui-warn-bg);
    color: var(--ui-warn-text);
}

html[data-theme="dark"] .bao-empty,
html[data-theme="dark"] .empty-state {
    background: var(--ui-tint);
}

html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .ui-price-modal__content,
html[data-theme="dark"] [class*="modal__content"],
html[data-theme="dark"] [class*="lightbox"] {
    background-color: var(--ui-surface);
    color: var(--ui-text);
}

html[data-theme="dark"] .dropdown-menu {
    background: var(--ui-surface);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .dropdown-item {
    color: var(--ui-text);
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background: var(--ui-hover);
    color: #ffffff;
}

html[data-theme="dark"] .pagination .page-link {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .page-item.active .page-link {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
    color: var(--ui-on-accent);
}

html[data-theme="dark"] hr {
    border-color: var(--ui-border);
    opacity: 1;
}

html[data-theme="dark"] ::placeholder {
    color: var(--ui-muted);
    opacity: 0.8;
}

html[data-theme="dark"] ::selection {
    background: rgba(84, 185, 99, 0.35);
    color: #ffffff;
}

/* 各頁硬編碼白底（specificity 需壓過 page CSS） */
html[data-theme="dark"] .ui-card,
html[data-theme="dark"] .card-admin-page .ui-card,
html[data-theme="dark"] .user-card,
html[data-theme="dark"] .user-hero-card,
html[data-theme="dark"] .ui-osl-card {
    background: var(--ui-surface);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .card-admin-page .ui-tab,
html[data-theme="dark"] .user-item,
html[data-theme="dark"] .bao-status-panel,
html[data-theme="dark"] .ui-osl-status-pill,
html[data-theme="dark"] .payment_status_select,
html[data-theme="dark"] .extra_charge_status_select {
    background: var(--ui-tint);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .card-admin-page .ui-tab:hover {
    background: var(--ui-hover);
    color: var(--ui-text);
}

html[data-theme="dark"] .card-admin-page .ui-tab.active {
    background: var(--ui-accent);
    color: var(--ui-on-accent);
}

html[data-theme="dark"] .card-admin-page .ui-tools .form-control,
html[data-theme="dark"] .card-admin-page .ui-tools .form-select,
html[data-theme="dark"] .card-admin-field:focus,
html[data-theme="dark"] .card-admin-table tbody tr:hover .card-admin-field:not(:focus):not(.is-saved):not(.is-error),
html[data-theme="dark"] .payment_status_select:focus,
html[data-theme="dark"] .extra_charge_status_select:focus,
html[data-theme="dark"] .order_additional_charge_status_select:focus,
html[data-theme="dark"] .ui-import-price-info,
html[data-theme="dark"] .order-additional-charge-remark-input {
    background: var(--ui-input-bg);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .card-admin-field:hover {
    background: var(--ui-hover);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .card-admin-field.is-saved {
    background: var(--ui-success-bg);
    border-color: rgba(134, 239, 172, 0.45);
}

html[data-theme="dark"] .card-admin-field.is-error {
    background: var(--ui-danger-bg);
    border-color: rgba(252, 165, 165, 0.45);
}

html[data-theme="dark"] .card-admin-table th,
html[data-theme="dark"] .payment-table thead th,
html[data-theme="dark"] .payment-admin-table thead th,
html[data-theme="dark"] .car-table thead th {
    background: var(--ui-tint);
    color: var(--ui-muted);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .card-admin-table tbody tr:hover,
html[data-theme="dark"] .payment-table tbody tr:hover,
html[data-theme="dark"] .payment-admin-table tbody tr:hover,
html[data-theme="dark"] .car-table tbody tr:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .card-admin-table th,
html[data-theme="dark"] .card-admin-table td {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .payment-remark {
    background: var(--ui-tint);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .order-additional-charge-remark {
    background: var(--ui-warn-bg);
    color: var(--ui-warn-text);
}

html[data-theme="dark"] .ui-import-price-info:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .ui-osl-alert,
html[data-theme="dark"] .user-line-alert-err {
    background: var(--ui-danger-bg);
    color: var(--ui-danger-text);
    border-color: rgba(252, 165, 165, 0.4);
}

html[data-theme="dark"] .user-line-alert-ok {
    background: var(--ui-success-bg);
    color: var(--ui-success-text);
    border-color: rgba(134, 239, 172, 0.4);
}

html[data-theme="dark"] .user-error {
    color: var(--ui-danger-text);
}

html[data-theme="dark"] .user-success {
    color: var(--ui-success-text);
}

html[data-theme="dark"] .cd-demo-banner {
    background: rgba(84, 185, 99, 0.14);
    border-bottom-color: var(--ui-border);
    color: #86efac;
}

html[data-theme="dark"] .ui-osl-status-pill--new,
html[data-theme="dark"] .ui-osl-badge--realm-go {
    background: var(--ui-success-bg);
    border-color: rgba(134, 239, 172, 0.4);
    color: var(--ui-success-text);
}

html[data-theme="dark"] .ui-osl-badge--db {
    background: var(--ui-warn-bg);
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--ui-warn-text);
}

html[data-theme="dark"] .ui-osl-badge--api,
html[data-theme="dark"] .ui-osl-badge--realm-ui {
    background: rgba(84, 185, 99, 0.12);
    border-color: rgba(84, 185, 99, 0.35);
    color: #86efac;
}

html[data-theme="dark"] .ui-osl-badge--other {
    background: rgba(175, 82, 222, 0.14);
    border-color: rgba(175, 82, 222, 0.35);
    color: #e9d5ff;
}

html[data-theme="dark"] .ui-osl-badge--realm-unknown {
    background: var(--ui-tint);
    border-color: var(--ui-border);
    color: var(--ui-muted);
}

html[data-theme="dark"] .card-admin-img img {
    background: var(--ui-tint);
}

html[data-theme="dark"] .ui-link-btn {
    color: var(--ui-on-accent);
}

html[data-theme="dark"] .user-logout-btn {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .user-logout-btn:hover {
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(220, 38, 38, 0.16);
}

html[data-theme="dark"] .order-table thead th {
    background: var(--ui-tint);
}

html[data-theme="dark"] .order-table tbody tr:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .ui-import-preview {
    background: var(--ui-tint);
}

html[data-theme="dark"] .ui-import-preview-summary,
html[data-theme="dark"] .ui-import-preview-fee-match,
html[data-theme="dark"] .ui-import-preview-table-wrap,
html[data-theme="dark"] .ui-import-secondary,
html[data-theme="dark"] .ui-import-row-del,
html[data-theme="dark"] .ui-modal-link-btn {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .ui-import-secondary:hover,
html[data-theme="dark"] .ui-modal-link-btn:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .ui-import-warn {
    background: var(--ui-warn-bg);
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--ui-warn-text);
}

html[data-theme="dark"] .card-admin-page .ui-pagination {
    background: var(--ui-tint);
    border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .card-admin-page .ui-page-btn {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .payment-table tbody tr,
html[data-theme="dark"] .car-table tbody tr,
html[data-theme="dark"] .payment-admin-table tbody tr {
    background: var(--ui-surface);
}

html[data-theme="dark"] .payment-cards-btn,
html[data-theme="dark"] .payment-cards-modal-dialog {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-theme="dark"] .payment-cards-btn:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .payment-cards-modal-head,
html[data-theme="dark"] .payment-cards-modal-table thead th {
    background: var(--ui-tint);
}

html[data-theme="dark"] .payment-cards-modal-table tbody tr:hover {
    background: var(--ui-hover);
}

html[data-theme="dark"] .ui-image-lightbox__close {
    color: var(--ui-text);
}
