/* ========================================
   Global Form Elements Styling
   Consistent dark theme form controls
   ======================================== */

/* ===== Default Checkbox Styling =====
   Apply the styled (dark-theme) checkbox to ALL <input type="checkbox">
   by default. Opt out by adding the .checkbox-native class, or by nesting
   the input inside .toggle-switch / .switch / .setting-toggle (those wrappers
   already hide the input via higher-specificity rules).
*/
input[type="checkbox"]:not(.checkbox-native) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    padding: 0 !important;
    box-sizing: border-box;
    vertical-align: middle;
}

input[type="checkbox"]:not(.checkbox-native):hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(var(--brand-primary-rgb), 0.1);
}

input[type="checkbox"]:not(.checkbox-native):focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

input[type="checkbox"]:not(.checkbox-native):checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

input[type="checkbox"]:not(.checkbox-native):checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 9px;
    border: solid white !important;
    border-width: 0 2px 2px 0 !important;
    transform: translate(-50%, -62%) rotate(45deg);
}

input[type="checkbox"]:not(.checkbox-native):disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-theme="light"] input[type="checkbox"]:not(.checkbox-native) {
    border-color: #cbd5e1;
    background: #f8fafc;
}

[data-theme="light"] input[type="checkbox"]:not(.checkbox-native):hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(var(--brand-primary-rgb), 0.08);
}

[data-theme="light"] input[type="checkbox"]:not(.checkbox-native):checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

/* ===== Custom Checkbox (legacy class hooks - now redundant aliases) ===== */
.form-check,
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

label.form-check {
    display: flex !important;
    align-items: flex-start !important;
    margin-bottom: 0 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.form-check-input,
input[type="checkbox"].custom-checkbox {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    box-sizing: border-box;
}

.form-check-input:hover,
input[type="checkbox"].custom-checkbox:hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(var(--brand-primary-rgb), 0.1);
}

.form-check-input:focus,
input[type="checkbox"].custom-checkbox:focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

.form-check-input:checked,
input[type="checkbox"].custom-checkbox:checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

.form-check-input:checked::after,
input[type="checkbox"].custom-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 9px;
    border: solid white !important;
    border-width: 0 2px 2px 0 !important;
    transform: translate(-50%, -62%) rotate(45deg);
}

.form-check-label,
.checkbox-label {
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Checkbox within label (nested pattern) */
.checkbox-label input[type="checkbox"],
.checkbox-group label:not(.setting-toggle) input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    box-sizing: border-box;
}

.checkbox-label input[type="checkbox"]:hover,
.checkbox-group label:not(.setting-toggle) input[type="checkbox"]:hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(var(--brand-primary-rgb), 0.1);
}

.checkbox-label input[type="checkbox"]:checked,
.checkbox-group label:not(.setting-toggle) input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

.checkbox-label input[type="checkbox"]:checked::after,
.checkbox-group label:not(.setting-toggle) input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 9px;
    border: solid white !important;
    border-width: 0 2px 2px 0 !important;
    transform: translate(-50%, -62%) rotate(45deg);
}

/* Light mode checkbox styling */
[data-theme="light"] .form-check-input,
[data-theme="light"] input[type="checkbox"].custom-checkbox,
[data-theme="light"] .checkbox-label input[type="checkbox"] {
    border-color: #cbd5e1;
    background: #f8fafc;
}

[data-theme="light"] .form-check-input:hover,
[data-theme="light"] input[type="checkbox"].custom-checkbox:hover,
[data-theme="light"] .checkbox-label input[type="checkbox"]:hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(var(--brand-primary-rgb), 0.08);
}

[data-theme="light"] .form-check-input:checked,
[data-theme="light"] input[type="checkbox"].custom-checkbox:checked,
[data-theme="light"] .checkbox-label input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

[data-theme="light"] .form-check-input:checked::after,
[data-theme="light"] input[type="checkbox"].custom-checkbox:checked::after,
[data-theme="light"] .checkbox-label input[type="checkbox"]:checked::after {
    border-color: white !important;
}

[data-theme="light"] .form-check-label,
[data-theme="light"] .checkbox-label {
    color: #1e293b;
}

/* ===== Checkbox Group ===== */
/* Container for multiple checkboxes in forms */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.checkbox-group label:not(.setting-toggle) {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0;
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
}

.checkbox-group label:not(.setting-toggle) span {
    font-weight: 400;
    text-transform: none;
}

.checkbox-group label:not(.setting-toggle) small {
    font-weight: 400;
    font-size: 0.85em;
    opacity: 0.7;
}

[data-theme="light"] .checkbox-group label:not(.setting-toggle) {
    color: #1e293b;
}

