:root {
  --yellow: #FECE15;
  --ink: #1a1a1a;
  --muted: #6b6b76;
  --line: #e3e3ea;
  --surface: #ffffff;
  --bg: #f6f6f8;
  --danger: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Jost", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
}
a { color: #1a5fb4; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.err { color: #b3261e; font-size: 12px; margin-top: 3px; }

/* Топбар */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; padding: 12px 22px;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; }
.brand:hover { text-decoration: none; }
.brand-k {
  background: var(--yellow); color: #000; font-weight: 800;
  padding: 1px 8px; border-radius: 5px; margin-right: 6px;
}
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: #fff; }
.logout { margin: 0; }
.link { background: none; border: none; color: #bfc0c8; cursor: pointer; font: inherit; padding: 0; }
.link:hover { color: #fff; }

/* Контейнер */
.wrap { max-width: 980px; margin: 24px auto; padding: 0 22px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.head-actions, .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions { margin-top: 20px; }

/* Сообщения */
.messages { max-width: 980px; margin: 16px auto 0; padding: 0 22px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.msg-success { background: #e7f6ec; color: #1a7f3c; }
.msg-error { background: #fdecea; color: var(--danger); }
.msg-info, .msg-warning { background: #fff6e0; color: #7a5b00; }

/* Карточки */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.empty { text-align: center; padding: 40px; }

/* Формы */
.form-row { margin-bottom: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field {
  width: 100%; padding: 9px 11px; border: 1px solid #cfcfd9; border-radius: 8px;
  font: inherit; background: #fff;
}
.field:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(254,206,21,.35); }
.field-num { text-align: right; }
.field-inline { width: auto; display: inline-block; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.item-form { background: #fcfcfd; }

/* Загрузка фото: dropzone + превью */
.photo-field { display: block; cursor: pointer; }
.photo-field input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photo-box {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 10px; text-align: center;
  border: 1.5px dashed #cfcfd9; border-radius: 8px; background: #fafafb; transition: .15s;
}
.photo-field:hover .photo-box { border-color: var(--yellow); }
.photo-field.drag .photo-box { border-color: var(--yellow); background: #fffceb; }
.photo-prev { max-width: 52px; max-height: 52px; border-radius: 4px; object-fit: cover; }
.photo-hint { color: var(--muted); font-size: 13px; }
/* Шапка позиции: номер слева, кнопки «Дублировать» / «Удалить» справа */
.item-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: -4px 0 12px;
}
.item-no { font-weight: 600; font-size: 14px; }
.item-tools { display: flex; gap: 8px; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
/* Служебная галочка DELETE: ею управляют кнопки, руками её трогать не нужно. */
.del-flag { display: none; }
/* Удалённая позиция: поля прячем, оставляем полоску с «Вернуть» — пока не
   нажато «Сохранить», удаление обратимо. */
.item-removed { display: none; color: var(--muted); font-size: 14px; }
.item-form.removed { background: #fbf7f7; border-color: #efdcd9; }
.item-form.removed .item-body { display: none; }
.item-form.removed .item-removed { display: block; }
.item-form.removed .js-dup, .item-form.removed .js-del { display: none; }
.link-btn { background: none; border: none; padding: 0; font: inherit; color: #1a5fb4; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.status-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }

/* Кнопки */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid #cfcfd9;
  background: #fff; color: var(--ink); font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #b6b6c2; text-decoration: none; }
/* В тёмной шапке обычная кнопка была белой на белом: правило .topnav a
   (color:#fff) перебивало цвет текста .btn. Делаем её контурной. */
.topnav .btn { background: transparent; border-color: rgba(255, 255, 255, .45); color: #fff; }
.topnav .btn:hover { border-color: #fff; }
.topnav .btn-primary { background: var(--yellow); border-color: var(--yellow); color: #000; }
.btn-primary { background: var(--yellow); border-color: var(--yellow); color: #000; font-weight: 600; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { background: #fff; border-color: #e3b7b2; color: var(--danger); }
.btn-block { width: 100%; }

/* Таблицы */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafafb; }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Действия строки — обычная ячейка, БЕЗ display:flex: флекс-контейнер в <td>
   перестаёт тянуться на высоту строки, и кнопки прилипали к её верху, съезжая
   относительно левых колонок (строки разной высоты из-за длинных имён). */
.row-actions { font-size: 14px; white-space: nowrap; vertical-align: middle; }
.row-actions > * { vertical-align: middle; margin-right: 12px; }
.row-actions > *:last-child { margin-right: 0; }
.preview .thumb { max-width: 64px; max-height: 48px; border-radius: 4px; }

/* Бейджи статусов */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #eee; color: #555; }
.badge-sent { background: #e3eefc; color: #1a5fb4; }
.badge-accepted { background: #e7f6ec; color: #1a7f3c; }
.badge-declined { background: #fdecea; color: var(--danger); }

/* Вход */
.login-body { background: var(--ink); display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 14px; padding: 32px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.login-logo { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-card label { margin-top: 12px; }
.login-card .btn-block { margin-top: 18px; }

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}
