/* =========================================================================
   AR-1 · Комплектация — та же дизайн-система, что в ar1-tz-generator
   (единый акцентный красный, нейтральная шкала, сетка отступов 4px), чтобы
   инструменты выглядели как одна линейка продуктов.
   ========================================================================= */

:root {
  --ar-red: #b02a2a;
  --ar-red-dark: #8a2020;
  --ar-red-wash: rgba(176, 42, 42, 0.06);
  --ar-red-wash-strong: rgba(176, 42, 42, 0.12);
  --ar-red-ring: rgba(176, 42, 42, 0.35);

  --ink: #1c1c1c;
  --ink-soft: #5a5a5a;
  --ink-faint: #96938f;
  --line: #e0dedd;
  --line-soft: #ededeb;
  --bg: #faf9f7;
  --panel: #ffffff;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 19px;
  --text-xl: 23px;
  --leading-tight: 1.25;
  --leading-normal: 1.5;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20, 18, 16, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 18, 16, 0.08);
  --shadow-modal: 0 24px 64px rgba(15, 13, 11, 0.28);

  /* Карточка позиции в два яруса вместо одной тесной пятиколоночной строки:
     верх — описание + два фото (широкие, за счёт fr), низ — стоимость и
     статус полноширинной строкой полей, где у каждого поля есть воздух
     (см. .card-top / .card-bottom ниже). Фото — единый блок фиксированной
     ширины (photo-row), а не две отдельные grid-колонки: так у него один
     "пол" по ширине, и на узких окнах достаточно переключить сетку в одну
     колонку, чтобы фото просто ушли под описание, без горизонтального
     скролла страницы. */
  --card-top-cols: minmax(280px, 1fr) auto;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--ar-red-wash-strong); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  background: var(--panel);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 5;
}
/* Логотип — ссылка на главную экосистемы, но выглядит как логотип:
   без подчёркивания и синевы, с лёгкой подсветкой при наведении. */
.topbar .logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; border-radius: var(--radius-sm); transition: opacity 0.12s ease; }
.topbar .logo:hover { opacity: 0.75; }
.topbar .logo-mark { width: 34px; height: 34px; display: block; flex-shrink: 0; }
.topbar .logo-text {
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.5px;
  color: var(--ar-red);
  line-height: 1;
}
.topbar .logo-text small {
  display: block;
  margin-top: 3px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1.6px;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.topbar-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
  border-left: 1px solid var(--line);
  padding-left: var(--sp-4);
  letter-spacing: 0.1px;
}

/* ---------- Статус-бар "требует внимания" (сквозной по всем объектам) ---------- */
.attention-bar {
  display: flex;
  flex-direction: column;
  padding: 10px var(--sp-6);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 4;
}
.attention-bar.has-alerts { background: #fffaf5; }
.attention-empty { font-size: var(--text-xs); color: var(--ink-faint); }

.attention-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.attention-chip {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  padding: 5px 12px 5px 10px; font: inherit; font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease, color .12s ease;
}
.attention-chip:hover { border-color: #cfccc8; }
.attention-chip.warning { border-color: hsl(38, 75%, 68%); color: hsl(30, 70%, 32%); background: hsl(42, 90%, 96%); }
.attention-chip.critical { border-color: hsl(0, 68%, 68%); color: hsl(0, 68%, 36%); background: hsl(0, 85%, 96%); }
.attention-chip.open { box-shadow: 0 0 0 2px rgba(20, 18, 16, 0.12); }
.attention-chip-count {
  background: rgba(0, 0, 0, 0.08); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}

.attention-panel {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: var(--sp-2); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md);
  max-height: 260px; overflow-y: auto; scrollbar-gutter: stable;
}
.attention-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3); border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.attention-row:last-child { border-bottom: none; }
.attention-row:hover { background: var(--bg); }
.attention-row-title { font-weight: 700; font-size: var(--text-sm); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attention-row-meta { font-size: var(--text-xs); color: var(--ink-faint); flex-shrink: 0; }
.attention-row-msg { font-size: var(--text-xs); font-weight: 700; flex-shrink: 0; width: 200px; text-align: right; color: hsl(30, 70%, 34%); }
.attention-row-msg.critical { color: hsl(0, 68%, 40%); }

/* Кратковременная подсветка карточки после перехода из статус-бара */
@keyframes flash-highlight {
  0%, 100% { box-shadow: 0 0 0 0 rgba(176, 42, 42, 0); }
  20% { box-shadow: 0 0 0 4px var(--ar-red-ring); }
}
.item-card.flash-highlight { animation: flash-highlight 1.6s ease; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 61px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  overflow-y: auto;
}
.sidebar-section { display: flex; flex-direction: column; gap: var(--sp-2); }
.sidebar-section + .sidebar-section { padding-top: var(--sp-5); border-top: 1px solid var(--line-soft); }
.sidebar-title {
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-faint);
  font-weight: 700;
}

