/* Global HambraTech theme tokens.
   Keep this file semantic: feature CSS should consume these variables instead
   of hard-coding white/gray/black surfaces. */
:root {
    color-scheme: light;

    --ht-font-ui: "Helvetica Neue", Helvetica, Arial, sans-serif;

    --ht-bg: #f6f7f8;
    --ht-bg-elevated: #ffffff;
    --ht-surface: #ffffff;
    --ht-surface-raised: #ffffff;
    --ht-surface-soft: #f9fafb;
    --ht-surface-muted: #f3f4f6;
    --ht-surface-hover: #f3f4f6;
    --ht-surface-elevated: #ffffff;
    --ht-surface-selected: #fef2f2;
    --ht-surface-accent: #fff7f7;
    --ht-overlay: rgba(17, 24, 39, 0.44);
    --ht-glass: rgba(255, 255, 255, 0.72);
    --ht-glass-strong: rgba(255, 255, 255, 0.86);
    --ht-border: #e5e7eb;
    --ht-border-soft: #f0f2f5;
    --ht-border-strong: #d1d5db;
    --ht-text: #1f2937;
    --ht-text-strong: #111827;
    --ht-text-muted: #6b7280;
    --ht-text-soft: #9ca3af;
    --ht-text-inverse: #ffffff;
    --ht-control-bg: #ffffff;
    --ht-control-bg-muted: #f9fafb;
    --ht-control-border: #d1d5db;
    --ht-control-text: var(--ht-text);
    --ht-control-placeholder: var(--ht-text-soft);
    --ht-focus-ring: rgba(220, 38, 38, 0.16);
    --ht-shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.08);
    --ht-shadow-md: 0 10px 30px rgba(17, 24, 39, 0.12);
    --ht-shadow-lg: 0 22px 70px rgba(17, 24, 39, 0.22);
    --ht-logo-plate: #ffffff;
    --ht-logo-plate-border: rgba(17, 24, 39, 0.08);
    --ht-safe-area-bg: #ffffff;
    --ht-neutral-action-bg: #1a1a1a;
    --ht-neutral-action-hover: #111111;
    --ht-neutral-action-active: #0f0f0f;
    --ht-neutral-action-text: #ffffff;
    --ht-neutral-action-stripe: rgba(26, 26, 26, 0.28);

    --ht-black: var(--ht-text-strong);
    --ht-charcoal: #2d2d2d;
    --ht-red: #dc2626;
    --ht-red-hover: #b91c1c;
    --ht-red-light: #fef2f2;
    --ht-petrol: #0f766e;
    --ht-petrol-dark: #0b5e57;
    --ht-petrol-light: #ecfdf5;
    --ht-petrol-badge-bg: rgba(15, 118, 110, 0.12);
    --ht-petrol-badge-text: var(--ht-petrol);
    --ht-petrol-badge-border: rgba(15, 118, 110, 0.25);
    --ht-green: #16a34a;
    --ht-green-light: #dcfce7;
    --ht-orange: #ea580c;
    --ht-orange-light: #fff7ed;
    --ht-blue: #2563eb;
    --ht-blue-light: #dbeafe;
    --ht-amber: #b45309;
    --ht-amber-light: #fef3c7;
    --ht-amber-border: #fde68a;

    --bg-color: var(--ht-bg);
    --card-bg: var(--ht-surface);
    --text-color: var(--ht-text);
    --text-light: var(--ht-text-muted);
    --border-color: var(--ht-border);
    --input-border: var(--ht-control-border);
    --surface-soft: var(--ht-surface);
    --error-bg: var(--ht-red-light);
    --error-border: #fecaca;
}

/* Shared product controls.
   Feature styles may compose layout around these components, but must not
   duplicate their color, typography or interaction states locally. */
