/* Десктопная вебморда. Без адаптива/медиазапросов — по правилам проекта. */
* { box-sizing: border-box; }
body {
    margin: 0;
    font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1d2330;
    background: #f4f6f9;
}
a { color: #2a6df4; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    background: #1d2330;
    color: #fff;
}
.topbar .brand { color: #fff; font-weight: 600; }
.topbar .topnav a { color: #c9d4e8; margin-right: 16px; }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .user span { color: #c9d4e8; }
form.inline { display: inline; margin: 0; }
button.link {
    background: none; border: none; color: #ff9d9d; cursor: pointer; padding: 0; font: inherit;
}

.content { padding: 20px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 16px; }

/* вход */
body.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card {
    background: #fff; padding: 28px 32px; border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08); width: 320px;
}
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #5a6477; }
.form input { padding: 8px 10px; border: 1px solid #cfd6e4; border-radius: 6px; font-size: 14px; }
button {
    padding: 8px 16px; border: 1px solid #2a6df4; background: #2a6df4; color: #fff;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
button:hover { background: #1f5ad6; }
.error { color: #c0392b; }

/* счётчики */
.counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
    background: #e8edf6; color: #41506b; padding: 3px 10px; border-radius: 12px; font-size: 12px;
}
.chip.total { background: #1d2330; color: #fff; }

/* фильтры */
.filters {
    background: #fff; border: 1px solid #e3e8f0; border-radius: 8px;
    padding: 12px 14px; margin-bottom: 16px;
}
.filter-statuses { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row input, .filter-row select {
    padding: 7px 9px; border: 1px solid #cfd6e4; border-radius: 6px; font-size: 13px;
}
label.check { font-size: 12px; color: #5a6477; display: inline-flex; align-items: center; gap: 4px; }
.btn-link { padding: 8px 12px; }

/* таблица */
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e3e8f0; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef1f6; }
table.grid th { background: #f0f3f8; font-size: 12px; color: #5a6477; text-transform: uppercase; }
table.grid tr.flagged { background: #fff7ed; }
table.grid td.empty { text-align: center; color: #8a93a5; padding: 24px; }

.status { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #e8edf6; color: #41506b; }
.status-published { background: #d7f5e0; color: #1e7a45; }
.status-in_review { background: #fdeecb; color: #8a6d12; }
.status-error { background: #fbdcdc; color: #b02a2a; }

.pager { margin-top: 14px; }

/* ── рабочее место контентщика ─────────────────────────────────────────── */
.toolbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: #fff; border: 1px solid #e3e8f0; border-radius: 8px;
    padding: 8px 12px; margin-bottom: 12px;
}
.toolbar .speed { margin-left: auto; color: #5a6477; font-size: 13px; }
button.primary { background: #1e7a45; border-color: #1e7a45; }
button.primary:hover { background: #176236; }

.lock-banner {
    background: #fdeecb; color: #8a6d12; border: 1px solid #f0d896;
    padding: 10px 14px; border-radius: 8px; margin-bottom: 12px;
}

.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.card-left, .card-right { background: #fff; border: 1px solid #e3e8f0; border-radius: 8px; padding: 16px; }
.card-left h2, .card-right h2 { font-size: 14px; margin: 18px 0 8px; color: #41506b; }
.prod-head h1 { font-size: 18px; margin: 0 0 6px; }
.prod-head .meta { display: flex; gap: 14px; flex-wrap: wrap; color: #5a6477; font-size: 13px; align-items: center; }

.text-field { margin-bottom: 12px; }
.text-field label { display: block; font-size: 12px; color: #5a6477; margin-bottom: 4px; }
.text-field .ver { color: #2a6df4; margin-left: 6px; }
.text-field .save-state { color: #1e7a45; margin-left: 6px; }
.text-field textarea {
    width: 100%; border: 1px solid #cfd6e4; border-radius: 6px; padding: 8px; font: inherit; resize: vertical;
}

/* плитки изображений + dropzone */
.tiles {
    display: flex; flex-wrap: wrap; gap: 8px; min-height: 80px;
    border: 1px dashed #cfd6e4; border-radius: 8px; padding: 8px; background: #fafbfd;
}
.tiles.dropzone { transition: background .1s; }
.tile {
    width: 120px; border: 1px solid #e3e8f0; border-radius: 6px; background: #fff;
    padding: 6px; cursor: grab; user-select: none;
}
.tile.dragging { opacity: .4; }
.tile .thumb {
    width: 100%; height: 80px; background: #eef1f6; border-radius: 4px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.tile .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile .thumb .ph { color: #8a93a5; font-size: 13px; }
.tile .tile-label { font-size: 11px; color: #5a6477; margin: 4px 0; text-align: center; }
.process-menu { display: none; flex-wrap: wrap; gap: 3px; }
.process-btn {
    font-size: 10px; padding: 2px 5px; background: #eef1f6; color: #41506b;
    border: 1px solid #d6deea; border-radius: 4px; cursor: pointer;
}
.process-btn:hover { background: #e0e7f2; }

.picklist { list-style: none; padding: 0; margin: 0; }
.picklist li { padding: 4px 0; border-bottom: 1px solid #f0f3f8; }
.picklist .tag { background: #e8edf6; color: #41506b; font-size: 11px; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.hint { color: #8a93a5; font-size: 13px; }

/* тосты */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { padding: 8px 14px; border-radius: 6px; color: #fff; font-size: 13px; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.toast.ok { background: #1e7a45; }
.toast.err { background: #c0392b; }

/* создание товара / шапка списка */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.btn-primary {
    background: #2a6df4; color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 14px;
}
.btn-primary:hover { background: #1f5ad6; text-decoration: none; }
.form-wide { max-width: 520px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.field-error { color: #c0392b; font-size: 12px; }

/* ── карточка v2: слева превью, справа вкладки ──────────────────────────── */
.preview-main {
    width: 100%; min-height: 200px; background: #f0f3f8; border: 1px solid #e3e8f0;
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    overflow: hidden; margin-bottom: 10px;
}
.preview-main img { max-width: 100%; max-height: 360px; object-fit: contain; }
.ph-big { color: #8a93a5; font-size: 14px; }

.gallery-strip { min-height: 70px; }
.tile { position: relative; }

/* Контролы плитки видны в зависимости от контейнера, где она лежит сейчас. */
.tile .main-badge {
    position: absolute; top: 4px; left: 4px; z-index: 2; display: none;
    background: #1e7a45; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 8px;
}
#gallery .tile.is-main { border-color: #1e7a45; box-shadow: 0 0 0 2px #1e7a45 inset; }
#gallery .tile.is-main .main-badge { display: inline-block; }

.tile-corner { position: absolute; top: 4px; right: 4px; z-index: 3; display: flex; gap: 3px; }
.tile-corner button {
    cursor: pointer; line-height: 1; padding: 2px 6px; font-size: 12px;
    background: rgba(255,255,255,.9); border: 1px solid #d6deea; border-radius: 4px;
}
.make-main { display: none; color: #8a6d12; }          /* по умолчанию скрыта */
#gallery .tile .make-main { display: inline-flex; }     /* «сделать главной» — только в галерее */
#gallery .tile.is-main .make-main { display: none; }    /* у самой главной не нужна */
.del-img { color: #c0392b; font-weight: 700; }
.del-img:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

/* кнопки обработки — только в пуле «Собранные» */
#collected .tile .process-menu, #processed .tile .process-menu { display: flex; }
.not-jpg { display: none; }
#processed .tile .not-jpg, #gallery .tile .not-jpg { display: inline-block; margin: 2px 0; padding: 1px 6px; border-radius: 4px; background: #fdecec; color: #c0392b; border: 1px solid #f0b3b3; font-size: 11px; font-weight: 600; }
/* метка на превью-миниатюрах «Внешний вид» */
.pv-thumb-wrap { position: relative; display: inline-block; line-height: 0; }
.pv-thumb-wrap .pv-not-jpg { position: absolute; left: 2px; bottom: 2px; background: #c0392b; color: #fff; font-size: 9px; line-height: 1.5; padding: 0 4px; border-radius: 3px; white-space: nowrap; }
.pv-thumb.not-jpg-thumb { outline: 2px solid #c0392b; outline-offset: -2px; }

.pool-title { font-size: 13px; color: #5a6477; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .03em; }

.preview-texts { margin-top: 14px; }
.pv-block { margin-bottom: 12px; }
.pv-block h3 { font-size: 13px; color: #5a6477; margin: 0 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.pv { white-space: normal; line-height: 1.5; }
table.pv-params { width: 100%; border-collapse: collapse; }
table.pv-params td { padding: 4px 8px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
table.pv-params td:first-child { color: #5a6477; width: 40%; }

/* вкладки справа */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid #e3e8f0; margin-bottom: 14px; }
.tab {
    background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
    padding: 8px 12px; cursor: pointer; color: #5a6477; font-size: 13px; border-radius: 0;
}
.tab:hover { color: #1d2330; }
.tab.active { color: #2a6df4; border-bottom-color: #2a6df4; font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tab-actions { margin-bottom: 10px; }
.tab-actions button { font-size: 13px; }

.quick-search { background: #f0f3f8; border: 1px solid #e3e8f0; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.quick-search .qs-label { color: #5a6477; font-size: 13px; }
.quick-search a { font-size: 13px; padding: 3px 10px; background: #fff; border: 1px solid #d6deea; border-radius: 6px; }

.preview-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pv-thumb { width: 64px; height: 64px; object-fit: cover; border: 1px solid #e3e8f0; border-radius: 6px; }
.pv-thumb:first-child { border-color: #1e7a45; box-shadow: 0 0 0 2px #1e7a45 inset; }

/* кнопки порядка/добавления на плитке (видимость — по контейнеру) */
.tile-move { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.tile-move button {
    cursor: pointer; line-height: 1; padding: 2px 7px; font-size: 12px;
    background: #eef1f6; color: #41506b; border: 1px solid #d6deea; border-radius: 4px;
}
.tile-move button:hover { background: #e0e7f2; }
.move-left, .move-right { display: none; }
.add-to-card { display: none; font-weight: 700; color: #1e7a45; }
#gallery .tile .move-left, #gallery .tile .move-right { display: inline-flex; }
#collected .tile .add-to-card, #processed .tile .add-to-card { display: inline-flex; }

/* нормализация характеристик / генерация текста */
.normalize-box { margin-bottom: 12px; }
.normalize-box textarea {
    width: 100%; border: 1px solid #cfd6e4; border-radius: 6px; padding: 8px; font: inherit; resize: vertical;
}
.normalize-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.model-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #5a6477; }
.model-pick select { font: inherit; padding: 4px 6px; border: 1px solid #cfd6e4; border-radius: 6px; }
.price-cell { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }
.rub-hint { color: #8a93a6; font-size: 11px; white-space: nowrap; }
button.mini { font-size: 11px; padding: 3px 8px; margin-left: 8px; background: #eef1f6; color: #2a6df4; border-color: #d6deea; }
button.mini:hover { background: #e0e7f2; }

.cost-badge { background: #fff4d6; color: #8a6d00; border: 1px solid #f0d98a; border-radius: 10px; padding: 2px 10px; font-weight: 600; font-size: 12px; }

/* разделы и сопоставление характеристик */
.section-pick { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-params { display: flex; flex-direction: column; gap: 12px; }
.section-param-card { border: 1px solid #e1e6ef; border-radius: 8px; padding: 10px; background: #fafbfd; }
.section-param-form { margin-bottom: 6px; }
.section-param-row { display: flex; align-items: center; gap: 8px; }
.param-values { width: 100%; margin-top: 8px; border: 1px solid #cfd6e4; border-radius: 6px; padding: 6px 8px; font: inherit; resize: vertical; }
.picklist li.group-sep { list-style: none; margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: #8a93a6; border-top: 1px dashed #d6deea; padding-top: 8px; }
.picklist li.extra { opacity: 0.85; }
.picklist .unit { color: #5a6477; }
.picklist .donor { display: inline-block; margin-left: 6px; font-size: 11px; color: #8a93a6; }
.picklist li.std, .picklist li.extra { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.param-val { display: inline-flex; align-items: center; gap: 4px; }
.param-value { font: inherit; padding: 3px 6px; border: 1px solid #cfd6e4; border-radius: 6px; min-width: 90px; }
.param-val-static { color: #2a3142; }
.prod-head .section-pick { margin-top: 8px; }
#params-match { background: #2a6df4; color: #fff; }

/* FAQ: пары вопрос-ответ */
.faq-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.faq-item { border: 1px solid #e1e6ef; border-radius: 8px; padding: 8px; background: #fafbfd; }
.faq-item .faq-q { width: 100%; font-weight: 600; border: 1px solid #cfd6e4; border-radius: 6px; padding: 6px 8px; font: inherit; }
.faq-item .faq-a { width: 100%; margin-top: 6px; border: 1px solid #cfd6e4; border-radius: 6px; padding: 6px 8px; font: inherit; resize: vertical; }
.faq-item-actions { margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.faq-draft-tag { color: #b8860b; font-size: 11px; }
.faq-item[data-pub="1"] .faq-draft-tag { display: none; }
.faq-item[data-pub="0"] { border-left: 3px solid #e0a800; }
.faq-item-actions button { margin-left: 0; }
.pv-faq dt { font-weight: 600; margin-top: 8px; }
.pv-faq dd { margin: 2px 0 0; color: #3a4150; }

/* редактор промптов */
.prompt-field { margin-bottom: 14px; }
.prompt-field label { display: block; font-size: 13px; color: #41506b; margin-bottom: 4px; font-weight: 600; }
.prompt-field textarea { width: 100%; border: 1px solid #cfd6e4; border-radius: 6px; padding: 8px; font: inherit; resize: vertical; }
.ok-msg { color: #1e7a45; }

/* сбор картинок (настройка) */
.collector-box { background: #fff; border: 1px solid #e3e8f0; border-radius: 8px; padding: 16px; max-width: 760px; }
.collector-box h3 { font-size: 14px; color: #41506b; margin: 14px 0 6px; }
.collector-box code { background: #f0f3f8; padding: 2px 6px; border-radius: 4px; }
.collector-box code.token { font-weight: 700; color: #b02a2a; }

/* модалка просмотра картинки */
#img-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 1000; align-items: center; justify-content: center; flex-direction: column; gap: 12px; }
#img-modal .modal-stage { position: relative; display: inline-block; line-height: 0; }
#img-modal img { max-width: 92vw; max-height: 84vh; object-fit: contain; box-shadow: 0 6px 40px rgba(0,0,0,.5); background: #fff; cursor: crosshair; user-select: none; }
#img-modal .crop-sel { position: absolute; border: 2px solid #2a6df4; background: rgba(42,109,244,.18); box-shadow: 0 0 0 9999px rgba(0,0,0,.35); cursor: move; }
#img-modal .crop-sel .ch { position: absolute; width: 14px; height: 14px; background: #2a6df4; border: 2px solid #fff; border-radius: 3px; box-sizing: border-box; }
#img-modal .crop-sel .ch.tl { left: -8px; top: -8px; cursor: nwse-resize; }
#img-modal .crop-sel .ch.tr { right: -8px; top: -8px; cursor: nesw-resize; }
#img-modal .crop-sel .ch.bl { left: -8px; bottom: -8px; cursor: nesw-resize; }
#img-modal .crop-sel .ch.br { right: -8px; bottom: -8px; cursor: nwse-resize; }
#img-modal .modal-tools { display: flex; align-items: center; gap: 10px; }
#img-modal .modal-tools .crop-hint { color: #cfd6e4; font-size: 13px; }
#img-modal .modal-close { position: absolute; top: 14px; right: 26px; color: #fff; font-size: 44px; line-height: 1; cursor: pointer; z-index: 2; }
.tile .thumb img, #main-image, .pv-thumb { cursor: zoom-in; }

/* индикатор «идёт обработка» */
#busy {
    display: none; position: fixed; top: 60px; right: 16px; z-index: 1100;
    align-items: center; gap: 8px; background: #1d2330; color: #fff;
    padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 3px 14px rgba(0,0,0,.25);
}
.busy-spin {
    width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    border-radius: 50%; animation: busy-rot .7s linear infinite; display: inline-block;
}
@keyframes busy-rot { to { transform: rotate(360deg); } }

/* палитра плейсхолдеров в редакторе промптов */
.ph-palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.ph-chip { font-size: 12px; padding: 3px 8px; background: #eef1f6; color: #2a6df4; border: 1px solid #d6deea; border-radius: 12px; cursor: pointer; font-family: monospace; }
.ph-chip:hover { background: #e0e7f2; }

.btn-danger { background: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #a93226; }
