/*
 * Оформление «Поля». Тёмное, крупное, с большими кнопками: приложением
 * пользуются в перчатках, на стремянке и на солнце, где светлый экран не
 * читается. Ничего внешнего не подключается — шрифты системные, иначе на
 * объекте без сети интерфейс поедет.
 */

:root {
  --bg: #16161a;
  --card: #1f1f25;
  --card-2: #26262e;
  --line: #33333d;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --radius: 14px;
  --tap: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: contain;
}

.loading { padding: 40px; text-align: center; color: var(--muted); }

/* --- каркас --- */

header.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(22, 22, 26, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

header.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
header.bar .sub { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }

main { padding: 14px 14px 90px; display: flex; flex-direction: column; gap: 12px; }

/* --- карточки и списки --- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.item:active { background: var(--card-2); }
.item .title { font-weight: 600; margin-bottom: 3px; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.pill.green { color: var(--green); }
.pill.red { color: var(--red); }
.pill.orange { color: var(--orange); }
.pill.blue { color: var(--accent); }
.pill.gray { color: var(--muted); }

/* --- поля ввода --- */

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }

input, textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
}

textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Числовое поле на телефоне должно открывать цифровую клавиатуру,
   а не прыгающие стрелки. */
input[inputmode="decimal"]::-webkit-outer-spin-button,
input[inputmode="decimal"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --- кнопки --- */

button.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.btn:active { transform: translateY(1px); }
button.btn[disabled] { opacity: .45; }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.danger { color: var(--red); }
button.btn.wide { width: 100%; }
button.btn.icon { min-width: var(--tap); padding: 0 12px; }

/* --- сетка фото --- */

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.photo { position: relative; }
.photo .mark {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0, 0, 0, .65); border-radius: 6px; padding: 1px 6px; font-size: 12px;
}

/* --- статус связи и очереди --- */

.banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card-2);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.banner.offline { background: #3a2a12; color: #fbbf24; }
.banner.sync { background: #12283a; color: #7dd3fc; }
.banner.error { background: #3a1414; color: #fca5a5; }

.spacer { height: 8px; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* Экран входа занимает весь экран и центрирует форму. */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}

.login h1 { margin: 0 0 4px; font-size: 26px; }