/* ---------- Формы ---------- */
select, input[type="text"], input[type="number"], textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: inherit;
  font-size: var(--text-sm);
  background: #fff;
  color: var(--ink);
}
select, input[type="text"], input[type="number"] { height: 38px; }
select { cursor: pointer; }
select:hover, input:hover, textarea:hover { border-color: #c8c5c1; }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--ar-red);
  box-shadow: 0 0 0 3px var(--ar-red-ring);
}
::placeholder { color: var(--ink-faint); }

/* ---------- Кнопки ---------- */
.btn-primary, .btn-secondary, .btn-link, .btn-icon {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  font-weight: 600;
  height: 38px;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
}
.btn-primary {
  background: var(--ar-red);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--ar-red-dark); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { background: var(--line); color: var(--ink-faint); cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--bg); border-color: #cfccc8; }
.btn-link {
  background: none; color: var(--ar-red); text-align: left;
  padding: var(--sp-1) 0; font-size: var(--text-xs); font-weight: 600;
  height: auto; text-decoration: none; border-bottom: 1px solid transparent;
}
.btn-link:hover { border-bottom-color: var(--ar-red); }
.btn-icon { background: none; color: var(--ink-soft); font-size: 15px; padding: var(--sp-1) var(--sp-2); height: auto; }
.btn-icon:hover { color: var(--ar-red); }

/* ---------- Строка объекта ---------- */
.select-row { display: flex; gap: var(--sp-2); align-items: stretch; }
.select-row select { flex: 1; min-width: 0; }
.select-row .btn-icon {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 38px;
  flex-shrink: 0;
}
.select-row .btn-icon:hover:not(:disabled) { border-color: var(--ar-red-ring); background: var(--ar-red-wash); }
.select-row .btn-icon:disabled { color: var(--ink-faint); cursor: not-allowed; opacity: 0.5; }

/* ---------- Список разделов ---------- */
.room-list { display: flex; flex-direction: column; gap: 2px; }
.room-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 9px 7px 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  transition: background-color .12s ease;
}
.room-pill:hover { background: var(--bg); }
.room-pill.active {
  background: var(--ar-red-wash-strong);
  border-color: var(--ar-red-ring);
  color: var(--ar-red-dark);
  font-weight: 700;
}
.room-pill-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.room-pill-count {
  flex-shrink: 0; font-size: var(--text-2xs); font-weight: 700; color: var(--ink-faint);
  background: var(--bg); border-radius: 999px; padding: 2px 7px;
}
.room-pill.active .room-pill-count { background: #fff; color: var(--ar-red-dark); }
.room-pill-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity .12s ease; }
.room-pill:hover .room-pill-actions { opacity: 1; }
.room-pill-actions .room-delete-btn { opacity: 1; width: 20px; height: 20px; font-size: 11px; }

