/* Окно «Запросить счёт» (.ivm): стили вынесены из прежнего product.css без изменений (карточка товара теперь — каркас krom, product.css). */
/* ---------- Окно «Запросить счёт» (.ivm) ----------
   Всплывающий белый лист поверх затемнения: тень только у него. Слева — данные для счёта (поля на --surface-2, без рамок),
   справа — предпросмотр на --surface-2; главная кнопка чёрная. Телефон (≤ 640 px) — лист снизу во всю ширину, одна колонка.
   Образец и правила — макет /design/, «Карточка товара: состояния» → «Окно запроса счёта». */
.ivm { box-sizing: border-box; width: min(980px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0; border-radius: var(--radius-lg);
	background: var(--surface); color: var(--ink); font-family: var(--font-sans); overflow: auto; overscroll-behavior: contain;
	box-shadow: 0 24px 64px rgba(15, 17, 22, .22); }
.ivm::backdrop { background: rgba(15, 17, 22, .42); }
.ivm *, .ivm *::before, .ivm *::after { box-sizing: border-box; }
.ivm--static { display: block; width: 100%; max-height: none; margin: 0; overflow: visible; }

.ivm__lay { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "head head" "form sum" "acts sum" "done sum";
	gap: 0 32px; align-items: start; padding: 28px 32px 32px; }
.ivm__head { grid-area: head; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.ivm__head h2 { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.ivm__lead { max-width: 56ch; margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.ivm__x { flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin: -6px -8px 0 0; padding: 0; border: 0; border-radius: 50%;
	background: var(--surface-2); color: var(--ink); cursor: pointer; transition: background .15s ease; }
.ivm__x:hover { background: var(--surface-3); }
.ivm__x svg { width: 18px; height: 18px; }
.ivm__form { grid-area: form; display: grid; gap: 16px; min-width: 0; }
.ivm__form[hidden] { display: none; }

/* Кто покупает: переключатель на серой заливке, выбранный — белый */
.ivm-kind { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--radius-md); background: var(--surface-2); }
.ivm-kind label { display: block; margin: 0; cursor: pointer; }
.ivm-kind input { position: absolute; opacity: 0; pointer-events: none; }
.ivm-kind span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted);
	font-size: 14px; font-weight: 600; text-align: center; line-height: 1.2; transition: background .15s ease, color .15s ease; }
.ivm-kind label:hover span { color: var(--ink); }
.ivm-kind input:checked + span { background: var(--surface); color: var(--ink); }
.ivm-kind input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 1px; }

/* Поля: подпись над полем, поле — серая заливка без рамки; фокус — тёмная граница; ошибка — красная подпись и граница */
.ivm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.ivm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ivm-field[hidden] { display: none; }
.ivm-field--wide { grid-column: 1 / -1; }
.ivm-field label { margin: 0; color: var(--ink-2); font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.ivm-req { color: #b3261e; }
.ivm-field input[type="text"], .ivm-field input[type="tel"], .ivm-field input[type="email"], .ivm-field textarea {
	display: block; width: 100%; height: 46px; margin: 0; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-md);
	background: var(--surface-2); color: var(--ink); font: 400 15px/1.3 var(--font-sans); outline: 0; box-shadow: none; transition: border-color .15s ease, background .15s ease; }
.ivm-field textarea { height: auto; min-height: 70px; padding: 12px 14px; resize: vertical; }
.ivm-field input::placeholder, .ivm-field textarea::placeholder { color: var(--muted); opacity: .8; }
.ivm-field input:focus, .ivm-field textarea:focus { border-color: var(--ink); background: var(--surface); }
.ivm-field input.is-bad, .ivm-field textarea.is-bad { border-color: #b3261e; }
.ivm-hint { color: var(--muted); font-size: 12px; line-height: 1.35; }
.ivm-err { color: #b3261e; font-size: 12.5px; line-height: 1.35; }
.ivm-err:empty { display: none; }
.ivm-alert { padding: 12px 14px; border-radius: var(--radius-md); background: var(--badge-red-bg); color: var(--badge-red-fg); font-size: 14px; font-weight: 500; line-height: 1.4; }
.ivm-alert[hidden] { display: none; }

.ivm-terms { display: grid; gap: 4px; }
.ivm-terms label { display: flex; gap: 10px; align-items: flex-start; margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.45; cursor: pointer; }
.ivm-terms input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); }
.ivm-terms a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--surface-3); }
.ivm-terms a:hover { text-decoration-color: var(--ink); }

