/* ============================================================
   Городской информатор — mobile-first редизайн
   Тап-цели ≥44px · safe-area · тёмная тема · чипы-скролл
   ============================================================ */

:root {
  --red: #e53935;
  --yellow: #f9a825;
  --green: #43a047;
  --gray: #9e9e9e;
  --bg: #f3f5f9;
  --card-bg: #ffffff;
  --chip-bg: #ffffff;
  --border: #dfe4ec;
  --text: #171c26;
  --muted: #6b7686;
  --header-grad: linear-gradient(135deg, #1c2a4a 0%, #2c4a8a 100%);
  --header-text: #ffffff;
  --accent: #2c4a8a;
  --accent-grad: linear-gradient(135deg, #2c4a8a, #4a6fd1);
  --shadow: 0 2px 10px rgba(23, 28, 38, .08);
  --shadow-lg: 0 8px 24px rgba(23, 28, 38, .14);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --card-bg: #182029;
    --chip-bg: #182029;
    --border: #2a3441;
    --text: #e9edf3;
    --muted: #93a0b0;
    --header-grad: linear-gradient(135deg, #10192e 0%, #1a3059 100%);
    --accent: #6d8fe8;
    --accent-grad: linear-gradient(135deg, #33498c, #5578d6);
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;              /* ≥16px — iOS не зумит инпуты */
  line-height: 1.45;
}

/* ---------------- Шапка ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  padding: .65rem calc(1rem + env(safe-area-inset-left)) .65rem calc(1rem + env(safe-area-inset-right));
  padding-top: calc(.65rem + env(safe-area-inset-top));
  background: var(--header-grad);
  color: var(--header-text);
  box-shadow: var(--shadow-lg);
}
.topbar a { color: #ccd8ff; text-decoration: none; margin-left: .9rem; padding: .45rem 0; }
.topbar a:active { opacity: .7; }
.topbar .brand {
  font-weight: 800;
  color: var(--header-text);
  margin-left: 0;
  font-size: 1.02rem;
  letter-spacing: .01em;
  white-space: nowrap;
}
.topbar .who {
  opacity: .85;
  margin-left: .9rem;
  max-width: 28vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

/* ---------------- Контент ---------------- */

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem calc(.9rem + env(safe-area-inset-left)) calc(5.5rem + env(safe-area-inset-bottom)) calc(.9rem + env(safe-area-inset-right));
}
/* на широких экранах запас снизу не нужен */
@media (min-width: 700px) {
  .container { padding-bottom: calc(1.4rem + env(safe-area-inset-bottom)); }
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 1rem 1rem calc(1.4rem + env(safe-area-inset-bottom));
}
@media (max-width: 699px) {
  .footer { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
}

h1 { font-size: clamp(1.25rem, 4.5vw, 1.6rem); margin: .4rem 0 .8rem; font-weight: 800; }
h2 { font-size: clamp(1.05rem, 4vw, 1.25rem); margin-top: 1.4rem; }

/* ---------- CTA-кнопки (две в строку) ---------- */

.cta-row {
  display: flex;
  gap: .6rem;
  margin-bottom: 1rem;
}
.cta-row .cta {
  flex: 1;
  min-width: 0;
}
@media (min-width: 700px) {
  .cta-row { position: static; padding: 0; }
}

/* Мобильные: фиксированная полоса внизу экрана */
@media (max-width: 699px) {
  .cta-row {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 55;
    padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom));
    gap: .5rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
  .cta-row .cta {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    font-size: .82rem;
    padding: .55rem .5rem;
    border-radius: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 50px;
  padding: .75rem 1.1rem;
  border-radius: 14px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .15s ease;
  text-align: center;
  white-space: nowrap;
}
.cta:active { transform: scale(.98); }
.cta:hover { filter: brightness(1.06); }

/* ---------------- Фильтры ---------------- */

.filters { margin: .25rem 0 1rem; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .15rem 0 .55rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: .45rem .95rem;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: .93rem;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.chip.active {
  background: var(--accent-grad);
  color: #fff;
  border-color: transparent;
  font-weight: 700;
}
.chip:active { transform: scale(.96); }

.district-form { margin-top: .2rem; }
select {
  width: 100%;
  min-height: 46px;
  padding: .55rem .75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 16px;
  background: var(--card-bg);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23888' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
}

/* ---------------- Карточки событий ---------------- */

.card {
  display: block;
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 6px;
  padding: 1rem 1.05rem;
  margin-bottom: .8rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.card:active { transform: scale(.985); }
.card.red    { border-left-color: var(--red); }
.card.yellow { border-left-color: var(--yellow); }
.card.green  { border-left-color: var(--green); }
.card.gray   { border-left-color: var(--gray); }
.card.single { cursor: default; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.cat {
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  flex-shrink: 0;
  background: rgba(128, 138, 157, .14);
  border-radius: 999px;
  padding: .24rem .7rem;
  font-size: .85rem;
  white-space: nowrap;
}
.loc { margin-top: .35rem; word-break: break-word; }
.meta { margin-top: .35rem; color: var(--muted); font-size: .86rem; word-break: break-word; }
.status-line { margin-top: .45rem; }

.empty, .hint { color: var(--muted); text-align: center; padding: .9rem 0; }
.error { color: var(--red); }

/* ---------------- Кнопки / действия ---------------- */

.actions { margin: 1.1rem 0; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }

button#confirm-btn,
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: .75rem 1.35rem;
  border-radius: 12px;
  font-size: 1rem;
  cursor: pointer;
}
button#confirm-btn {
  background: var(--accent-grad);
  color: #fff;
  border: none;
  font-weight: 700;
  box-shadow: var(--shadow);
}
button#confirm-btn:active { transform: scale(.97); }
button#confirm-btn[disabled] { opacity: .55; }
.btn-link { background: rgba(128, 138, 157, .14); color: var(--text); text-decoration: none; }

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: .6rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 480px) {
  button#confirm-btn { width: 100%; }
  .actions { flex-direction: column; align-items: stretch; text-align: center; }
}

/* ---------------- Таймлайн ---------------- */

.timeline { padding-left: .2rem; }
.tl-item {
  display: flex;
  gap: .7rem;
  padding: .55rem 0 .55rem .2rem;
  border-bottom: 1px dashed var(--border);
}
.tl-item:last-child { border-bottom: none; }
.tl-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gray);
  margin-top: .42rem;
  flex-shrink: 0;
}
.tl-dot.red    { background: var(--red); }
.tl-dot.yellow { background: var(--yellow); }
.tl-dot.green  { background: var(--green); }
.tl-time { font-size: .82rem; color: var(--muted); }
.tl-reason { font-size: .87rem; color: var(--muted); font-style: italic; word-break: break-word; }

/* ---------------- Вход ---------------- */

.login-box {
  margin: 1.6rem 0;
  display: flex;
  justify-content: center;
  padding: 1.2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Цветовые индикаторы ситуации */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.red    { background: #e53935; box-shadow: 0 0 6px rgba(229, 57, 53, .55); }
.dot.yellow { background: #fdd835; }
.dot.green  { background: #43a047; box-shadow: 0 0 6px rgba(67, 160, 71, .55); }
.dot.gray   { background: #9e9e9e; }

.dot-lg {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  vertical-align: -3px;
  margin-right: .4rem;
}
.dot-lg.red    { background: #e53935; box-shadow: 0 0 10px rgba(229, 57, 53, .6); }
.dot-lg.yellow { background: #fdd835; }
.dot-lg.green  { background: #43a047; box-shadow: 0 0 10px rgba(67, 160, 71, .6); }
.dot-lg.gray   { background: #9e9e9e; }

.author-line { margin-top: .45rem; font-size: .85rem; color: var(--muted); }

.hp-field {
  position: absolute !important;
  left: -9999px !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* ---------------- Форма сообщения о проблеме ---------------- */

.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.05rem 1.25rem;
}
.form-card label {
  display: block;
  margin: 1rem 0 .4rem;
  font-weight: 700;
  font-size: .92rem;
}
.form-card label:first-child { margin-top: 0; }
.form-card input[type="text"],
.form-card textarea,
.form-card select {
  width: 100%;
  min-height: 48px;
  padding: .65rem .8rem;
  font-size: 16px;              /* iOS: без авто-зума */
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.form-card textarea { min-height: 110px; resize: vertical; }

/* обёртка поля адреса с подсказками */
.loc-wrap { position: relative; }
.sug-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}
.sug-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 48px;
  padding: .55rem .8rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: .95rem;
  cursor: pointer;
}
.sug-item:last-child { border-bottom: none; }
.sug-item:active, .sug-item:hover { background: rgba(108, 143, 232, .12); }
.sug-item small { color: var(--muted); font-size: .8rem; }

.geo-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .5rem;
  padding: .5rem .9rem;
  min-height: 42px;
  font-size: .88rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
  cursor: pointer;
}
.geo-btn:disabled { opacity: .55; }
.rep-error {
  margin-top: .8rem;
  padding: .6rem .8rem;
  border-radius: 10px;
  background: rgba(220, 53, 69, .12);
  color: var(--red);
  font-size: .9rem;
}
.success-box { text-align: center; padding: 1.4rem 1rem; }
.success-box .big { font-size: 2.4rem; margin-bottom: .5rem; }
.success-box p { color: var(--muted); margin: .25rem 0 1rem; }

/* ---------------- Доступность ---------------- */

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------- Пагинация ---------------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 1.2rem 0 .6rem;
  flex-wrap: wrap;
}
.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.pg-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  pointer-events: none;
}
.pg-dots {
  color: var(--muted);
  font-size: .88rem;
  padding: 0 2px;
}
