/* Оформление всех экранов. Одно место на весь проект:
   правку цвета или размера кнопки не приходится искать по шаблонам. */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --line: #d1d1d6;
  --blue: #007aff;
  --green: #1a7f37;
  --green-bg: #e7f7ec;
  --red: #b3261e;
  --red-bg: #fdecec;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любые наши display — иначе спрятанный
   элемент внезапно окажется видимым из-за правила ниже по файлу */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0 0 40px;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;   /* iOS иначе сам увеличивает шрифт */
}

header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 21px; margin: 0; }
header .sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

.back {
  display: inline-block;
  color: var(--blue);
  text-decoration: none;
  font-size: 16px;
  margin-bottom: 8px;
}

main { padding: 20px; }

/* Крупные кнопки-ссылки стартового экрана.
   Высота 64px — минимум, в который уверенно попадаешь пальцем в перчатке. */
.big-link {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 20px;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.big-link .arrow { float: right; color: var(--muted); }
.big-link:active { background: #e8e8ed; }

/* Список объектов */
.site {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
}
.site:active { background: #e8e8ed; }
.site__name { font-size: 17px; font-weight: 500; padding-right: 34px; }
.site__addr { font-size: 14px; color: var(--muted); margin-top: 4px; padding-right: 34px; }

/* Галочка состояния отчёта в углу карточки объекта */
.site { position: relative; }
.site__mark {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
}
.site__mark.ok   { color: var(--green); }
.site__mark.fail { color: var(--red); }

/* Заголовки разделов на экране объекта */
.section {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin: 4px 0 10px;
}
.section:not(:first-child) { margin-top: 26px; }
.section__hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
}

/* Четыре слота под фотографии, сеткой 2x2 */
.slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Обёртка нужна, чтобы кнопка просмотра лежала рядом с label, а не внутри:
   нажатие внутри label открывает камеру */
.slot-wrap { position: relative; }
.slot-wrap .slot { height: 100%; }

.slot__zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  z-index: 4;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.slot__zoom:active { background: rgba(0, 0, 0, .8); }

/* Просмотр во весь экран */
#viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
#viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
#viewer-hint {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, .6);
  font-size: 13px;
}

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 12px;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.slot:active { background: #e8e8ed; }
.slot input { display: none; }

.slot__label { font-size: 16px; font-weight: 500; z-index: 2; }
.slot__state { font-size: 13px; color: var(--muted); margin-top: 6px; z-index: 2; }

/* Миниатюра лежит фоном, подпись читается поверх затемнения */
.slot__thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.slot.has-photo .slot__thumb { display: block; }
.slot.has-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
}
.slot.has-photo .slot__label,
.slot.has-photo .slot__state { color: #fff; position: relative; }

.slot.done  { border-color: var(--green); border-style: solid; }
.slot.fail  { border-color: var(--red);   border-style: solid; }
.slot.busy  { border-color: var(--blue);  border-style: solid; }

/* Нижняя кнопка отчёта */
.submit {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 18px;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: 14px;
  cursor: pointer;
}
.submit:disabled { background: var(--muted); }

.note {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  font-size: 15px;
  line-height: 1.45;
}
.note.ok   { background: var(--green-bg); color: var(--green); }
.note.fail { background: var(--red-bg);   color: var(--red); }

/* Метка версии внизу страницы — видно, свежий код на телефоне или из кэша */
.build {
  margin: 28px 20px 0;
  font-size: 12px;
  color: var(--line);
  text-align: center;
}

/* Красная полоса со сбоем скрипта. Появляется поверх всего: молчаливая
   поломка страшнее некрасивой */
#js-error {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  padding: 12px 16px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

/* Поле ввода в настройках */
.field {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
label.field-label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 8px 2px;
}

/* Комментарий электрика */
.kommentariy {
  min-height: 90px;
  resize: vertical;
  line-height: 1.4;
}

.podskazka {
  margin: 8px 2px 0;
  font-size: 13px;
  color: var(--muted);
}

/* Негромкая кнопка: нужна редко, но должна быть на виду.
   «Это не тот объект» — не действие на каждый день */
.tihaya {
  display: block;
  width: 100%;
  margin-top: 28px;
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.tihaya:active { background: #e8e8ed; }

/* Кнопки выбора объекта для переноса выглядят как ссылки списка */
button.big-link {
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  margin-top: 12px;
}