/* ---------- Кнопка "Карточка объекта" в сайдбаре ---------- */
.dashboard-nav-btn { width: 100%; text-align: left; }
.dashboard-nav-btn.active-nav {
  background: var(--ar-red-wash-strong); border-color: var(--ar-red-ring); color: var(--ar-red-dark);
}

/* ---------- Управление помещениями (компактный список в сайдбаре) ---------- */
.room-manage-list { display: flex; flex-direction: column; gap: 2px; }
.room-manage-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 6px 4px 6px 9px; font-size: var(--text-xs); color: var(--ink-soft); border-radius: var(--radius-sm);
}
.room-manage-row:hover { background: var(--bg); }
.room-manage-row:hover .room-delete-btn { opacity: 1; }
.room-manage-empty { font-size: var(--text-xs); color: var(--ink-faint); font-style: italic; padding: 4px 2px; }

.room-delete-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 12px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity .12s ease, background-color .12s ease, color .12s ease;
}
.room-manage-row .room-delete-btn { opacity: 0; }
.room-delete-btn:hover { background: var(--ar-red-wash-strong); color: var(--ar-red); }

/* ---------- Контент ---------- */
.content { padding: var(--sp-6) var(--sp-8) var(--sp-10); }
.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.content-header h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.2px;
}
.category-subtotal {
  margin-top: var(--sp-1);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}
.category-subtotal strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.add-item-bar {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
}
.add-item-bar input[type="text"] { width: 340px; }

/* ---------- Фильтры внутри раздела ---------- */
.item-filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.filter-bar-label { font-size: var(--text-xs); color: var(--ink-faint); margin-right: 2px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  padding: 5px 11px 5px 9px; font: inherit; font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease, color .12s ease, opacity .12s ease;
}
.filter-chip:hover { border-color: #cfccc8; }
.filter-chip.empty { opacity: 0.4; }
.filter-chip.active { background: var(--ar-red-wash-strong); border-color: var(--ar-red-ring); color: var(--ar-red-dark); }
.filter-chip-count {
  background: rgba(0, 0, 0, 0.07); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.filter-chip.active .filter-chip-count { background: rgba(176, 42, 42, 0.16); }
.filter-chip-clear { color: var(--ink-faint); border-style: dashed; }
.category-subtotal-full { color: var(--ink-faint); font-weight: 400; }

/* ---------- Таблица позиций ---------- */
.items-table { display: flex; flex-direction: column; }
.items-grid { display: flex; flex-direction: column; gap: var(--sp-3); }

.item-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.item-card-head .item-title-input {
  border: none;
  border-bottom: 1px solid transparent;
  background: none;
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--ink);
  width: 46%;
  padding: var(--sp-1) 0;
  border-radius: 0;
  height: auto;
}
.item-card-head .item-title-input:hover { border-bottom-color: var(--line); }
.item-card-head .item-title-input:focus {
  outline: none;
  border-bottom: 1px solid var(--ar-red);
  box-shadow: none;
}
.item-card-head .item-actions { display: flex; gap: var(--sp-3); align-items: center; flex-shrink: 0; }
.urgency-dot {
  flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line);
}

.item-card.has-problem { border-color: hsl(0, 68%, 55%); box-shadow: 0 0 0 1px hsl(0, 68%, 60%); }
.item-card.has-problem .item-card-head { background: hsl(0, 85%, 97%); }

.problem-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--text-2xs); font-weight: 700; white-space: nowrap;
  color: var(--ink-faint); background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px 4px 8px; cursor: pointer; user-select: none;
  transition: color .12s ease, border-color .12s ease, background-color .12s ease;
}
.problem-toggle input { accent-color: hsl(0, 68%, 45%); width: 13px; height: 13px; cursor: pointer; }
.problem-toggle:hover { border-color: hsl(0, 68%, 70%); color: hsl(0, 68%, 40%); }
.problem-toggle.active { background: hsl(0, 85%, 96%); border-color: hsl(0, 68%, 60%); color: hsl(0, 68%, 38%); }
.room-select {
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  height: auto;
}

