/* Форма заявки — Битрикс24 (вкладка в задаче) и телефон (m.php) */
:root {
    --text: #1e293b;
    --muted: #64748b;
    --label: #334155;
    --border: #e2e8f0;
    --field: #f8fafc;
    --primary: #4f46e5;
    --primary-2: #0ea5e9;
    --primary-soft: #eef2ff;
    --focus: #6366f1;
    --error: #e11d48;
    --error-bg: #fff1f2;
    --success: #059669;
    --success-bg: #ecfdf5;
    --warn-bg: #fffbeb;
    --bg: #fff;
    --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
body.mobile { background: linear-gradient(180deg, #eef2ff 0, #f8fafc 220px); min-height: 100vh; }

.card {
    max-width: 720px;
    padding: 20px 22px 24px;
}
body.mobile .card {
    margin: 0 auto;
    padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Шапка ---------- */
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.logo { width: 48px; height: 48px; border-radius: 14px; flex: none; box-shadow: 0 6px 16px rgba(79, 70, 229, .25); }
.head-text { min-width: 0; }
h1 { font-size: 21px; font-weight: 700; margin: 0; color: var(--text); letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 13px; }
.task-ref { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin-top: 3px; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: #4338ca; font-size: 12.5px; font-weight: 500; }
.task-ref span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Поля ---------- */
.field { margin-bottom: 18px; }
label { display: block; margin-bottom: 7px; color: var(--label); font-size: 13.5px; font-weight: 600; }
.req { color: var(--error); }

input[type=text], input[type=number], textarea, select {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: var(--field);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
textarea::placeholder, input::placeholder { color: #94a3b8; }
select { appearance: none; background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center; padding-right: 38px; }
input:focus, textarea:focus, select:focus { border-color: var(--focus); background: #fff; box-shadow: 0 0 0 4px rgba(99, 102, 241, .14); }
body.mobile input, body.mobile textarea, body.mobile select { font-size: 16px; } /* iOS не увеличивает страницу */

.field.invalid input, .field.invalid textarea, .field.invalid select, .field.invalid .drop { border-color: var(--error); }
.err { color: var(--error); font-size: 12.5px; margin-top: 6px; }
.err:empty { display: none; }

/* ---------- Фото ---------- */
.drop {
    border-radius: var(--radius);
    padding: 4px;
    transition: background .15s, box-shadow .15s;
}
.drop.over { background: var(--primary-soft); box-shadow: 0 0 0 2px var(--focus) inset; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.thumbs { display: contents; list-style: none; padding: 0; margin: 0; }
.add-photo {
    aspect-ratio: 1; border: 1.5px dashed #a5b4fc; border-radius: 14px; background: #f5f7ff; color: #4f46e5;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    font: 600 12.5px/1.2 inherit; font-family: inherit; cursor: pointer; transition: background .15s, transform .1s;
}
.add-photo:hover { background: var(--primary-soft); }
.add-photo:active { transform: scale(.97); }
.add-photo svg { width: 26px; height: 26px; }
.thumbs li { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #eef0f2; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .noimg { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 11px; color: var(--muted); padding: 6px; text-align: center; word-break: break-all; }
.thumbs .size { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 8px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); }
.thumbs .rm {
    position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border: 0; border-radius: 50%;
    background: rgba(15, 23, 42, .6); color: #fff; font-size: 16px; line-height: 26px; cursor: pointer; padding: 0;
    backdrop-filter: blur(4px);
}
.thumbs .rm:hover { background: var(--error); }
.photo-hint { margin-top: 8px; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 22px; border-radius: 14px; border: 1.5px solid transparent;
    font: 600 15px/1 inherit; font-family: inherit; cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 8px 20px rgba(79, 70, 229, .28); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(79, 70, 229, .36); }
.btn-light { background: #fff; color: var(--label); border-color: var(--border); }
.btn-light:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn[disabled] { opacity: .6; cursor: default; transform: none; }
.btn .spin { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.actions .btn-primary { min-width: 220px; height: 50px; font-size: 16px; }
body.mobile .actions {
    position: sticky; bottom: 0; flex-direction: column; align-items: stretch; gap: 8px;
    margin: 6px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, #f8fafc 30%);
}
body.mobile .actions .btn-primary { width: 100%; }

/* ---------- Сообщения ---------- */
.alert { padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: var(--error-bg); color: #9f1239; border: 1px solid #fecdd3; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert a { color: var(--primary); font-weight: 600; }

.warnings { padding-left: 18px; color: #92400e; font-size: 13px; }
.warnings:empty { display: none; }

/* Экран «Заявка отправлена» */
.done { text-align: center; padding: 28px 8px 8px; animation: pop .25s ease-out; }
.done-icon { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: flex; align-items: center; justify-content: center; }
.done-icon svg { width: 38px; height: 38px; }
.done h2 { margin: 0 0 6px; font-size: 20px; }
.done p { margin: 0 auto 18px; max-width: 420px; color: var(--muted); }
.done .done-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.done .warnings { text-align: left; max-width: 460px; margin: 0 auto 14px; }

/* ---------- Вопросы завхоза (видны, пока нет ответа) ---------- */
.badge-q { background: var(--error); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.pending { border-radius: var(--radius); padding: 14px; margin-bottom: 20px; background: var(--warn-bg); border: 1px solid #fde68a; }
.pending-head { font-weight: 700; color: #92400e; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.q { padding: 12px; border-radius: 14px; background: #fff; border: 1px solid #fef3c7; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); transition: opacity .4s ease, transform .4s ease; }
.q + .q { margin-top: 10px; }
.q-leaving { opacity: 0; transform: translateY(-6px); }
.q-ref { font-size: 12px; margin-bottom: 8px; }
.q-bubble { position: relative; display: inline-block; max-width: 100%; padding: 10px 13px; border-radius: 4px 14px 14px 14px; background: #f1f5f9; white-space: pre-wrap; }
.q-from { display: block; font-size: 12px; font-weight: 700; color: #4338ca; margin-bottom: 2px; }
.q-form { margin-top: 10px; display: flex; gap: 8px; align-items: flex-end; }
.q-form textarea { min-height: 46px; height: 46px; padding: 11px 13px; resize: none; }
.q-form .q-send { height: 46px; width: 46px; padding: 0; flex: none; border-radius: 14px; }
.q-form .err { flex-basis: 100%; }
.q-form-wrap .err { margin-top: 6px; }
.q-answer { margin-top: 10px; font-size: 14px; color: var(--success); font-weight: 600; }

/* ---------- Телефон: навигация и выбор задачи ---------- */
.mobile-nav { display: flex; justify-content: space-between; align-items: center; max-width: 720px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 16px 4px; font-size: 15px; }
.mobile-nav a { color: var(--primary); text-decoration: none; font-weight: 600; }
.mobile-nav a.muted { color: var(--muted); font-weight: 500; }
.task-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.task-list a { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--border); color: inherit; text-decoration: none; font-weight: 500; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.task-list a::after { content: "›"; margin-left: auto; color: #94a3b8; font-size: 22px; line-height: 1; }
.task-list a:active { background: var(--primary-soft); }
.task-manual label { display: block; margin-bottom: 7px; color: var(--label); }
.task-manual .row { display: flex; gap: 8px; }
.task-manual input { flex: 1; min-width: 0; }
.task-manual .btn { flex: none; }
.small { font-size: 13px; margin-top: 22px; }
.small a { color: var(--muted); }

/* ---------- Страница установки ---------- */
.install .steps { list-style: none; padding: 0; margin: 0 0 14px; }
.install .steps li { padding: 4px 0 4px 26px; position: relative; }
.install .steps li::before { position: absolute; left: 0; font-weight: 700; }
.install .steps li.ok::before { content: "✓"; color: var(--success); }
.install .steps li.fail::before { content: "!"; color: var(--error); }
.mobile-link { margin-top: 16px; padding: 14px; border: 1px solid #c7d2fe; background: var(--primary-soft); border-radius: 14px; display: grid; gap: 8px; font-size: 14px; }
.mobile-link input { width: 100%; font-family: ui-monospace, monospace; font-size: 13px; }

@media (max-width: 520px) {
    .card { padding: 16px 14px 20px; }
    .actions { flex-direction: column; align-items: stretch; }
    .actions .btn-primary { width: 100%; min-width: 0; }
    h1 { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
.q-form { flex-wrap: wrap; }
.q-form textarea { flex: 1 1 0; width: auto; min-width: 0; }
a.btn { text-decoration: none; }

/* Кнопка «Оставить заявку» в чатах задач (страница настроек) */
.tb-panel { margin-top: 18px; padding: 16px; border: 1px solid var(--border, #e2e8f0); border-radius: 14px; background: #fff; }
.tb-panel h2 { margin: 0 0 6px; font-size: 16px; }
.tb-panel .row { display: flex; gap: 8px; margin: 10px 0; }
.tb-panel .row input { flex: 1 1 0; min-width: 0; }
.tb-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.tb-results { list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; }
.tb-results li { padding: 4px 0; }
.tb-results li.ok::before { content: "✔ "; color: #059669; }
.tb-results li.skip::before { content: "• "; color: #64748b; }
.tb-results li.fail { color: #b91c1c; }
.tb-results li.fail::before { content: "✖ "; }
