/* --- Палитра и база --- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #ea580c;      /* тёплый «аппетитный» акцент */
  --accent-hover: #c2410c;
  --accent-soft: #fff2ea;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

/* --- Кнопки --- */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f0f1f3; }
.btn-danger { background: transparent; color: var(--danger); border-color: #f0d0d0; }
.btn-danger:hover { background: #fdf0f0; }
/* «Не еда» сознательно не похожа на обычный брак: эта кнопка
   меняет память автобрака и требует осознанного выбора. */
.btn-not-food { background: transparent; color: #6d28d9; border-color: #ddd0f7; }
.btn-not-food:hover { background: #f7f3ff; }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; color: var(--muted); line-height: 1;
}

/* --- Экран входа --- */
.login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  /* тематический фон: ИИ + распознавание блюд (тёмный графит), с затемнением для контраста */
  background: linear-gradient(rgba(18,20,24,.62), rgba(18,20,24,.82)),
              #14161a url('/bg-login.jpg') center/cover no-repeat;
}
.login-card .muted { color: var(--muted); }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.login-card input {
  font: inherit; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fbfbfc;
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* --- Бренд --- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 0; }
.brand-logo { font-size: 30px; }
.brand-sm .brand-logo { font-size: 22px; }

.form-error { color: var(--danger); font-size: 14px; margin: 0; min-height: 18px; }

/* --- Топбар и вкладки --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.tabs {
  display: flex; gap: 4px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.tab {
  font: inherit; font-weight: 600; color: var(--muted);
  background: transparent; border: none; cursor: pointer;
  padding: 14px 14px; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Контент --- */
.content { max-width: 960px; margin: 0 auto; padding: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head-controls { display: flex; gap: 10px; align-items: center; }

.select {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface);
}

/* --- Разделы меню --- */
.cat { margin-bottom: 26px; }
.cat-head {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; font-size: 16px; font-weight: 700;
  padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft);
}
.cat-count {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 2px 9px;
}

/* --- Карточки --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
/* Сети и их адреса (21.08): объекты сети под общим заголовком, отдельные
   рестораны — своей группой, чтобы было видно, что к чему относится */
.chain-list { display: flex; flex-direction: column; gap: 26px; }
.chain-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding-bottom: 8px; margin-bottom: 14px; border-bottom: 2px solid var(--accent-soft);
}
.chain-name { font-size: 19px; font-weight: 700; }
.chain-count { font-size: 13px; color: var(--muted); }
.chain-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.card-title { font-weight: 700; font-size: 16px; }
.card-sub { color: var(--muted); font-size: 13px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Кнопки в карточке (22.08): раньше строка не переносилась, и в узкой
   карточке ресторана корзина вылезала за край. Теперь кнопки переносятся,
   а внутри карточки они компактнее — три штуки встают в один ряд. */
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.card-actions .btn { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.dish-photo { width: 100%; height: 130px; object-fit: cover; border-radius: 10px; background: #f0f1f3; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.badge-muted { background: #eef0f3; color: var(--muted); }
.reject-reason {
  padding: 8px 10px; border-radius: 9px; background: #f7f7f8;
  color: var(--muted); font-size: 13px;
}
/* «Был в сети» (21.08): цвет точки — насколько давно человек заходил */
.seen { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.seen-now { color: #1f9d55; }                 /* в кабинете прямо сейчас */
.seen-was { color: var(--muted); }            /* заходил на днях */
.seen-old { color: #b06e14; }                 /* больше двух недель назад */
.seen-never { color: var(--danger); }         /* ни разу не входил */
.empty { color: var(--muted); padding: 40px 0; text-align: center; grid-column: 1 / -1; }

/* --- Модалка --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 440px; box-shadow: var(--shadow);
  max-height: 90vh; overflow: auto;
}
.modal-wide { max-width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.modal-body input, .modal-body select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fbfbfc;
}
.modal-body input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check-row { flex-direction: row !important; align-items: center; gap: 10px; font-weight: 500; }
.check-row input { width: auto; }
.checklist { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }

/* --- Дашборд --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.chart-card { padding: 18px; }
.chart-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.barsvg { width: 100%; height: auto; display: block; }
.barsvg .bar { fill: var(--accent); }
.barsvg .bar:hover { fill: var(--accent-hover); }
.barsvg .maxtick { stroke: #64748b; stroke-width: 2; }
.barsvg .grid { stroke: #eef0f3; stroke-width: 1; }
.barsvg .axis-base { stroke: var(--border); stroke-width: 1; }
.barsvg .axis-y { fill: var(--muted); font-size: 11px; text-anchor: end; }
.barsvg .axis-x { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.legend { display: flex; gap: 18px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend .lg { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw-bar { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.legend .sw-max { width: 14px; height: 0; border-top: 2px solid #64748b; }
.badge-danger { background: #fdecec; color: var(--danger); }
.badge-warn { background: #fdf3e4; color: #b06e14; }   /* средний 5–10 мин */
.badge-good { background: #e7f6ee; color: #1f9d55; }   /* быстрый до 2 мин */
.barsvg .bar.peak { fill: #b45309; }
.dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.catbars { display: flex; flex-direction: column; gap: 10px; }
.catrow { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 10px; }
.catname { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catbar-track { background: #f0f1f3; border-radius: 999px; height: 12px; overflow: hidden; }
.catbar-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.catval { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; text-align: right; }
@media (max-width: 640px) { .dash-2col { grid-template-columns: 1fr; } }

/* --- Табло простоя --- */
.board { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.board th, .board td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.board th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafafb; }
.board tr:last-child td { border-bottom: none; }
.board-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #f0f1f3; }
.board-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; }
.board-timer.t-warn { color: #b45309; }
.board-timer.t-danger { color: var(--danger); }

/* --- Выбор блюда в разметке + галерея эталонов --- */
.dish-search { position: relative; flex: 1 1 auto; width: 100%; min-width: 0; }
.cap-dish { width: 100%; min-width: 0; margin-top: 2px; }
.dish-search.has-error .cap-dish { border-color: var(--danger); outline-color: #fee2e2; }
.dish-search-error { margin-top: 5px; color: var(--danger); font-size: 12px; line-height: 1.35; }
.dish-picker {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  min-width: 0; overflow: hidden; background: var(--surface);
  border: 1px solid var(--border); border-radius: 11px; box-shadow: 0 12px 30px rgba(16, 24, 40, .16);
}
.dish-picker-status {
  padding: 8px 12px; color: var(--muted); background: #fafafb;
  border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600;
}
.dish-picker-options {
  max-height: 320px; max-height: min(320px, 38vh); max-height: min(320px, 38dvh);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.dish-picker-option {
  display: flex; align-items: center; min-height: 44px; padding: 10px 12px;
  border-bottom: 1px solid #f0f1f3; cursor: pointer; line-height: 1.3;
  overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent;
}
.dish-picker-option:last-child { border-bottom: none; }
.dish-picker-option:hover, .dish-picker-option.active { background: var(--accent-soft); }
.dish-picker-empty { padding: 16px 12px; color: var(--text); font-size: 14px; line-height: 1.4; }
.dish-picker-empty span { color: var(--muted); font-size: 12px; }
@media (max-width: 700px) {
  /* В потоке карточки список можно прокрутить выше экранной клавиатуры. */
  .dish-picker { position: relative; top: auto; left: auto; right: auto; margin-top: 4px; max-width: 100%; }
  .dish-picker-options { max-height: 280px; max-height: min(280px, 34vh); max-height: min(280px, 34dvh); }
}
.dish-card { cursor: pointer; transition: border-color .15s; }
.dish-card:hover { border-color: var(--accent); }
.dish-noimg { height: 130px; border-radius: 10px; background: #f0f1f3; display: flex;
  align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gal-item { display: flex; flex-direction: column; gap: 8px; }
.gal-item .dish-photo { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; }

/* --- Лайтбокс (увеличение фото по клику) --- */
.dish-photo { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 11, 13, .9);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
}
.lightbox img {
  max-width: 94vw; max-height: 94vh;
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}

/* --- Тост --- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 60; font-size: 14px;
}
.toast.error { background: var(--danger); }

@media (max-width: 560px) {
  .content { padding: 16px; }
  .panel-head { flex-direction: column; align-items: stretch; }
}

/* Фильтр по датам в разметке (21.08) */
.date-range { display: inline-flex; align-items: center; gap: 6px; }
.date-range .select { min-width: 140px; }
.date-dash { color: var(--muted); }
.review-all-controls { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Active-learning очередь (task 18): режим, прогресс и причина карточки. */
.review-mode {
  display: inline-flex; max-width: 100%; padding: 3px; margin: -4px 0 14px;
  border: 1px solid var(--border); border-radius: 11px; background: #eef0f3;
}
.review-mode-btn {
  border: 0; border-radius: 8px; padding: 8px 14px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.review-mode-btn.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.queue-progress {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-bottom: 14px;
  overflow: hidden; border: 1px solid #cfe0fb; border-radius: var(--radius);
  background: #cfe0fb; box-shadow: var(--shadow);
}
.queue-progress > div { min-width: 0; padding: 11px 14px; background: #f3f7ff; }
.queue-progress strong { display: block; font-size: 14px; }
.queue-progress span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.queue-reason {
  padding: 7px 9px; border-radius: 9px; background: #f3f7ff; color: #315b93;
  border: 1px solid #d8e5f7; font-size: 12px; font-weight: 650; line-height: 1.35;
}
.queue-reason-control { background: #fff8ed; color: #8a5b12; border-color: #f3e2c7; }
.queue-done strong { color: var(--text); font-size: 18px; }

.coverage-panel {
  max-width: 100%; margin-bottom: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.coverage-panel summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; cursor: pointer; font-size: 14px; font-weight: 700;
}
.coverage-panel summary strong { color: var(--accent); font-size: 13px; text-align: right; }
.coverage-table-wrap { max-width: 100%; overflow-x: auto; border-top: 1px solid var(--border); }
.coverage-table { width: 100%; min-width: 520px; border-collapse: collapse; }
.coverage-table th, .coverage-table td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.coverage-table th { color: var(--muted); background: #fafafb; font-size: 12px; }
.coverage-table td small { display: block; margin-top: 2px; color: var(--muted); }
.coverage-table tr:last-child td { border-bottom: 0; }
.coverage-table .coverage-missing td:first-child { border-left: 3px solid #d99a32; }
.coverage-table .coverage-ready { color: var(--muted); }
.coverage-count { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Действия табло отдельной строкой (21.08): слева очистка, справа ссылка на экран */
.board-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.board-actions:empty { display: none; }
.board-actions-left, .board-actions-right { display: flex; gap: 10px; }
@media (max-width: 560px) {
  .board-actions { flex-direction: column; align-items: stretch; }
  .board-actions .btn { width: 100%; }
}

/* Памятка шефу над лентой разметки (21.08) */
.quality-strip {
  display: grid; grid-template-columns: minmax(130px, 1.1fr) repeat(4, minmax(120px, 1fr));
  gap: 1px; margin-bottom: 14px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--border);
  box-shadow: var(--shadow);
}
.quality-period, .quality-metric {
  min-height: 82px; padding: 12px 14px; background: var(--surface);
  display: flex; justify-content: center; flex-direction: column;
}
.quality-period { font-size: 14px; font-weight: 700; }
.quality-period span { color: var(--muted); font-size: 12px; font-weight: 500; }
.quality-metric { flex-direction: row; align-items: center; gap: 10px; }
.quality-metric strong { font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.quality-metric span { color: var(--muted); font-size: 12px; line-height: 1.3; }
.quality-metric small { font-size: 11px; }
.quality-danger { background: #fff1f1; }
.quality-danger strong, .quality-danger span { color: var(--danger); }

.hint {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.hint-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 16px; background: transparent; border: none;
  font: inherit; font-weight: 700; color: var(--text); cursor: pointer; text-align: left;
}
.hint-toggle:hover { background: #fafafb; }
.hint-title { font-size: 15px; }
.hint-arrow { color: var(--muted); transition: transform .15s; }
.hint.collapsed .hint-arrow { transform: rotate(-90deg); }
.hint.collapsed .hint-body { display: none; }
.hint-body {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 24px;
  padding: 4px 16px 16px; border-top: 1px solid var(--border);
}
.hint-col-head { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.hint-yes .hint-col-head { color: #1f9d55; }
.hint-no .hint-col-head { color: var(--danger); }
.hint-col ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.hint-col li { font-size: 14px; color: var(--text); }
.hint-why { grid-column: 1 / -1; margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
@media (max-width: 800px) {
  .quality-strip { grid-template-columns: 1fr 1fr; }
  .hint-body { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .quality-strip { grid-template-columns: 1fr; }
  .quality-period, .quality-metric { min-height: 64px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   МОБИЛЬНАЯ ВЁРСТКА (26.08). Жалоба Александра с айфона: съехал адаптив,
   не видно кнопки «Брак кадра», меню занимает половину экрана.
   ПРИЧИНА: шесть вкладок во flex без переноса и полоска качества с
   жёсткими minmax-колонками распирали документ до ~700 px. Телефон в
   380-430 px показывал левый край страницы, всё правое уезжало за экран.
   ЛЕЧИМ ПРИЧИНУ: даём вкладкам горизонтальную прокрутку, разрешаем
   grid-ячейкам сжиматься (min-width: 0 — без него grid не уже содержимого).
   ═══════════════════════════════════════════════════════════════════════ */

/* Без этого любая grid/flex-ячейка не сжимается уже своего текста
   и распирает страницу — корень всей мобильной беды */
.quality-period, .quality-metric, .card, .panel-head-controls .select { min-width: 0; }
.quality-metric span, .card-title { overflow-wrap: anywhere; }
/* колонка карточек никогда не шире экрана (было жёстко 290 px) */
.cards { grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); }

@media (max-width: 700px) {
  /* ВКЛАДКИ: прокручиваем вбок, как в мобильных приложениях, а не режем */
  .tabs {
    overflow-x: auto; flex-wrap: nowrap; padding: 0 12px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 12px 11px; font-size: 14px; }

  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar-right { gap: 8px; min-width: 0; }
  #current-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45vw; }
  .content { padding: 14px 12px; }

  /* ШАПКА РАЗДЕЛА: заголовок сверху, фильтры отдельной строкой в ряд */
  .panel-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .panel-head-controls { flex-wrap: wrap; width: 100%; }
  .panel-head-controls .select, .panel-head-controls .input { flex: 1 1 140px; }
  .review-all-controls { width: 100%; }
  .review-all-controls > .select { flex: 1 1 140px; }
  .review-mode { display: flex; width: 100%; }
  .review-mode-btn { flex: 1 1 50%; min-width: 0; }

  /* ПОЛОСКА КАЧЕСТВА: две колонки и мельче цифры — влезает без обрезки */
  .quality-strip { grid-template-columns: 1fr 1fr; }
  .quality-period, .quality-metric { min-height: 58px; padding: 10px 11px; }
  .quality-metric { gap: 8px; }
  .quality-metric strong { font-size: 22px; }
  .quality-metric span { font-size: 11px; }
  .quality-metric small { font-size: 10px; }
  .quality-period { font-size: 13px; }

  /* КНОПКИ КАРТОЧКИ: чтобы «Брак кадра» и «Не еда» всегда были видны */
  .card-actions { gap: 6px; }
  .card-actions .btn { flex: 1 1 auto; padding: 9px 8px; font-size: 13px; white-space: nowrap; }
  .dish-photo { height: 150px; }
  .date-range { flex-wrap: wrap; }
  .date-range .select { min-width: 120px; }
}

/* Совсем узкие экраны (iPhone SE, 320-400 px).
   Полоску качества держим в ДВЕ колонки даже здесь: в одну она занимала
   треть экрана и отодвигала ленту — а это сводка, а не главный экран */
@media (max-width: 400px) {
  .quality-strip { grid-template-columns: 1fr 1fr; }
  .quality-period, .quality-metric { min-height: 52px; padding: 8px 9px; }
  .quality-metric { gap: 6px; }
  .quality-metric strong { font-size: 19px; }
  .quality-metric span { font-size: 10px; line-height: 1.25; }
  .quality-metric small { font-size: 9px; }
  .tab { padding: 12px 9px; font-size: 13px; }
  .card-actions .btn { padding: 9px 6px; font-size: 12px; }
  .queue-progress > div { padding: 9px 10px; }
  .queue-progress strong { font-size: 12px; }
  .queue-progress span { font-size: 10px; }
  .coverage-panel summary { align-items: flex-start; padding: 10px 11px; }
  .coverage-panel summary strong { max-width: 55%; font-size: 11px; }
}

/* Кто принял решение по кадру (26.08): шеф, владелец или автобрак */
.who-line {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted); margin-top: 2px;
}

/* Предположение системы, которого нет в меню (26.08): показываем как
   подсказку для поиска, но не подставляем в поле — иначе шеф ищет в
   справочнике название, которого там никогда не было */
.guess-line {
  font-size: 12px; color: var(--muted); margin-top: 3px;
  padding: 4px 8px; background: #fff8ed; border-radius: 8px;
  border: 1px solid #f3e2c7;
}

/* ═══════════════════════════════════════════════════════════════════════
   УТРЕННЯЯ СТРАНИЦА ШЕФА (task 19)
   Среднее и максимум намеренно не используются: основной экран показывает
   медиану, p90, долю сверх ресторанного SLA и суммарный ущерб.
   ═══════════════════════════════════════════════════════════════════════ */
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.morning-loading {
  position: sticky; top: 8px; z-index: 10; width: max-content; max-width: 100%;
  margin: 0 auto 12px; padding: 8px 13px; border-radius: 999px;
  background: #111827; color: #fff; font-size: 12px; box-shadow: var(--shadow);
}
.morning-warnings { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.morning-warnings:empty { display: none; }
.morning-warning {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; gap: 9px;
  padding: 10px 12px; border: 1px solid #f0d6a9; border-radius: 11px;
  background: #fff8ed; color: #71480f; font-size: 13px; line-height: 1.4;
}
.morning-warning span {
  display: flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: #f6dfb9; font-weight: 800;
}
.morning-warning p { margin: 1px 0 0; min-width: 0; overflow-wrap: anywhere; }
.morning-warning-error { border-color: #f3c0c0; background: #fff1f1; color: var(--danger); }
.morning-section { margin: 0 0 26px; }
.morning-section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.morning-section-head h3 { margin: 0; font-size: 17px; }
.morning-section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.quality-strip.morning-quality {
  grid-template-columns: minmax(118px, 1.05fr) repeat(5, minmax(105px, 1fr));
}
.quality-unknown { background: #f7f7f8; }
.quality-unknown strong, .quality-unknown span { color: var(--muted); }
.morning-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.morning-kpis .kpi { min-width: 0; padding: 14px; }
.morning-kpis .kpi-val { font-size: 23px; overflow-wrap: anywhere; }
.kpi-compare { margin-top: 9px; font-size: 11px; line-height: 1.35; color: var(--muted); }
.comparison-worse { color: var(--danger); }
.comparison-better { color: #1f8050; }
.morning-footnote { margin-top: -8px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.morning-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.morning-action {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: start; gap: 9px;
  padding: 12px 13px; border: 1px solid #cfe0fb; border-radius: 11px; background: #f3f7ff;
  font-size: 13px; line-height: 1.4;
}
.morning-action > strong {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border-radius: 8px; color: var(--accent); background: #dce9fa;
}
.morning-action span { min-width: 0; overflow-wrap: anywhere; }
.morning-incidents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.morning-incident {
  min-width: 0; display: grid; grid-template-columns: 145px minmax(0, 1fr);
  align-items: stretch; padding: 10px; gap: 12px;
}
.morning-incident-photo { width: 145px; height: 126px; cursor: zoom-in; }
.morning-no-photo {
  display: flex; align-items: center; justify-content: center; width: 145px; min-height: 126px;
  border-radius: 10px; background: #eef0f3; color: var(--muted); font-size: 12px; text-align: center;
}
.morning-incident-body { display: flex; flex-direction: column; min-width: 0; gap: 5px; }
.morning-timeline {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
  margin-top: auto; padding-top: 7px; border-top: 1px solid var(--border);
}
.morning-timeline > div { min-width: 0; }
.morning-timeline span, .morning-timeline strong { display: block; overflow-wrap: anywhere; }
.morning-timeline span { color: var(--muted); font-size: 10px; }
.morning-timeline strong { margin-top: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.morning-timeline .timeline-unknown strong { color: var(--muted); font-size: 10px; font-weight: 600; }
.morning-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; margin-bottom: 26px; }
.morning-section-card { min-width: 0; margin: 0; }
.morning-hour-list { display: flex; flex-direction: column; gap: 9px; }
.morning-hour-row {
  display: grid; grid-template-columns: 48px minmax(50px, 1fr) 126px;
  align-items: center; gap: 9px; min-width: 0; font-size: 12px;
}
.morning-hour-row strong { font-variant-numeric: tabular-nums; }
.morning-hour-row > span { color: var(--muted); text-align: right; white-space: nowrap; }
.morning-hour-track { height: 10px; overflow: hidden; border-radius: 999px; background: #eef0f3; }
.morning-hour-track i { display: block; height: 100%; border-radius: 999px; background: #d67b35; }
.morning-unavailable {
  padding: 14px; border-radius: 11px; border: 1px dashed #c9cdd4; background: #fafafb;
}
.morning-unavailable strong { font-size: 14px; }
.morning-unavailable p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.morning-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.morning-table { width: 100%; min-width: 650px; border-collapse: collapse; background: var(--surface); }
.morning-table th, .morning-table td { padding: 10px 13px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
.morning-table th { color: var(--muted); background: #fafafb; font-size: 11px; }
.morning-table tr:last-child td { border-bottom: 0; }
.morning-empty { padding: 24px 8px; }
.morning-journal-link { display: flex; justify-content: flex-end; padding: 2px 0 8px; }

@media (max-width: 900px) {
  .morning-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .morning-incidents { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .quality-strip.morning-quality { grid-template-columns: 1fr 1fr; }
  .morning-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .morning-kpis .kpi { padding: 12px; }
  .morning-kpis .kpi-val { font-size: 21px; }
  .morning-actions, .morning-grid { grid-template-columns: 1fr; }
  .morning-incident { grid-template-columns: 118px minmax(0, 1fr); }
  .morning-incident-photo, .morning-no-photo { width: 118px; min-height: 122px; height: 122px; }
  .morning-section { margin-bottom: 22px; }
  .morning-journal-link .btn { width: 100%; }
}

@media (max-width: 400px) {
  .quality-strip.morning-quality { grid-template-columns: 1fr 1fr; }
  .morning-warning { font-size: 12px; }
  .morning-section-head h3 { font-size: 16px; }
  .morning-incident { grid-template-columns: 1fr; }
  .morning-incident-photo, .morning-no-photo { width: 100%; height: 148px; min-height: 148px; }
  .morning-hour-row { grid-template-columns: 43px minmax(0, 1fr); gap: 7px; }
  .morning-hour-row > span { grid-column: 2; text-align: left; white-space: normal; font-size: 11px; }
  .morning-timeline { gap: 3px; }
  .morning-timeline strong { font-size: 11px; }
}

/* Расшифровка показателя простыми словами (27.08): цифра сама по себе
   ничего не объясняет, а «медиана» и «перцентиль» шефу не говорят ничего */
.kpi-hint { font-size: 11px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
