/* Портал смен — одна вёрстка на все точки.
   Палитра приходит из CSS-переменных, которые base.html подставляет из VENUES[key]["theme"].
   Правило вёрстки: телефон, один столбец, палец в перчатке. Ничего мельче 56px по высоте. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  /* Место под «чёлку» и домашнюю полоску iPhone. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3 {
  font-family: var(--font-head);
  margin: 0 0 10px;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

a { color: var(--accent2); }

/* ── Каркас ────────────────────────────────────────────────────────────── */

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 40px;
  /* Страница не должна ездить по горизонтали: широкие блоки
     прокручиваются внутри себя, а не тянут за собой вёстальное. */
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
}

.topbar .brand {
  font-family: var(--font-head);
  font-size: 19px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.topbar .sub {
  font-size: 13px;
  color: var(--muted);
  /* Адрес точки бывает длинным — режем многоточием, а не краем экрана. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Блок названия в шапке должен сжиматься, иначе выталкивает соседей. */
.topbar .titles { min-width: 0; flex: 1; }

/* Кнопка «назад» — тоже крупная, попасть с одной руки. */
.back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 22px;
  text-decoration: none;
}

.spacer { flex: 1; }

/* ── Типовые блоки ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}

.card.accent { border-left: 6px solid var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.big-num { font-family: var(--font-head); font-size: 40px; line-height: 1; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }

/* Длинное название точки не должно выдавливать плашку статуса за край. */
.row.between > .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row.between > .pill { flex: none; }

.pill {
  display: inline-block;
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.pill.on { background: var(--accent2); color: #06180f; }
.pill.off { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.pill.warn { background: var(--accent); color: #fff; }

/* ── Кнопки ────────────────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 14px 18px;
  margin-bottom: 12px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.06s ease;
}

.btn:active { transform: scale(0.985); }

.btn.primary { background: var(--accent); color: #fff; }
.btn.ok { background: var(--accent2); color: #06180f; }
.btn.ghost { background: rgba(255, 255, 255, 0.07); }

.btn.danger {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.btn[disabled], .btn.locked {
  opacity: 0.45;
  pointer-events: none;
}

.btn .ico { font-size: 26px; flex: 0 0 32px; text-align: center; }
.btn .t { flex: 1; }
.btn .t small { display: block; font-weight: 400; font-size: 14px; opacity: 0.8; }

/* Плитка рабочего экрана — выше обычной кнопки, чтобы попадать не глядя. */
.tile {
  min-height: 88px;
  align-items: center;
  font-size: 19px;
}

.tile.alarm {
  background: var(--accent);
  color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
  50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.12); }
}

.btn-row { display: flex; gap: 12px; }
.btn-row .btn { margin-bottom: 12px; }

/* Пара «Готово / Проблема» внизу экрана шага. */
.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ── Формы ─────────────────────────────────────────────────────────────── */

label.field { display: block; margin-bottom: 16px; }
label.field > span { display: block; margin-bottom: 8px; font-weight: 600; }

input[type="text"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%;
  min-height: 60px;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 19px;
}

textarea { min-height: 130px; resize: vertical; line-height: 1.35; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Крупное поле для суммы — цифры видно с вытянутой руки. */
input.money {
  font-family: var(--font-head);
  font-size: 34px;
  text-align: center;
  min-height: 76px;
}

/* Чекбокс «срочно» — вся строка кликабельна. */
.check {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.check input { width: 30px; height: 30px; accent-color: var(--accent); flex: 0 0 30px; }

/* Загрузка фото: настоящий input спрятан, нажимается вся зона. */
.photo {
  display: block;
  margin-bottom: 16px;
}

.photo input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.photo .zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 92px;
  padding: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  background: var(--surface);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.photo.required .zone { border-color: var(--accent); }
.photo .zone .ico { font-size: 30px; }
.photo img.preview { display: none; width: 100%; border-radius: 18px; margin-top: 10px; }
.photo.has-file .zone { border-style: solid; border-color: var(--accent2); }

/* ── Прогресс ──────────────────────────────────────────────────────────── */

.progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin: 10px 0;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent2);
}

/* ── PIN ───────────────────────────────────────────────────────────────── */

.dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 22px 0;
  min-height: 26px;
}

.dots i {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.dots i.on { background: var(--accent); }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pad button {
  min-height: 74px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-head);
  font-size: 30px;
  cursor: pointer;
}

.pad button:active { background: var(--accent); color: #fff; }
.pad button.wide { grid-column: span 1; font-size: 22px; font-family: var(--font); }

/* ── Лента ─────────────────────────────────────────────────────────────── */

.feed { margin: 0; padding: 0; list-style: none; }

.feed li {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: var(--surface);
}

.feed li.unread {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.feed .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.feed .txt { font-size: 17px; }
.feed img { width: 100%; border-radius: 12px; margin-top: 10px; }

/* ── Таблицы (главная сети и админка) ──────────────────────────────────── */

/* Календарь недели шире экрана — прокручивается внутри себя.
   Отрицательные поля здесь нельзя: они растягивают всю страницу
   и уводят карточки точек за правый край. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; }
td.name { white-space: normal; }

/* Календарь недели: точки строками, дни столбцами. */
.cal td, .cal th { text-align: center; min-width: 54px; }
.cal td.v { text-align: left; font-weight: 700; }
.cal td.today { background: rgba(255, 255, 255, 0.06); }
.cal .who { font-size: 13px; }
.cal .none { color: var(--muted); }

/* ── Главная сети ──────────────────────────────────────────────────────── */

/* Плитка точки красится своим акцентом через inline style. */
.venue-tile {
  display: block;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: var(--surface);
  border-left: 8px solid var(--accent);
  color: var(--text);
  text-decoration: none;
}

.venue-tile .name { font-family: var(--font-head); font-size: 21px; }
.venue-tile .line { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 15px; }
.venue-tile .rev { font-family: var(--font-head); font-size: 22px; }

.flash {
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Касса в сводке ──────────────────────────────────────────────────────
   Только экран управляющих: на публичных страницах выручки нет. */
.rev { font-family: var(--font-head); font-weight: 600; white-space: nowrap; }
.up { color: var(--accent2); white-space: nowrap; }
.down { color: #ff6b6b; white-space: nowrap; }
tr.total td { border-top: 1px solid rgba(255, 255, 255, 0.14); font-weight: 700; }

/* ── Выводы по сводке ────────────────────────────────────────────────────
   Короткие фразы с цветной полоской слева: тон задаёт services/dashboard.py. */
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insights li {
  padding: 10px 14px;
  border-left: 4px solid var(--muted);
  border-radius: 0 12px 12px 0;
  background: rgba(255, 255, 255, 0.03);
  font-size: 15px;
  line-height: 1.45;
}
.insights .tone-good { border-left-color: var(--accent2); }
.insights .tone-bad { border-left-color: #ff6b6b; }
.insights .tone-warn { border-left-color: #f0a500; }
.insights .tone-info { border-left-color: var(--accent); }

/* ── Стоп-лист ───────────────────────────────────────────────────────────
   Колонками на ноутбуке, в столбик на телефоне. */
.stops { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.stop-venue h3 { font-family: var(--font-head); font-size: 17px; margin: 0 0 8px; }
.stop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.stop-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
  padding-left: 14px;
  position: relative;
  font-size: 15px;
}
/* Точка-маркер: красная у свежего стопа, приглушённая у висяка. */
.stop-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff6b6b;
}
.stop-list li.stale::before { background: var(--muted); }
.stop-list li.stale .what { color: var(--muted); }

/* ── График смен ─────────────────────────────────────────────────────────
   Семь колонок в ряд: на телефоне таблица уезжает в горизонтальный скролл. */
.week-nav { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.week-nav .chip { width: auto; margin: 0; padding: 10px 16px; font-size: 15px; }
.week-nav .chip .t { flex: none; }

table.sched td, table.sched th { vertical-align: top; padding: 8px 6px; }
table.sched th.today { color: var(--accent); }
table.sched th.weekend { color: var(--accent2); }
table.sched td.past { opacity: 0.65; }
table.sched .vname { font-family: var(--font-head); white-space: nowrap; padding-top: 16px; }
table.sched select { min-width: 130px; padding: 10px; margin: 0; font-size: 15px; }
/* Заполненная клетка заметна боковой полоской: пустую неделю видно сразу. */
table.sched select.filled { border-left: 3px solid var(--accent); }

/* Факт под планом: галка — сошлось, красное — вышел не тот, кто в графике. */
table.sched .fact { margin-top: 5px; font-size: 13px; color: var(--muted); }
table.sched .fact.bad { color: #ff6b6b; }
