/* uikit.css — единые контролы формы: чекбокс, радио, переключатель, поля ввода, выпадающий список.
   Грузится ПОСЛЕ styles.css и ДО модульных css (assistant.css, billing.css…) — модульные правила
   могут уточнять размеры, но внешний вид (цвета, рамки, галочка) един.
   Размер чекбокса/радио задаётся переменной --ck (по умолчанию 18px): .bulk{--ck:14px}. */

:root {
    --ck: 18px;
    --ck-bg: #ffffff;
    --ck-border: #b4bac6;
    --ck-border-hover: var(--accent);
    --field-bg: var(--surface);
    --field-border: var(--border-strong, var(--border));
    --field-border-hover: var(--text-faint);
    --field-ring: 0 0 0 3px var(--accent-soft);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --ck-bg: #262b34; --ck-border: #4a515d; --field-border: #3a4049; }
}
:root[data-theme="dark"] { --ck-bg: #262b34; --ck-border: #4a515d; --field-border: #3a4049; }

/* ───────── чекбокс ───────── */
input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    box-sizing: border-box !important;
    width: var(--ck) !important; height: var(--ck) !important; min-width: var(--ck); min-height: var(--ck);
    padding: 0 !important; flex: none;
    margin: 0;
    border: 1.5px solid var(--ck-border); border-radius: calc(var(--ck) * .3);
    background-color: var(--ck-bg); background-repeat: no-repeat; background-position: center; background-size: 78%;
    display: inline-block; vertical-align: middle; position: relative; top: -1px;
    cursor: pointer; transition: background-color .12s var(--ease, ease), border-color .12s var(--ease, ease), box-shadow .12s var(--ease, ease);
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--ck-border-hover); }
input[type="checkbox"]:checked {
    background-color: var(--accent); border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.4 8.6l3 3 6.2-7.2'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate {
    background-color: var(--accent); border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M4 8h8'/%3E%3C/svg%3E");
}
input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--field-ring); border-color: var(--accent); border-radius: calc(var(--ck) * .3); }
input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
input[type="checkbox"]:checked:disabled { opacity: .55; }

/* ───────── радио ───────── */
input[type="radio"] {
    -webkit-appearance: none; appearance: none;
    box-sizing: border-box !important;
    width: var(--ck) !important; height: var(--ck) !important; min-width: var(--ck); min-height: var(--ck);
    padding: 0 !important; flex: none; margin: 0;
    border: 1.5px solid var(--ck-border); border-radius: 50%; background-color: var(--ck-bg);
    display: inline-block; vertical-align: middle; position: relative; top: -1px;
    cursor: pointer; transition: border-color .12s var(--ease, ease), background-color .12s var(--ease, ease), box-shadow .12s var(--ease, ease);
}
input[type="radio"]:hover:not(:disabled) { border-color: var(--ck-border-hover); }
input[type="radio"]:checked { border-color: var(--accent); background-color: var(--accent); box-shadow: inset 0 0 0 calc(var(--ck) * .24) var(--ck-bg); }
input[type="radio"]:focus-visible { outline: none; box-shadow: var(--field-ring); border-color: var(--accent); }
input[type="radio"]:checked:focus-visible { box-shadow: inset 0 0 0 calc(var(--ck) * .24) var(--ck-bg), 0 0 0 3px var(--accent-soft); }
input[type="radio"]:disabled { opacity: .5; cursor: not-allowed; }

/* ───────── переключатель: <input type="checkbox" class="ui-switch"> ───────── */
input[type="checkbox"].ui-switch {
    width: 36px !important; height: 20px !important; min-width: 36px; min-height: 20px; border-radius: 99px; border: 0;
    background-color: var(--border-strong, #c9ced8); background-image: none; position: relative; top: 0;
}
input[type="checkbox"].ui-switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s var(--ease, ease);
}
input[type="checkbox"].ui-switch:checked { background-color: var(--accent); background-image: none; }
input[type="checkbox"].ui-switch:checked::after { transform: translateX(16px); }

/* подпись-обёртка вокруг чекбокса */
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { cursor: pointer; }
label:has(> input:disabled) { cursor: not-allowed; }

/* ───────── поля ввода (нулевая специфичность: локальные классы вправе уточнять размеры/вид) ───────── */
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"]), textarea) {
    box-sizing: border-box; max-width: 100%;
    padding: 8px 10px; border: 1px solid var(--field-border); border-radius: var(--radius-s);
    background-color: var(--field-bg); color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.35;
    transition: border-color .12s var(--ease, ease), box-shadow .12s var(--ease, ease), background-color .12s var(--ease, ease);
}
:where(textarea) { resize: vertical; min-height: 64px; }
:where(select:not(.ui-sel-native)) {
    box-sizing: border-box; max-width: 100%; padding: 8px 30px 8px 10px; border: 1px solid var(--field-border); border-radius: var(--radius-s);
    background-color: var(--field-bg); color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer;
    -webkit-appearance: none; appearance: none; background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868d9b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; }