.ht-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    font-family: var(--ht-font-ui);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.ht-button:hover { text-decoration: none; }
.ht-button:active { transform: translateY(1px); }
.ht-button:focus-visible {
    outline: 2px solid var(--ht-red);
    outline-offset: 2px;
}
.ht-button:disabled,
.ht-button[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.ht-button--primary {
    background: var(--ht-red);
    color: var(--ht-text-inverse);
}
.ht-button--primary:hover { background: var(--ht-red-hover); }
.ht-button--secondary {
    border-color: var(--ht-control-border);
    background: var(--ht-control-bg);
    color: var(--ht-text-strong);
}
.ht-button--secondary:hover {
    border-color: var(--ht-border-strong);
    background: var(--ht-surface-hover);
}
.ht-button--quiet {
    background: transparent;
    color: var(--ht-text);
}
.ht-button--quiet:hover { background: var(--ht-surface-hover); }
.ht-button--danger {
    border-color: var(--ht-red);
    background: transparent;
    color: var(--ht-red);
}
.ht-button--danger:hover { background: var(--ht-red-light); }
.ht-button--compact {
    min-height: 36px;
    padding: 0.45rem 0.7rem;
    font-size: 0.8125rem;
}
.ht-icon-button {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 0;
}

.ht-field {
    min-height: 44px;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--ht-control-border);
    border-radius: 0.625rem;
    background: var(--ht-control-bg);
    color: var(--ht-control-text);
    font-family: var(--ht-font-ui);
    font-size: 1rem;
    line-height: 1.35;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}
.ht-field::placeholder { color: var(--ht-control-placeholder); }
.ht-field:hover { border-color: var(--ht-border-strong); }
.ht-field:focus {
    border-color: var(--ht-red);
    box-shadow: 0 0 0 3px var(--ht-focus-ring);
    outline: none;
}
.ht-field:disabled,
.ht-field[readonly] {
    background: var(--ht-control-bg-muted);
    color: var(--ht-text-muted);
}
textarea.ht-field { min-height: 7rem; resize: vertical; }

.ht-field-label {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--ht-text-strong);
    font-family: var(--ht-font-ui);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.35;
}
.ht-field-help,
.ht-field-error {
    margin: 0.375rem 0 0;
    font-family: var(--ht-font-ui);
    font-size: 0.8125rem;
    line-height: 1.4;
}
.ht-field-help { color: var(--ht-text-muted); }
.ht-field-error { color: var(--ht-red); }

.ht-badge {
    min-height: 1.625rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: var(--ht-surface-muted);
    color: var(--ht-text);
    font-family: var(--ht-font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}
.ht-badge--success { background: var(--ht-green-light); color: var(--ht-green); }
.ht-badge--warning { background: var(--ht-amber-light); color: var(--ht-amber); }
.ht-badge--danger { background: var(--ht-red-light); color: var(--ht-red); }
.ht-badge--info { background: var(--ht-blue-light); color: var(--ht-blue); }
.ht-badge--accent { background: var(--ht-petrol-light); color: var(--ht-petrol); }

.ht-skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
    background: var(--ht-surface-muted);
}
.ht-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--ht-surface-raised), transparent);
    transform: translateX(-100%);
    animation: ht-skeleton-shimmer 1.4s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}
@keyframes ht-skeleton-shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
    .ht-button,
    .ht-field { transition-duration: 0.01ms; }
    .ht-skeleton::after { animation: none; display: none; }
}