/* ---------- Тело карточки: два яруса ----------
   Раньше всё (описание, два фото, стоимость, статус) втискивалось в одну
   пятиколоночную строку — колонка описания росла, а стоимость/статус
   оставались в узкой фиксированной колонке и мельчали. Теперь верх (описание
   + фото) — широкая grid-строка, низ (стоимость/статус) — отдельная
   полноширинная flex-строка, где у каждого поля есть собственный процент
   ширины через flex-basis, а не втиснутая колонка. */
.item-card-body { background: var(--bg); }

.card-top {
  display: grid;
  grid-template-columns: var(--card-top-cols);
  gap: var(--sp-4);
  padding: var(--sp-4);
}
/* На узких окнах (ноутбук со свёрнутым сайдбаром браузера и т.п.) фиксированной
   ширины фото-блок вместе с минимальной шириной описания уже не помещаются
   рядом — переключаем в одну колонку, фото уходят под описание, вместо того
   чтобы продавливать горизонтальный скролл всей страницы. */
@media (max-width: 1180px) {
  .card-top { grid-template-columns: 1fr; }
  .photo-row { width: 100%; }
  .photo-group { flex: 1; width: auto; max-width: 260px; }
}

.field-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--ink-faint); margin-bottom: 4px; display: block;
}
.field-group { display: flex; flex-direction: column; min-width: 0; }
.field-group input, .field-group select, .field-group textarea { width: 100%; }

