/*  Приложение отряда ГБР — телефон, крупные элементы, одна рука.
    Внешний вид как у системных приложений iOS: сгруппированные списки,
    крупные кнопки, полупрозрачная шапка. Основа — /vendor/safe/ui.css. */

html, body { height: 100%; overscroll-behavior: none; }
body { background: var(--bg); font-size: 16px; -webkit-user-select: none; user-select: none; }
input { -webkit-user-select: text; user-select: text; }

:root { --bg: #F2F2F7; }
@media (prefers-color-scheme: dark) { :root { --bg: #000; } }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── Шапка ────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 20px 12px;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: inset 0 -.5px 0 var(--sep);
}

.topbar__title { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.topbar__sub { color: var(--label-2); font-size: 13px; }

/* Вызов: шапка красная — видно издалека, что идёт тревога. */
.topbar--alert { background: var(--red); color: #fff; box-shadow: none; }
.topbar--alert .topbar__sub { color: rgba(255, 255, 255, .82); }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray); }
.dot.is-online { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 22%, transparent); }
.dot.is-offline { background: var(--red); }

.timer { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ── Смена ────────────────────────────────────────────────────────────── */

.shift {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.shift__big { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.shift__hint { margin: -8px 0 4px; color: var(--label-2); font-size: 15px; line-height: 1.45; }

.big-button {
  height: 58px;
  border: 0;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  transition: transform .15s var(--ease), filter .2s;
}

.big-button:active { transform: scale(.98); }
.big-button.is-on { background: color-mix(in srgb, var(--red) 14%, var(--surface)); color: var(--red-text); }

/* Состояние — сгруппированный список, как в «Настройках». */
.stat { border-radius: 14px; background: var(--surface); overflow: hidden; }

.stat__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  font-size: 15px;
  box-shadow: inset 0 -.5px 0 var(--sep);
}

.stat__row:last-child { box-shadow: none; }
.stat__row span { color: var(--label); }
.stat__row b { color: var(--label-2); font-weight: 400; text-align: right; }

.ghost {
  margin-top: auto;
  padding: 14px;
  border: 0;
  background: transparent;
  color: var(--red-text);
  font-size: 16px;
}

/* ── Вызов ────────────────────────────────────────────────────────────── */

.call { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.map { height: 34vh; min-height: 200px; background: #E9E8E4; }

.panel {
  position: relative;
  flex: 1;
  margin-top: -18px;
  padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .08);
  z-index: 500;
}

.address { font-size: 22px; font-weight: 700; letter-spacing: -.025em; line-height: 1.25; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface); color: var(--label); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-1); }

.note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  font-size: 15px;
}

/* Код отмены: крупно и вразрядку — его диктуют голосом у подъезда. */
.cancel-code {
  display: grid;
  gap: 2px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
}

.cancel-code__label { font-size: 13px; color: var(--orange-text); font-weight: 600; }
.cancel-code__value { font-size: 34px; font-weight: 700; letter-spacing: .24em; font-variant-numeric: tabular-nums; }
.cancel-code__hint { font-size: 12.5px; color: var(--label-2); }

.actions, .status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.btn {
  flex: 1 1 44%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--blue-text);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: transform .15s var(--ease);
}

.btn:active { transform: scale(.98); }
.btn--nav { flex-basis: 100%; background: var(--blue); color: #fff; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--ok { background: var(--green); color: #fff; }
.btn[disabled] { opacity: .4; }
.btn.is-hidden { display: none; }

.status-actions .btn { min-height: 56px; font-size: 17px; }

/* ── Чат ──────────────────────────────────────────────────────────────── */

.chat { margin-top: 22px; }
.chat__label { margin: 0 4px 8px; color: var(--label-2); font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
.chat__log { display: flex; flex-direction: column; gap: 8px; max-height: 32vh; overflow-y: auto; }
.chat__empty { color: var(--label-2); font-size: 14px; padding: 4px; }

.msg { max-width: 82%; padding: 8px 13px 9px; border-radius: 18px; background: var(--surface); font-size: 16px; line-height: 1.35; }
.msg__head { color: var(--label-2); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.msg--resident { align-self: flex-start; border-bottom-left-radius: 6px; }
.msg--resident .msg__head { color: var(--red-text); }
.msg--dispatcher { align-self: flex-start; border-bottom-left-radius: 6px; }
.msg--dispatcher .msg__head { color: var(--blue-text); }
.msg--crew { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.msg--crew .msg__head { color: rgba(255, 255, 255, .75); }

.chat__form { display: flex; gap: 8px; margin-top: 12px; }

.chat__form input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--sep);
  font-size: 16px;
  outline: none;
}

.chat__form button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--blue); color: #fff; font-size: 20px; font-weight: 600; }

/* ── Карта ────────────────────────────────────────────────────────────── */

.leaflet-container { background: #E9E8E4; font: inherit; }
.leaflet-tile-pane { filter: saturate(.4) brightness(1.04) contrast(.94); }
.leaflet-control-attribution { display: none; }

@media (prefers-color-scheme: dark) {
  .map, .leaflet-container { background: #1B1C1E; }
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.32) brightness(.82) contrast(.92); }
  .panel { box-shadow: none; }
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--material-strong); color: var(--label); }

.pin {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #fff;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}

.pin--call { background: var(--red); color: #fff; }
.pin--crew { background: var(--blue); color: #fff; }