/* Предпросмотр счёта: серая плитка, строка «товар × количество», итог */
.ivm__sum { grid-area: sum; position: sticky; top: 0; padding: 20px; border-radius: var(--radius-lg); background: var(--surface-2); }
.ivm__sum h3 { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--ink-2); }
.ivm-sum.is-counting { opacity: .45; }
.ivm-lines { display: grid; gap: 10px; margin: 0 0 14px; padding: 0; list-style: none; }
.ivm-lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; margin: 0; padding: 12px; border-radius: var(--radius-md); background: var(--surface); }
.ivm-lines__name { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.ivm-lines__name small { color: var(--muted); font-size: 12px; font-weight: 400; }
.ivm-lines .cart-full__qty { grid-area: auto; justify-self: start; height: 36px; background: var(--surface-2); }
.ivm-lines .cart-full__qty-btn { width: 34px; font-size: 16px; }
.ivm-lines .cart-full__qty-num { min-width: 30px; font-size: 14px; }
.ivm-lines__sum { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; font-variant-numeric: tabular-nums; }
.ivm-lines__sum b { font-size: 15px; font-weight: 700; }
.ivm-lines__sum small { color: var(--muted); font-size: 12px; }
.ivm-total { display: grid; gap: 8px; margin: 0; font-size: 14px; }
.ivm-total > div { display: flex; justify-content: space-between; gap: 12px; }
.ivm-total dt { color: var(--ink-2); }
.ivm-total dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.ivm-total .ivm-later { color: var(--muted); font-weight: 500; }
.ivm-total__sum { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--surface-3); align-items: baseline; }
.ivm-total__sum dt { color: var(--ink); font-weight: 600; }
.ivm-total__sum dd { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.ivm-note { margin: 14px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* Действия: главная — чёрная, «Отмена» — текстом */
.ivm__acts { grid-area: acts; display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.ivm-go { flex: 1 1 auto; min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--radius-sm); background: var(--ink); color: var(--dark-ink);
	font: 600 15px/1.1 var(--font-sans); cursor: pointer; transition: opacity .15s ease; }
.ivm-go:hover:not(:disabled) { opacity: .88; }
.ivm-go:disabled { opacity: .5; cursor: default; }
.ivm-go[hidden] { display: none; }
.ivm-off { flex: none; min-height: 48px; padding: 0 18px; border: 0; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink);
	font: 600 14px/1.1 var(--font-sans); cursor: pointer; transition: background .15s ease; }
.ivm-off:hover { background: var(--surface-3); }
.ivm__acts .ivm-go + .ivm-off { order: 1; }

/* Итог после отправки: вместо полей */
.ivm-done { grid-area: form; display: grid; gap: 10px; padding: 20px; border-radius: var(--radius-md); background: var(--badge-green-bg); color: var(--badge-green-fg); font-size: 14px; line-height: 1.55; }
.ivm-done[hidden] { display: none; }
.ivm-done h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: inherit; }
.ivm-done p { margin: 0; }
.ivm-done a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ivm-done__links { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 4px !important; }

/* Узкое окно: колонки друг под другом, предпросмотр сверху */
@media (max-width: 860px) {
	.ivm__lay { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "sum" "form" "acts" "done"; padding: 22px 22px 26px; }
	.ivm__sum { position: static; margin-bottom: 20px; }
	.ivm-done { grid-area: done; margin-bottom: 4px; }
}
/* Телефон: лист снизу во всю ширину; шрифт полей 16 px — иначе iPhone приближает страницу при вводе */
@media (max-width: 640px) {
	.ivm:not(.ivm--static) { width: 100%; max-width: 100%; max-height: calc(100dvh - 12px); margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
	.ivm__lay { padding: 18px 16px 22px; }
	.ivm__head { margin-bottom: 16px; }
	.ivm__head h2 { font-size: 20px; }
	.ivm__lead { font-size: 13.5px; }
	.ivm-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
	.ivm-field input[type="text"], .ivm-field input[type="tel"], .ivm-field input[type="email"], .ivm-field textarea { font-size: 16px; }
	.ivm__sum { padding: 16px; }
	.ivm__acts { flex-direction: column-reverse; align-items: stretch; margin-top: 16px; }
	.ivm__acts .ivm-go + .ivm-off { order: 0; }
	.ivm-total__sum dd { font-size: 20px; }
}


/* Выбрать организацию из сохранённых в кабинете (владелец 24.10.2026) */
.ivm-pick { display: grid; gap: 8px; }
.ivm-pick__title { color: var(--muted); font-size: 13px; font-weight: 500; }
.ivm-pick__q { width: 100%; }
.ivm-pick__list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 180px; overflow-y: auto; }
.ivm-co { display: grid; gap: 1px; padding: 8px 12px; border: 0; border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.ivm-co[hidden] { display: none; }
.ivm-co:hover { background: var(--surface-3); }
.ivm-co b { font-size: 13px; font-weight: 600; }
.ivm-co span { color: var(--muted); font-size: 12px; }
.ivm-co.is-on { background: var(--ink); color: var(--dark-ink); }
.ivm-co.is-on span { color: var(--grey-lo); }