/* --- Описание: бренд/артикул, характеристики, ссылка --- */
.desc-cell {
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--panel); border-radius: var(--radius-sm); padding: var(--sp-3);
}
.desc-cell .field-row { display: flex; gap: var(--sp-3); }
.desc-cell .field-row .field-group { flex: 1; }
.desc-cell .field-row input { height: 34px; font-size: var(--text-sm); }
.desc-cell textarea.char-input {
  min-height: 76px; font-size: var(--text-sm); resize: vertical; background: var(--bg);
}
.desc-cell textarea.char-input:focus { background: #fff; }
.desc-cell input.link-input { height: 34px; font-size: var(--text-sm); }

/* --- Фото: подпись сверху + дропзона --- */
.photo-row { display: flex; gap: var(--sp-4); flex-shrink: 0; }
.photo-group { display: flex; flex-direction: column; width: 190px; flex-shrink: 0; }

/* --- Дропзоны фото --- */
.dropzone {
  width: 100%;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  aspect-ratio: 4 / 3;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: var(--text-2xs);
  color: var(--ink-faint);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.dropzone:hover { border-color: #cfccc8; color: var(--ink-soft); }
.dropzone.dragover { border-color: var(--ar-red); background: var(--ar-red-wash); color: var(--ar-red-dark); }
.dropzone .dz-icon { opacity: 0.55; }
.dropzone.dragover .dz-icon { opacity: 1; }
.dropzone img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.dropzone .dz-label { white-space: pre-line; line-height: var(--leading-tight); }
.dropzone .remove-img {
  position: absolute; top: 6px; right: 6px;
  background: rgba(20, 18, 16, 0.65); color: #fff; border: none;
  border-radius: 50%; width: 22px; height: 22px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.dropzone .remove-img:hover { background: var(--ar-red); }

/* ---------- Низ карточки: стоимость + статус, полноширинной строкой ---------- */
.card-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--sp-3) var(--sp-4);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--line);
}
.card-bottom .field-group input,
.card-bottom .field-group select { height: 34px; font-size: var(--text-sm); }
.card-bottom .supplier-group { flex: 1.6 1 180px; }
.card-bottom .qty-group { flex: 0.6 1 80px; }
.card-bottom .qty-group input { text-align: right; font-variant-numeric: tabular-nums; }
.card-bottom .price-group { flex: 0.9 1 110px; }
.card-bottom .price-group input { text-align: right; font-variant-numeric: tabular-nums; }
.card-bottom .sum-group { flex: 0.9 1 120px; }
.card-bottom .status-group { flex: 1.2 1 160px; }
.card-bottom .deadline-group { flex: 1.5 1 210px; }
.card-bottom .ship-group { flex: 0.9 1 150px; }
.card-bottom .ship-group input:disabled { opacity: 0.45; cursor: not-allowed; }
.card-bottom .reimburse-group { flex: 1.4 1 220px; }
/* Не height, а min-height: тут два чекбокса друг под другом (в отличие от
   однострочных полей рядом), фиксированные 34px их обрезали и утаскивали
   вверх — визуально наезжало на подпись поля "Оплата" над блоком. */
.reimburse-row { display: flex; flex-direction: column; gap: 6px; min-height: 34px; justify-content: center; }
.reimbursed-toggle.disabled { opacity: 0.4; }
.reimbursed-toggle.disabled input { cursor: not-allowed; }

.card-bottom .bonus-group { flex: 1.3 1 190px; }
.bonus-row { display: flex; flex-direction: column; gap: 6px; }
.bonus-row input[type="number"] { height: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.bonus-received-toggle.disabled { opacity: 0.4; }
.bonus-received-toggle.disabled input { cursor: not-allowed; }

.card-bottom .comment-group { flex: 2 1 220px; }
.card-bottom .comment-group textarea {
  min-height: 34px; height: 34px; resize: vertical; font-size: var(--text-sm); background: var(--panel);
}
.card-bottom .comment-group textarea:focus { background: #fff; }

.sum-display-inline {
  height: 34px; display: flex; align-items: center; justify-content: flex-end;
  padding: 0 11px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--panel); font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--text-sm);
}

.deadline-row { display: flex; align-items: center; gap: var(--sp-2); }
.deadline-row input[type="date"] { flex: 1; min-width: 0; }
.deadline-row.disabled input[type="date"] { opacity: 0.45; cursor: not-allowed; }

/* Заблокировано, потому что никто не выбран (см. wireItemCard в app.js) —
   роль на редактирование полей больше не влияет, все заполняют всё, когда
   есть время; блокировка нужна только затем, чтобы у правки всегда была
   подпись в логе. Отличается от "заблокировано бизнес-логикой" (например
   ship_date при завершённом статусе, стили выше) визуальным штрихом (иконка
   замка перед лейблом), а не просто прозрачностью. */
.field-locked { opacity: 0.45; cursor: not-allowed; }
.field-group.role-locked .field-label::before { content: "🔒 "; }
.dropzone.locked { opacity: 0.45; cursor: not-allowed; }
.dropzone.locked:hover { border-color: var(--line-soft); }
.purchased-toggle {
  display: flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-soft); cursor: pointer; user-select: none; white-space: nowrap; flex-shrink: 0;
}
.purchased-toggle input { accent-color: var(--ar-red); width: 15px; height: 15px; cursor: pointer; }

.delete-item-btn {
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 4px 2px;
}
.delete-item-btn:hover { color: var(--ar-red); }