/* состояния (только цвета — раскладку и размеры не трогаем) */
input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"]):not(:disabled):not(:read-only):hover,
textarea:not(:disabled):not(:read-only):hover { border-color: var(--field-border-hover); }
input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"]):focus,
textarea:focus, select:focus { border-color: var(--accent); }
input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"]):focus-visible,
textarea:focus-visible, select:focus-visible { outline: none; box-shadow: var(--field-ring); border-radius: var(--radius-s); }
input:disabled, textarea:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 40px var(--field-bg) inset; -webkit-text-fill-color: var(--text); caret-color: var(--text); }
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"] { min-height: 36px; color-scheme: light dark; }
:root[data-theme="light"] input[type="date"], :root[data-theme="light"] input[type="time"], :root[data-theme="light"] input[type="datetime-local"] { color-scheme: light; }
:root[data-theme="dark"] input[type="date"], :root[data-theme="dark"] input[type="time"], :root[data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
input[type="range"] { accent-color: var(--accent); }
input[type="file"] { font: inherit; font-size: 13px; color: var(--text-dim); max-width: 100%; }
input[type="file"]::file-selector-button {
    margin-right: 10px; padding: 7px 12px; border: 1px solid var(--field-border); border-radius: var(--radius-s);
    background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: background-color .12s;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-3); }

/* явные классы для нестандартной разметки */
.ui-input { box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--field-border); border-radius: var(--radius-s); background-color: var(--field-bg); color: var(--text); font: inherit; font-size: 13.5px; }

/* ───────── выпадающий список (замена <select>) ───────── */
.ui-sel { position: relative; display: inline-block; vertical-align: middle; max-width: 100%; width: var(--ui-w, auto); }
.ui-sel[hidden] { display: none !important; }
.ui-sel.ui-fill { display: block; width: 100%; }
.ui-sel-native {
    position: absolute !important; width: 1px !important; height: 1px !important; min-width: 0 !important; min-height: 0 !important;
    margin: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important;
    overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important;
}
.ui-sel .ui-sel-btn { color: var(--text); min-height: 36px; padding: 7px 10px; border-radius: var(--radius-s); border-color: var(--field-border); background: var(--field-bg); font-family: inherit; font-size: 13.5px; line-height: 1.3; transition: border-color .12s var(--ease, ease), box-shadow .12s var(--ease, ease), background-color .12s var(--ease, ease); }
.ui-sel .ui-sel-btn:hover:not(:disabled) { border-color: var(--field-border-hover); background: var(--field-bg); }
.ui-sel .ui-sel-btn.open, .ui-sel .ui-sel-btn:focus-visible { border-color: var(--accent); box-shadow: var(--field-ring); outline: none; }
.ui-sel .ui-sel-btn:disabled { opacity: .6; cursor: not-allowed; }
.ui-sel .ui-sel-btn.ui-ph .cs-label { color: var(--text-faint); }
.ui-sel .ui-sel-btn .cs-label { text-align: left; }
.ui-sel.ui-sel-sm .ui-sel-btn { min-height: 28px; padding: 3px 8px; font-size: 12.5px; }
.ui-sel-ic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; font-size: 14px; line-height: 1; }
.ui-sel-ic[hidden] { display: none; }
.ui-sel-ic img, .ui-opt-ic img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; }
.ui-dot { width: 9px; height: 9px; border-radius: 50%; }

.ui-pop.cs-panel {
    position: fixed; right: auto; z-index: 10050; width: max-content; padding: 6px; box-sizing: border-box;
    border-radius: var(--radius-m); overscroll-behavior: contain; animation: ui-pop-in .12s var(--ease, ease);
}
.ui-pop.up { animation-name: ui-pop-in-up; }
@keyframes ui-pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes ui-pop-in-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ui-pop .cs-search { margin: -6px -6px 4px; padding: 8px 8px 6px; border-bottom: 0; border-radius: var(--radius-m) var(--radius-m) 0 0; }
.cs-panel .cs-search-input {
    box-sizing: border-box; padding: 9px 12px; border: 1.5px solid var(--field-border); border-radius: var(--radius-s); background: var(--bg); font-size: 13.5px;
}
.cs-panel .cs-search-input:focus, .cs-panel .cs-search-input:focus-visible { border-color: var(--accent); box-shadow: var(--field-ring); outline: none; }
.ui-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 0 !important; border-radius: 8px; font-size: 13.5px; line-height: 1.3; cursor: pointer; user-select: none; }
.ui-opt:hover { background: transparent; }
.ui-opt.hl { background: var(--surface-2); }
.ui-opt.active { font-weight: 600; color: var(--text); }
.ui-opt.active .cs-label { color: var(--accent-text); }
.ui-opt.disabled { opacity: .45; cursor: not-allowed; }
.ui-opt .cs-label { white-space: normal; overflow-wrap: anywhere; }
.ui-opt .ui-opt-cb { pointer-events: none; }
.ui-opt .ui-tick { flex: none; width: 15px; height: 15px; color: var(--accent); }
.ui-opt-ic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; font-size: 15px; line-height: 1; border-radius: 6px; }
.ui-opt-ic.ui-dot { width: 9px; height: 9px; }
.ui-opt .cs-key { max-width: 50%; }
.ui-reset { margin-top: 4px; border-top: 1px solid var(--border) !important; border-radius: 0 0 8px 8px; color: var(--text-dim); justify-content: center; }
.ui-grp { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); }
.ui-grp[hidden] { display: none; }
.ui-grp:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border); }
.ui-pop .cs-empty { padding: 14px 10px; }

/* телефон: крупнее зоны нажатия, поле поиска ≥16px (иначе iOS приближает страницу при фокусе) */
@media (pointer: coarse) {
    .ui-opt { padding: 11px 10px; }
    .ui-pop .cs-search-input { font-size: 16px; }
    .ui-sel .ui-sel-btn { min-height: 40px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .ui-pop.cs-panel { animation: none; } input, .ui-sel-btn { transition: none !important; } }