/* ===== Toggle Switch ===== */
:root {
    --switch-track-off: #475569;
    --switch-track-border: var(--border-control, #64748b);
}

[data-theme="light"] {
    --switch-track-off: #64748b;
}

.toggle-switch,
.switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

:is(.toggle-switch, .switch, .modern-toggle, .day-toggle, .setting-toggle) input[type="checkbox"] {
    display: block;
    position: absolute;
    width: 1px;
    min-width: 0;
    max-width: none;
    height: 1px;
    opacity: 0;
    clip-path: inset(50%);
    border: 0;
    margin: 0;
}

:is(.toggle-switch, .switch, .modern-toggle, .day-toggle, .setting-toggle) input[type="checkbox"]:focus-visible + :is(.toggle-slider, .slider, .toggle-visual) {
    outline: 2px solid var(--accent-primary, var(--brand-primary));
    outline-offset: 3px;
}

:is(.toggle-switch, .switch, .modern-toggle, .day-toggle, .setting-toggle) input[type="checkbox"]:disabled + :is(.toggle-slider, .slider, .toggle-visual) {
    opacity: 0.55;
    cursor: not-allowed;
}

.toggle-slider,
.slider {
    width: 48px;
    height: 26px;
    background: var(--switch-track-off);
    box-shadow: inset 0 0 0 2px var(--switch-track-border);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::before,
.slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider,
.switch input:checked + .slider {
    background: var(--accent-success, #10b981);
}

.toggle-switch input:checked + .toggle-slider::before,
.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.toggle-label,
.switch-label {
    font-size: 14px;
    color: var(--text-primary, #ffffff);
    font-weight: 500;
}


/* ===== Text Inputs ===== */
/* Unified styling for form-input and form-control - use either class interchangeably */
.form-input,
.form-control,
input:not([type]),
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-control, var(--border-color, rgba(255, 255, 255, 0.12)));
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg, rgba(255, 255, 255, 0.04));
    color: var(--text-primary, #ffffff);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-input:hover,
.form-control:hover,
input:hover:not([type="checkbox"]):not([type="radio"]) {
    border-color: var(--accent-primary, var(--brand-primary));
}

.form-input:focus,
.form-control:focus,
input:focus:not([type="checkbox"]):not([type="radio"]),
textarea:focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

/* Amount controls show focus on the enclosing currency field, not twice. */
:root :is(.quick-amount-input, .ta-amount-row, .amount-input-wrapper) > input:focus {
    outline: none;
    box-shadow: none;
}

.form-input::placeholder,
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-muted, rgba(255, 255, 255, 0.4));
}

/* Normalize boundaries without adding borders to composite controls' borderless inputs.
   Keep page-specific sizing, radii, backgrounds and focus rings. */
:root :is(input:not([type]), input[type="text"], input[type="email"], input[type="password"],
    input[type="number"], input[type="tel"], input[type="url"], input[type="search"],
    input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"],
    input[type="week"], textarea):not([hidden]):not(.input-borderless) {
    border-color: var(--control-border-color, var(--border-control, var(--border-color))) !important;
}

:root :where(input, textarea):where(:not(:disabled):not([readonly])):is(:hover, :focus) {
    --control-border-color: var(--accent-primary);
}

:root :is(input, textarea):is(.is-valid, .valid.modified):not(:is(.is-invalid, .input-invalid, .invalid, [aria-invalid="true"])) {
    --control-border-color: var(--success);
}

:root :is(input, textarea):is(.is-invalid, .input-invalid, .invalid, [aria-invalid="true"]) {
    --control-border-color: var(--danger);
}


/* ===== Select Dropdowns ===== */
/* Note: theme.css provides themed select styles with !important - this is fallback */
.form-select,
select:not(.location-select):not(.mobile-location-select) {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: 1px solid var(--border-control, var(--border-color, rgba(255, 255, 255, 0.15)));
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--input-bg, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #ffffff);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-select:hover,
select:not(.location-select):not(.mobile-location-select):hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.form-select:focus,
select:not(.location-select):not(.mobile-location-select):focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

.form-select option,
select:not(.location-select):not(.mobile-location-select) option {
    background: var(--bg-card, #1a1a2e);
    color: var(--text-primary, #ffffff);
    padding: 10px;
}


/* ===== Form Groups ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label:not(.checkbox-label):not(.form-check):not(.toggle-switch):not(.switch):not(.setting-toggle) {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, rgba(255, 255, 255, 0.7));
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* ===== Radio Buttons ===== */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
}

.radio-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin: 0;
}

.radio-label input[type="radio"]:hover {
    border-color: var(--accent-primary, var(--brand-primary));
}

.radio-label input[type="radio"]:checked {
    border-color: var(--accent-primary, var(--brand-primary));
    background: var(--accent-primary, var(--brand-primary));
}

.radio-label input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}


/* ===== Small Variants ===== */
.form-input-sm,
.form-control-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.form-select-sm {
    padding: 8px 36px 8px 12px;
    font-size: 13px;
}


/* ===== Disabled States ===== */
.form-input:disabled,
.form-control:disabled,
.form-select:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.02);
}