.empty-state {
  color: var(--ink-soft);
  font-size: var(--text-sm);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

/* ---------- Модалка (диалоги prompt/confirm/alert) ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 18, 16, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(1px);
}
.modal {
  background: #fff;
  width: 480px;
  max-width: calc(100vw - 40px);
  max-height: 82vh;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: var(--text-md); font-weight: 700; }
.modal-body { padding: var(--sp-2) var(--sp-5); overflow-y: auto; scrollbar-gutter: stable; flex: 1; }
.modal-footer { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); text-align: right; background: var(--bg); }

.modal-sm .modal-body { padding: var(--sp-4) var(--sp-5); }
.modal-footer-split { display: flex; justify-content: flex-end; gap: var(--sp-2); }
/* pre-line — чтобы переносы строк в тексте диалога сохранялись: в
   сообщении о конфликте правок (см. resolveConflict в app.js) чужое и своё
   значения стоят на отдельных строках, иначе они склеиваются в кашу. */
.dialog-message { margin: 0; font-size: var(--text-sm); color: var(--ink-soft); line-height: var(--leading-normal); white-space: pre-line; }
.dialog-label { display: block; font-size: var(--text-sm); color: var(--ink-soft); margin-bottom: var(--sp-2); }
.dialog-input { width: 100%; }

/* ---------- Карточка объекта (дашборд) ---------- */
.dashboard-title { margin: 0 0 var(--sp-5); font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.3px; }

.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
.dash-stat.dash-stat-warn {
  border-color: hsl(38, 75%, 68%);
  background: hsl(42, 90%, 97%);
}
.dash-stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.dash-stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.dash-stat-of { font-size: var(--text-md); font-weight: 500; color: var(--ink-faint); }
.dash-stat-label { margin-top: 4px; font-size: var(--text-sm); color: var(--ink-soft); }

.dash-section-title { font-size: var(--text-md); font-weight: 700; margin: 0 0 var(--sp-3); }

/* ---------- Портфель: таблица объектов ---------- */
.portfolio-table {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
}
.portfolio-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.6fr) repeat(6, minmax(80px, 1fr));
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.portfolio-row:last-child { border-bottom: none; }
.portfolio-row:hover { background: var(--bg); }
.portfolio-row.portfolio-head {
  cursor: default; background: var(--bg);
  font-size: var(--text-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-faint);
}
.portfolio-row.portfolio-head:hover { background: var(--bg); }
.portfolio-row-name { font-weight: 700; font-size: var(--text-sm); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-row-cell { font-size: var(--text-sm); font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.portfolio-row-cell.warn { color: hsl(30, 70%, 38%); font-weight: 700; }
.portfolio-attention-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: hsl(0, 85%, 94%); color: hsl(0, 68%, 40%); font-weight: 700; font-size: var(--text-xs);
}

.urgency-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.urgency-legend-item { display: flex; align-items: center; gap: 7px; font-size: var(--text-sm); color: var(--ink-soft); }
.urgency-legend-item .urgency-dot { box-shadow: none; }

.urgency-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.urgency-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}
.urgency-row:last-child { border-bottom: none; }
.urgency-row .urgency-dot { box-shadow: none; flex-shrink: 0; }
.urgency-row-title { font-weight: 600; font-size: var(--text-sm); flex: 1; min-width: 0; }
.urgency-row-meta { font-size: var(--text-xs); color: var(--ink-faint); flex-shrink: 0; }
.urgency-row-label { font-size: var(--text-xs); font-weight: 700; color: var(--ink-soft); flex-shrink: 0; width: 160px; text-align: right; }

/* ---------- Библиотека шаблонов ---------- */
.save-template-btn { font-size: 14px; }

.template-search { margin-bottom: var(--sp-3); position: sticky; top: 0; }
.template-list { display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: var(--sp-2); }
.template-empty { color: var(--ink-faint); font-size: var(--text-sm); font-style: italic; padding: var(--sp-5) 0; text-align: center; }