html[data-ht-theme="dark"] {
    color-scheme: dark;

    --ht-bg: #0b1018;
    --ht-bg-elevated: #101722;
    --ht-surface: #141c28;
    --ht-surface-raised: #182231;
    --ht-surface-soft: #101722;
    --ht-surface-muted: #1e2938;
    --ht-surface-hover: #223043;
    --ht-surface-elevated: #182231;
    --ht-surface-selected: rgba(248, 113, 113, 0.13);
    --ht-surface-accent: rgba(220, 38, 38, 0.11);
    --ht-overlay: rgba(2, 6, 23, 0.72);
    --ht-glass: rgba(20, 28, 40, 0.78);
    --ht-glass-strong: rgba(24, 34, 49, 0.9);
    --ht-border: #2b384a;
    --ht-border-soft: #223043;
    --ht-border-strong: #3d4c61;
    --ht-text: #e5e7eb;
    --ht-text-strong: #f8fafc;
    --ht-text-muted: #aab4c3;
    --ht-text-soft: #7f8a9a;
    --ht-text-inverse: #0b1018;
    --ht-control-bg: #101722;
    --ht-control-bg-muted: #0f1621;
    --ht-control-border: #3b475a;
    --ht-control-text: var(--ht-text);
    --ht-control-placeholder: var(--ht-text-soft);
    --ht-focus-ring: rgba(248, 113, 113, 0.24);
    --ht-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --ht-shadow-md: 0 14px 36px rgba(0, 0, 0, 0.42);
    --ht-shadow-lg: 0 26px 80px rgba(0, 0, 0, 0.55);
    --ht-logo-plate: transparent;
    --ht-logo-plate-border: rgba(255, 255, 255, 0.14);
    --ht-safe-area-bg: #0b1018;
    --ht-neutral-action-bg: #243042;
    --ht-neutral-action-hover: #2f3d52;
    --ht-neutral-action-active: #1f2a3a;
    --ht-neutral-action-text: #f8fafc;
    --ht-neutral-action-stripe: rgba(148, 163, 184, 0.34);

    --ht-black: var(--ht-text-strong);
    --ht-charcoal: #dce3ee;
    --ht-red: #ef4444;
    --ht-red-hover: #f87171;
    --ht-red-light: rgba(239, 68, 68, 0.18);
    --ht-petrol: #2dd4bf;
    --ht-petrol-dark: #5eead4;
    --ht-petrol-light: rgba(45, 212, 191, 0.14);
    --ht-petrol-badge-bg: rgba(15, 118, 110, 0.48);
    --ht-petrol-badge-text: #ccfbf1;
    --ht-petrol-badge-border: rgba(153, 246, 228, 0.38);
    --ht-green: #86efac;
    --ht-green-light: rgba(22, 101, 52, 0.34);
    --ht-orange: #fb923c;
    --ht-orange-light: rgba(251, 146, 60, 0.16);
    --ht-blue: #60a5fa;
    --ht-blue-light: rgba(96, 165, 250, 0.17);
    --ht-amber: #fde68a;
    --ht-amber-light: rgba(146, 64, 14, 0.34);
    --ht-amber-border: rgba(251, 191, 36, 0.38);

    --bg-color: var(--ht-bg);
    --card-bg: var(--ht-surface);
    --text-color: var(--ht-text);
    --text-light: var(--ht-text-muted);
    --border-color: var(--ht-border);
    --input-border: var(--ht-control-border);
    --surface-soft: var(--ht-surface);
    --error-bg: var(--ht-red-light);
    --error-border: rgba(248, 113, 113, 0.36);
}

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

html[data-ht-theme="dark"] ::selection {
    background: rgba(248, 113, 113, 0.32);
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #425169;
}

html[data-ht-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #59687d;
}