/* ===== Validation States ===== */
.form-input.is-invalid,
.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: #ef4444;
}

.form-input.is-invalid:focus,
.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-input.is-valid,
.form-control.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: #10b981;
}

.form-input.is-valid:focus,
.form-control.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.invalid-feedback {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #ef4444;
}


/* ===== Input Groups ===== */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group > input,
.input-group > select {
    flex: 1;
    border-radius: 0;
}

.input-group > *:first-child {
    border-radius: 8px 0 0 8px;
}

.input-group > *:last-child {
    border-radius: 0 8px 8px 0;
}

.input-group-text {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-control, var(--border-color, rgba(255, 255, 255, 0.15)));
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-size: 14px;
    display: flex;
    align-items: center;
}

/* Final shared select-arrow normalization.
   Several feature stylesheets add select background arrows; this late rule keeps
   the browser native arrow hidden and ensures all normal selects display a
   single CSS arrow. Opt out with .select-native when a platform-native control
   is intentionally desired. */
select:not(.select-native):not(.location-select):not(.mobile-location-select) {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 12px !important;
    padding-right: 36px !important;
}

select:not(.select-native):not(.location-select):not(.mobile-location-select)::-ms-expand {
    display: none;
}

[data-theme="dark"] select:not(.select-native):not(.location-select):not(.mobile-location-select) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
}

/* Keep real selects: unsupported browsers retain their native option picker.
   The specificity also overrides older theme and feature-specific select rules. */
:root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select) {
    box-sizing: border-box;
    min-inline-size: 0;
    max-inline-size: 100%;
    min-block-size: 44px;
    border-radius: 12px !important;
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-control, var(--border-color)) !important;
    box-shadow: var(--shadow-sm);
    text-overflow: ellipsis;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

:root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select):not(:disabled):hover {
    border-color: var(--accent-primary) !important;
}

:root select.select-pill:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select) {
    border-radius: 999px !important;
    background-color: color-mix(in srgb, var(--text-muted) 8%, var(--bg-card)) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

:root select.select-pill:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select):not(:disabled):hover {
    border-color: var(--accent-primary) !important;
}

:root select:not(.select-native):not([multiple]):not([size]):focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

:root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select):focus-visible {
    border-color: var(--accent-primary) !important;
}

:root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select):disabled {
    cursor: not-allowed;
    background-color: var(--bg-tertiary) !important;
    opacity: 0.6;
}

:root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select):is(.is-invalid, .invalid, [aria-invalid="true"]) {
    border-color: var(--danger) !important;
}

:root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select):is(.is-valid, .valid):not(.is-invalid):not(.invalid):not([aria-invalid="true"]) {
    border-color: var(--success) !important;
}

:root select:is(.select-native, [multiple], [size]):not(.location-select):not(.mobile-location-select) {
    appearance: auto !important;
    -webkit-appearance: auto !important;
    background-image: none !important;
}

@media (max-width: 768px), (pointer: coarse) {
    :root select:not([multiple]):not([size]) {
        min-block-size: 48px !important;
        min-inline-size: 0;
        max-inline-size: 100%;
        font-size: 16px !important;
    }

    :root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select) {
        padding-inline: 14px 40px !important;
    }
}