.template-row {
  display: flex; align-items: center; gap: var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  transition: border-color .12s ease;
}
.template-row:hover { border-color: #cfccc8; background: var(--bg); }
.template-thumb {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.template-thumb img { width: 100%; height: 100%; object-fit: contain; }
.template-thumb span { font-size: 9px; color: var(--ink-faint); text-align: center; }
.template-info { flex: 1; min-width: 0; }
.template-title { font-weight: 700; font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-meta { font-size: var(--text-xs); color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-insert-btn { flex-shrink: 0; }
.template-delete-btn { flex-shrink: 0; opacity: 1; width: 30px; height: 30px; }

/* ---------- «С объектом работает ещё кто-то» ---------- */
/* Предупреждение, а не украшение: показывается только когда кто-то реально
   был активен в этом объекте недавно (см. refreshPresence в app.js). */
.presence-bar {
  margin-top: var(--sp-2);
  padding: 7px 10px;
  border: 1px solid var(--ar-red-ring);
  background: var(--ar-red-wash);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--ink-soft);
  line-height: var(--leading-normal);
}
.presence-bar strong { color: var(--ink); }

/* ---------- Пользователи и роли (см. README «Пользователи и роли») ---------- */
.sidebar-section-bottom { margin-top: auto; padding-top: var(--sp-5); border-top: 1px solid var(--line-soft); }
.author-btn {
  width: 100%; text-align: left;
  border: 1px dashed var(--line); border-radius: var(--radius-sm); background: none;
  padding: 8px 11px; font: inherit; font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-faint); cursor: pointer;
}
.author-btn:hover { border-color: #cfccc8; color: var(--ink-soft); }

.user-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.user-row {
  display: flex; align-items: center; gap: var(--sp-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 8px 11px;
  cursor: pointer; background: var(--bg);
}
.user-row:hover { border-color: var(--ar-red-ring); background: var(--ar-red-wash); }
.user-row.active { border-color: var(--ar-red); background: var(--ar-red-wash); }
.user-row-name { flex: 1; font-weight: 600; font-size: var(--text-sm); }
.user-role-badge {
  font-size: var(--text-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--ink-soft); background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 2px 8px;
}
.user-add-row { display: flex; gap: var(--sp-2); }
.user-add-row .user-add-name { flex: 1.4; }
.user-add-row .user-add-role { flex: 1; }

/* ---------- История изменений позиции ---------- */
.history-btn { position: relative; }
.history-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--ar-red); color: #fff; border-radius: 999px;
  font-size: 9px; font-weight: 700; min-width: 14px; height: 14px; line-height: 14px; text-align: center; padding: 0 2px;
}
.history-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.history-empty { color: var(--ink-faint); font-size: var(--text-sm); font-style: italic; padding: var(--sp-4) 0; }
.history-row {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); background: var(--bg);
}
.history-row-note { background: var(--ar-red-wash); border-color: var(--ar-red-ring); }
.history-row-top { display: flex; justify-content: space-between; gap: var(--sp-2); margin-bottom: 3px; }
.history-author { font-size: var(--text-2xs); font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.history-time { font-size: var(--text-2xs); color: var(--ink-faint); }
.history-message { font-size: var(--text-sm); color: var(--ink); }
.history-note-row { display: flex; gap: var(--sp-2); width: 100%; }
.history-note-row input { flex: 1; }

/* ---------- Дайджест ---------- */
.modal-digest { width: 620px; }
.modal-digest .modal-body { max-height: 60vh; }

.digest-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.digest-chip { cursor: default; }
.digest-chip:hover { border-color: var(--line); }

.digest-totals {
  display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
}
.digest-totals-item { font-size: var(--text-sm); color: var(--ink-soft); }
.digest-totals-item strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.digest-totals-item.warn strong { color: hsl(30, 70%, 38%); }

.digest-list {
  border: 1px solid var(--line-soft); border-radius: var(--radius-md); overflow: hidden;
}
.digest-row { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line-soft); cursor: pointer; transition: background-color .12s ease; }
.digest-row:last-child { border-bottom: none; }
.digest-row:nth-child(odd) { background: var(--bg); }
.digest-row:hover { background: var(--ar-red-wash); }
.digest-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
.digest-row-title { font-weight: 700; font-size: var(--text-sm); min-width: 0; }
.digest-row-msg { font-size: var(--text-xs); font-weight: 700; color: hsl(30, 70%, 38%); flex-shrink: 0; white-space: nowrap; }
.digest-row-msg.critical { color: hsl(0, 68%, 42%); }
.digest-row-meta { font-size: var(--text-2xs); color: var(--ink-faint); margin-top: 2px; }

.digest-copy-btn { width: 100%; white-space: normal; height: auto; min-height: 38px; padding: 9px 15px; }