html[data-ht-theme="dark"] :is(input, textarea, select):not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
    background-color: var(--ht-control-bg);
    border-color: var(--ht-control-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(input, textarea, select)::placeholder {
    color: var(--ht-text-soft);
}

html[data-ht-theme="dark"] :is(input, textarea, select):focus {
    border-color: var(--ht-red);
    box-shadow: 0 0 0 3px var(--ht-focus-ring);
}

html[data-ht-theme="dark"] :is(input, textarea, select)[readonly],
html[data-ht-theme="dark"] :is(input, textarea, select):disabled {
    background-color: var(--ht-control-bg-muted);
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(input[type="checkbox"], input[type="radio"], input[type="range"]) {
    accent-color: var(--ht-red);
}

img.ht-theme-logo-dark {
    display: none;
}

html[data-ht-theme="dark"] img.ht-theme-logo-light {
    display: none;
}

html[data-ht-theme="dark"] img.ht-theme-logo-dark {
    display: block;
}

/* Tailwind utility bridge for existing inline markup. */
html[data-ht-theme="dark"] :is(.bg-white, [class~="bg-white"]) {
    background-color: var(--ht-surface);
}

html[data-ht-theme="dark"] :is(#ht-header, .header-bar, .dashboard-header) {
    background-color: var(--ht-surface);
    border-color: var(--ht-border);
    color: var(--ht-text-strong);
    box-shadow: var(--ht-shadow-sm);
}

html[data-ht-theme="dark"] :is(.bg-gray-50, [class~="bg-gray-50"]) {
    background-color: var(--ht-bg);
}

html[data-ht-theme="dark"] :is(.bg-gray-100, [class~="bg-gray-100"]) {
    background-color: var(--ht-surface-muted);
}

html[data-ht-theme="dark"] :is(.bg-gray-200, [class~="bg-gray-200"]) {
    background-color: var(--ht-border-strong);
}

html[data-ht-theme="dark"] :is(.hover\:bg-gray-50:hover, [class~="hover:bg-gray-50"]:hover) {
    background-color: var(--ht-surface-muted);
}

html[data-ht-theme="dark"] :is(.hover\:bg-gray-100:hover, [class~="hover:bg-gray-100"]:hover) {
    background-color: var(--ht-surface-muted);
}

html[data-ht-theme="dark"] :is(.hover\:bg-red-50:hover, [class~="hover:bg-red-50"]:hover) {
    background-color: var(--ht-red-light);
}

html[data-ht-theme="dark"] :is(.text-gray-900, [class~="text-gray-900"], [class~="text-[#1a1a1a]"], [class~="text-[#111827]"]) {
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] :is(.text-gray-800, .text-gray-700, .text-gray-600, [class~="text-gray-800"], [class~="text-gray-700"], [class~="text-gray-600"]) {
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(.text-gray-500, .text-gray-400, [class~="text-gray-500"], [class~="text-gray-400"]) {
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(.text-red-600, .text-red-500, [class~="text-red-600"], [class~="text-red-500"], [class~="text-[#dc2626]"]) {
    color: var(--ht-red);
}

html[data-ht-theme="dark"] :is(.text-blue-700, .text-blue-600, [class~="text-blue-700"], [class~="text-blue-600"]) {
    color: #bfdbfe;
}

html[data-ht-theme="dark"] :is(.border-gray-100, .border-gray-200, .border-gray-300, [class~="border-gray-100"], [class~="border-gray-200"], [class~="border-gray-300"]) {
    border-color: var(--ht-border);
}

html[data-ht-theme="dark"] :is(.divide-gray-100 > :not([hidden]) ~ :not([hidden]), .divide-gray-200 > :not([hidden]) ~ :not([hidden])) {
    border-color: var(--ht-border);
}

/* Common app surfaces shared by all modules. */
html[data-ht-theme="dark"] :is(
    #ht-header,
    .header-bar,
    .dashboard-header,
    .login-card,
    .password-card,
    .home-card,
    .card,
    .stat-card,
    .entry-card,
    .course-card,
    .km-course-card,
    .student-card,
    .report-card,
    .invoice-card,
    .invoice-table-card,
    .invoice-card-mobile,
    .payroll-card,
    .settings-card,
    .dashboard-card,
    .quick-action-card,
    .favorite-card,
    .asset-card,
    .color-card,
    .modal,
    .modal-content,
    .modal-card,
    .dialog,
    .sheet,
    .panel,
    .editor-sidebar,
    .editor-panel-header,
    .preview-accordion,
    .filter-panel,
    .re-filter-panel,
    .export-panel,
    .form-card,
    .clean-panel
) {
    background-color: var(--ht-surface);
    border-color: var(--ht-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(
    .card-header,
    .modal-header,
    .modal-footer,
    .table-header,
    .list-header,
    .form-section,
    .empty-state,
    .detail-section,
    .preview-toolbar,
    .editor-toolbar,
    .preview-summary,
    .filter-tabs,
    .re-filter-body,
    .tab-nav,
    .toolbar,
    .selection-bar
) {
    background-color: var(--ht-surface-soft);
    border-color: var(--ht-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(
    .stat-value,
    .card-title,
    .home-card-title,
    .entry-title,
    .entry-route,
    .entry-time,
    .course-title,
    .km-course-title-block h3,
    .student-name,
    .invoice-number,
    .invoice-card-titlewrap,
    .invoice-card-fact-value,
    .section-title,
    .modal-title,
    .detail-title,
    .logo-title,
    h1,
    h2,
    h3,
    h4
) {
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] :is(
    .stat-label,
    .card-subtitle,
    .welcome-meta,
    .entry-meta,
    .entry-purpose,
    .entry-date,
    .course-meta,
    .km-course-subline,
    .km-course-meta,
    .km-course-next-label,
    .student-meta,
    .invoice-recipient,
    .invoice-card-recipient,
    .invoice-card-fact-label,
    .form-hint,
    .empty-message,
    .muted,
    small
) {
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(.back-btn, .btn-outline, .secondary-btn, .ghost-btn, .icon-btn, .action-btn) {
    background-color: var(--ht-surface);
    border-color: var(--ht-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(
    .btn-secondary,
    .btn-icon,
    .btn-text,
    .clean-input,
    .mobile-view-btn,
    .invoice-card-menu summary,
    .invoice-card-menu-item,
    .template-option
) {
    background-color: var(--ht-surface);
    border-color: var(--ht-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(
    .btn-secondary,
    .btn-icon,
    .btn-text,
    .clean-input,
    .mobile-view-btn,
    .invoice-card-menu summary,
    .invoice-card-menu-item,
    .template-option
):hover {
    background-color: var(--ht-surface-muted);
    border-color: var(--ht-border-strong);
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] :is(.back-btn, .btn-outline, .secondary-btn, .ghost-btn, .icon-btn, .action-btn):hover {
    background-color: var(--ht-surface-muted);
    border-color: var(--ht-border-strong);
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] :is(.tab-btn, .filter-tab) {
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(.mobile-view-btn.active, .wizard-tab-active, .template-option:hover) {
    background-color: var(--ht-red-light);
    color: var(--ht-red);
}

html[data-ht-theme="dark"] :is(.tab-btn.active, .filter-tab.active) {
    background-color: var(--ht-surface-raised);
    color: var(--ht-text-strong);
    box-shadow: var(--ht-shadow-sm);
}

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

html[data-ht-theme="dark"] :is(th, thead td) {
    color: var(--ht-text-muted);
    border-color: var(--ht-border);
}

html[data-ht-theme="dark"] :is(td, tr) {
    border-color: var(--ht-border-soft);
}

html[data-ht-theme="dark"] :is(tr:hover td, .table-row:hover) {
    background-color: var(--ht-surface-soft);
}

html[data-ht-theme="dark"] :is(.logo-copy) {
    border-color: var(--ht-border);
}

html[data-ht-theme="dark"] :is(.preview-panel, #preview-wrapper, .editor-preview, .preview-container) {
    background-color: var(--ht-bg);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(.modal-overlay, #template-backdrop) {
    background-color: var(--ht-overlay);
}

html[data-ht-theme="dark"] :is(#template-content, .address-suggestions, .invoice-card-menu-list, .checkered-bg) {
    background-color: var(--ht-surface);
    border-color: var(--ht-border);
    color: var(--ht-text);
    box-shadow: var(--ht-shadow-lg);
}

html[data-ht-theme="dark"] :is(.address-suggestion, .address-suggestion-item) {
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(.address-suggestion:hover, .address-suggestion-item:hover, .address-suggestion-item.active, .invoice-card-menu-item:hover) {
    background-color: var(--ht-surface-muted);
}

html[data-ht-theme="dark"] .checkered-bg {
    background-color: var(--ht-surface-soft);
    background-image:
        linear-gradient(45deg, var(--ht-border) 25%, transparent 25%),
        linear-gradient(-45deg, var(--ht-border) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--ht-border) 75%),
        linear-gradient(-45deg, transparent 75%, var(--ht-border) 75%);
}

html[data-ht-theme="dark"] :is(.form-input, .clean-input, .search-input, .filter-input) {
    background-color: var(--ht-control-bg);
    border-color: var(--ht-control-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(.form-input:focus, .clean-input:focus, .search-input:focus, .filter-input:focus) {
    border-color: var(--ht-red);
    box-shadow: 0 0 0 3px var(--ht-focus-ring);
}

html[data-ht-theme="dark"] :is(.form-input[readonly], .clean-input[readonly]) {
    background-color: var(--ht-control-bg-muted);
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(.badge, .entry-user-tag, .km-course-status, .status-badge) {
    border-color: var(--ht-border);
}

html[data-ht-theme="dark"] :is(
    .calendar-header,
    .planner-cal-header,
    .planner-month-side-label,
    .planner-month-index-btn,
    .re-filter-label,
    .calc-row,
    .abr-card-amount-label,
    .schedule-generator-field,
    .km-cb-label.placeholder,
    .planner-legend-label,
    .planner-day-picker-label
) {
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(
    .calendar-day,
    .planner-day,
    .planner-month-card,
    .planner-month-index-btn,
    .wizard-body,
    .wizard-body--edit,
    .wizard-edit-sidebar,
    .wizard-body--edit #wizard-form,
    .km-header-action--secondary,
    .km-cb-toggle,
    .km-cb-list,
    .manual-student-row,
    .planner-color-popover,
    .planner-day-picker,
    .planner-day-picker-row,
    .position-row,
    .calc-summary,
    .abr-card,
    .abr-card-pdf,
    .item-row,
    .items-total,
    .re-filter-summary,
    .re-filter-check span,
    .success-card,
    .export-row
) {
    background-color: var(--ht-surface);
    border-color: var(--ht-border);
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(
    .calendar-day:hover,
    .planner-day:hover:not(.empty),
    .wizard-tab:hover,
    .km-cb-item:hover,
    .planner-day-picker-row:hover,
    .planner-month-index-btn:hover,
    .abr-card-pdf:hover,
    .re-filter-summary:hover
) {
    background-color: var(--ht-surface-muted);
    border-color: var(--ht-border-strong);
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] :is(
    .calendar-day.weekend,
    .planner-day.weekend,
    .calendar-day.cancelled,
    .planner-day.empty,
    .step-pending,
    .student-row-missing,
    .shopify-missing-notice,
    .calc-row-ag
) {
    background-color: var(--ht-surface-soft);
    border-color: var(--ht-border);
    color: var(--ht-text-muted);
}

html[data-ht-theme="dark"] :is(
    .calendar-day.holiday,
    .planner-day.holiday,
    .entry-card.selected,
    .form-input.field-invalid,
    .editor-errors
) {
    background-color: var(--ht-red-light);
    border-color: rgba(248, 113, 113, 0.36);
    color: var(--ht-red);
}

html[data-ht-theme="dark"] :is(
    .calendar-day.today,
    .planner-day.today,
    .planner-month-index-btn.active,
    .planner-color-swatch.selected
) {
    border-color: var(--ht-petrol);
    outline-color: var(--ht-petrol);
    background-color: var(--ht-petrol-light);
    color: var(--ht-petrol-dark);
}

html[data-ht-theme="dark"] :is(
    .wizard-tab,
    .km-cb-item,
    .planner-day-picker-row,
    .manual-student-row,
    .planner-legend-item,
    .km-header-action--secondary
) {
    color: var(--ht-text);
}

html[data-ht-theme="dark"] :is(
    .wizard-tab-active,
    .re-filter-check input:checked + span
) {
    background-color: var(--ht-red-light);
    border-color: rgba(248, 113, 113, 0.36);
    color: var(--ht-red);
}

html[data-ht-theme="dark"] :is(
    .km-header-search input,
    .km-cb-label,
    .planner-month-card h4,
    .planner-day-number,
    .calc-row-total,
    .abr-card-name,
    .abr-card-amount-value,
    .success-title,
    .success-subtitle strong,
    .export-month
) {
    color: var(--ht-text-strong);
}

html[data-ht-theme="dark"] :is(
    .re-table th,
    .la-table th,
    .re-table td,
    .la-table td,
    .re-table tfoot td,
    .la-table tfoot td
) {
    border-color: var(--ht-border);
}

html[data-ht-theme="dark"] :is(
    .re-table th,
    .la-table tfoot td,
    .re-table tbody tr:hover,
    .la-table tbody tr:hover
) {
    background-color: var(--ht-surface-soft);
}

html[data-ht-theme="dark"] :is(
    .badge-draft,
    .badge-pending,
    .status-probestunde
) {
    background-color: var(--ht-orange-light);
    color: var(--ht-orange);
}

html[data-ht-theme="dark"] :is(
    .badge-final,
    .badge-released,
    .status-aktiv
) {
    background-color: var(--ht-green-light);
    color: var(--ht-green);
}

html[data-ht-theme="dark"] :is(
    .badge-stamm,
    .status-interessent
) {
    background-color: var(--ht-blue-light);
    color: var(--ht-blue);
}

html[data-ht-theme="dark"] :is(
    .badge-no-stamm,
    .status-pausiert
) {
    background-color: var(--ht-surface-muted);
    color: var(--ht-text-muted);
}

/* Shared multi-select filter component. Use this for compact toolbar filters
   that need checkbox-style multiple selection without native multi-select UI. */
.ht-multi-filter {
    position: relative;
    min-width: 0;
}

.ht-multi-filter__label {
    display: block;
    margin: 0 0 5px;
    color: var(--ht-text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ht-multi-filter__button {
    width: 100%;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--ht-control-border);
    border-radius: 10px;
    background: var(--ht-control-bg);
    color: var(--ht-control-text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.ht-multi-filter__button:hover {
    border-color: var(--ht-border-strong);
    background: var(--ht-surface-hover);
}

.ht-multi-filter__button:focus-visible {
    outline: none;
    border-color: var(--ht-red);
    box-shadow: 0 0 0 3px var(--ht-focus-ring);
}

.ht-multi-filter__value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ht-multi-filter__chevron {
    width: 12px;
    flex-shrink: 0;
    color: var(--ht-text-soft);
    transition: transform 0.15s ease;
}

.ht-multi-filter__button[aria-expanded="true"] .ht-multi-filter__chevron {
    transform: rotate(180deg);
}

.ht-multi-filter__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 90;
    width: max-content;
    min-width: min(220px, calc(100vw - 32px));
    max-width: min(320px, calc(100vw - 32px));
    max-height: min(320px, 62vh);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--ht-border);
    border-radius: 12px;
    background: var(--ht-surface-raised);
    box-shadow: var(--ht-shadow-md);
}

.ht-multi-filter__menu.hidden {
    display: none;
}

.ht-multi-filter__option {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ht-text);
    font-size: 0.86rem;
    cursor: pointer;
    user-select: none;
}

.ht-multi-filter__option:hover {
    background: var(--ht-surface-hover);
}

.ht-multi-filter__option--all {
    position: relative;
    margin-bottom: 9px;
    border-radius: 8px;
    font-weight: 650;
}

.ht-multi-filter__option--all::after {
    content: '';
    position: absolute;
    right: 10px;
    bottom: -5px;
    left: 10px;
    height: 1px;
    background: var(--ht-border);
    pointer-events: none;
}

.ht-multi-filter__option[aria-selected="true"] {
    background: var(--ht-surface-selected);
    color: var(--ht-text-strong);
}

.ht-multi-filter__checkbox {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--ht-red);
}

.ht-multi-filter__option-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .ht-multi-filter__menu {
        width: min(220px, calc(100vw - 32px));
        max-width: calc(100vw - 32px);
    }
}

/* Keep generated documents and previews paper-white for visual fidelity. */
html[data-ht-theme="dark"] :is(
    .a4-page,
    .offer-page,
    .preview-page,
    .invoice-preview,
    .pdf-page,
    .document-page,
    .document-template-page-preview,
    .certificate-preview,
    .urkunde,
    #preview-content,
    #preview-container .page,
    #invoice-preview
) {
    background-color: #ffffff;
    color: #111827;
    color-scheme: light;
}