@supports (appearance: base-select) and selector(select::picker(select)) {
    :root select:not(.select-native):not([multiple]):not([size]),
    :root select:not(.select-native):not([multiple]):not([size])::picker(select) {
        appearance: base-select !important;
    }

    :root select:not(.select-native):not([multiple]):not([size]) {
        background-image: none !important;
        padding-inline-end: 14px !important;
        display: inline-flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    :root select:not(.select-native):not([multiple]):not([size]):not(.location-select):not(.mobile-location-select) {
        padding-inline-end: 14px !important;
    }

    :root select:not(.select-native):not([multiple]):not([size])::picker-icon {
        content: '';
        flex: 0 0 8px;
        inline-size: 8px;
        block-size: 8px;
        border-inline-end: 2px solid currentColor;
        border-block-end: 2px solid currentColor;
        rotate: 45deg;
        margin-block-start: -4px;
        color: var(--text-muted);
        transition: rotate 0.15s ease;
    }

    :root select:not(.select-native):not([multiple]):not([size]):open::picker-icon {
        rotate: 225deg;
        margin-block-start: 4px;
        color: var(--accent-primary);
    }

    :root select:not(.select-native):not([multiple]):not([size]):is(.location-select, .mobile-location-select)::picker-icon {
        color: inherit;
    }

    :root select:not(.select-native):not([multiple]):not([size])::picker(select) {
        box-sizing: border-box;
        min-inline-size: anchor-size(self-inline);
        max-inline-size: calc(100vw - 24px);
        max-block-size: min(360px, calc(100dvh - 24px));
        margin-block: 4px;
        padding: 6px;
        border: 1px solid var(--border-color);
        border-radius: 14px;
        background: var(--bg-card);
        color: var(--text-primary);
        box-shadow: var(--shadow-lg);
        overflow: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--text-muted) transparent;
        position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    }

    :root select:not(.select-native):not([multiple]):not([size]) option {
        box-sizing: border-box;
        display: flex;
        align-items: center;
        gap: 12px;
        min-block-size: 44px;
        padding: 10px 12px;
        border: 0;
        border-radius: 8px;
        background: transparent !important;
        color: var(--text-primary) !important;
        font: inherit;
        line-height: 1.4;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    :root select:not(.select-native):not([multiple]):not([size]) option:not(:disabled):is(:hover, :focus) {
        background: var(--bg-hover) !important;
        outline: 2px solid var(--accent-primary);
        outline-offset: -2px;
    }

    :root select:not(.select-native):not([multiple]):not([size]) option:checked {
        background: var(--accent-primary-light) !important;
        color: var(--accent-text) !important;
        font-weight: 600;
    }

    :root select:not(.select-native):not([multiple]):not([size]) option::checkmark {
        order: 1;
        margin-inline-start: auto;
        color: var(--accent-text);
    }

    :root select:not(.select-native):not([multiple]):not([size]) option:disabled {
        color: var(--text-disabled) !important;
        cursor: not-allowed;
    }

    :root select:not(.select-native):not([multiple]):not([size]) optgroup {
        background: transparent !important;
        color: var(--text-muted) !important;
        font-weight: 600;
    }

    @media (max-width: 768px), (pointer: coarse) {
        :root select:not(.select-native):not([multiple]):not([size]) option {
            min-block-size: 48px;
            font-size: 16px;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    :root select,
    :root select::picker-icon {
        transition: none !important;
    }
}


/* ===== Number Input Spinners ===== */
input[type="number"] {
    -moz-appearance: textfield;
}

/* Webkit (Chrome, Safari, Edge) spinner buttons */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 100%;
    margin: 0;
    margin-right: -14px;
    background: transparent;
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    cursor: pointer;
    opacity: 1;
    position: relative;
}

/* Custom number input with visible spinners */
input[type="number"].show-spinners {
    -moz-appearance: auto;
    appearance: auto;
}

/* Style number inputs with custom +/- buttons */
.number-input-wrapper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-control, var(--border-color, rgba(255, 255, 255, 0.15)));
    border-radius: 8px;
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.number-input-wrapper:hover {
    border-color: var(--accent-primary, var(--brand-primary));
}

.number-input-wrapper:focus-within {
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

.number-input-wrapper input[type="number"] {
    flex: 1;
    border: none;
    background: transparent;
    text-align: center;
    padding: 10px 8px;
    min-width: 60px;
}

.number-input-wrapper input[type="number"]:focus {
    outline: none;
    box-shadow: none;
}

.number-input-wrapper .spinner-btn {
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    font-size: 18px;
    font-weight: 600;
    border: none;
    padding: 0;
}

.number-input-wrapper .spinner-btn:hover {
    background: var(--accent-primary, var(--brand-primary));
    color: white;
}

.number-input-wrapper .spinner-btn:active {
    background: var(--accent-primary-dark, var(--brand-primary-hover));
    transform: scale(0.95);
}

.number-input-wrapper .spinner-btn.decrement {
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

.number-input-wrapper .spinner-btn.increment {
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

/* Inline number stepper (compact) */
.number-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border-control, var(--border-color, rgba(255, 255, 255, 0.15)));
    border-radius: 8px;
    overflow: hidden;
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
}

.number-stepper input[type="number"] {
    width: 50px;
    text-align: center;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 14px;
}

.number-stepper input[type="number"]:focus {
    outline: none;
    box-shadow: none;
}

.number-stepper button {
    width: 32px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #ffffff);
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.number-stepper button:hover {
    background: var(--accent-primary, var(--brand-primary));
    color: white;
}

.number-stepper button:active {
    transform: scale(0.9);
}

.number-stepper button:first-child {
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

.number-stepper button:last-child {
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}
