/* Obhod TCM - mobilnyy klient */

:root {
  --navy: #1b2a4a;
  --copper: #c0703a;
  --copper-dark: #a35c2c;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #2d2d2d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --red: #c0392b;
  --amber: #d99b3c;
  --blue: #4a7fb5;
  --green: #2e7d52;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(27, 42, 74, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  /* Stranica nikogda ne ezdit vbok - vsya informaciya v predelah ekrana */
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Segoe UI', Inter, -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  /* Prokrutka vnutrennih blokov ne "peretekaet" na stranicu */
  overscroll-behavior-x: none;
}

button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; }
img { display: block; }

/* --- Shapka --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }
.topbar h1 span { color: var(--copper); }

/* Na uzkih ekranah nazvanie ubiraem: ono i tak na znachke prilozheniya,
   a mesto nuzhno vkladkam, knopke obnovleniya i imeni polzovatelya */
@media (max-width: 460px) {
  .topbar h1 { display: none; }
}

/* Vkladki v shapke */
.top-tabs { display: flex; gap: 6px; flex: 1; }

.top-tabs button {
  position: relative;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.85);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.top-tabs button.active { background: var(--copper); color: #fff; }

.top-tabs .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--navy);
}

.user-chip {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  max-width: 34vw;
  min-width: 62px;
  flex: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Knopka obnovleniya dannyh: prilozhenie s ekrana "Domoy" samo ne perezagruzhaetsya */
.icon-btn {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 17px;
  line-height: 1;
  flex: none;
}

.icon-btn.spin { animation: spin 0.7s linear infinite; }

/* --- Obshee --- */

main { padding: 14px 14px 20px; max-width: 640px; margin: 0 auto; }

.section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.section > h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-num {
  background: var(--navy);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.section.done .step-num { background: var(--green); }
.section.locked { opacity: 0.45; pointer-events: none; }

.hint { font-size: 13px; color: var(--muted); }

/* --- Chipsy --- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  min-height: 44px;
}

.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
}

.chip.small { padding: 7px 13px; min-height: 36px; font-size: 13.5px; }

/* Schetchik na knopke filtra: otdely - nezakrytye zamechaniya,
   statusy - skolko popadet v etot filtr vnutri vybrannogo otdela */
.chip-cnt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e7eaf0;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.chip.active .chip-cnt { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* Nepodtverzhdennye zamechaniya - krasnym: ih nuzhno razobrat v pervuyu ochered */
.chip-cnt.alert { background: var(--red); color: #fff; }
.chip.active .chip-cnt.alert { background: #fff; color: var(--red); }

/* --- Plan etazha --- */

.plan-wrap {
  position: relative;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fafafa;
  max-height: 62vh;
  -webkit-overflow-scrolling: touch;
  /* Kogda plan doehal do kraya - stranica za nim ne sdvigaetsya */
  overscroll-behavior: contain;
}

/* Vnutrenniy konteyner rovno po razmeru kartinki: piny pozicioniruyutsya
   v procentah ot NEGO, a ne ot vidimogo okna - inache tochka "uezzhaet"
   pri prokrutke shirokogo plana. */
.plan-inner { position: relative; width: max-content; }

.plan-wrap img {
  height: 56vh;
  max-height: 520px;
  width: auto;
  max-width: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  /* Prokrutku (i plana, i stranicy) delaet sam brauzer - ona plavnaya, s inerciey.
     Zapreshaem tolko pinch-zoom stranicy: masshtab plana obrabatyvaem sami. */
  touch-action: pan-x pan-y;
}

.plan-wrap.fit .plan-inner { width: 100%; }
.plan-wrap.fit img { width: 100%; height: auto; }

.pin {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.pin::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--red);
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

.pin.static::after { animation: none; display: none; }

.plan-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }

.link-btn {
  background: none;
  border: none;
  color: var(--copper);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 4px;
}

/* --- Foto --- */

.photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  border: 1.5px dashed var(--copper);
  background: #faf4ef;
  color: var(--copper-dark);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

.photo-preview { position: relative; margin-top: 10px; }
.photo-preview img { width: 100%; border-radius: 10px; max-height: 300px; object-fit: cover; }

.photo-preview .retake {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(27, 42, 74, 0.85);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13.5px;
}

/* --- Forma --- */

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }

/* 16px - ne menshe: pri melkom shrifte iOS sam uvelichivaet stranicu
   pri nazhatii na pole, i posle etogo ekran nachinaet ezdit vbok. */
textarea, input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
}

textarea { resize: none; min-height: 68px; }
textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--copper); }

/* Pole daty: brauzer telefona risuet ee v formate svoego regiona (mm/dd/yyyy),
   poetomu sobstvennyy tekst polya delaem prozrachnym i risuem svoy - DD.MM.GGGG.
   Nazhatie po-prezhnemu otkryvaet nativnyy kalendar. */
.date-field { position: relative; }
.date-field input[type="date"] { color: transparent; }
.date-field input[type="date"]::-webkit-datetime-edit { color: transparent; }
.date-field input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; }

.date-field .date-view {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text);
  pointer-events: none;
}

/* Vybor ispolnitelya i sroka (naznachenie) */
.sel {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px; /* men'she 16px - iOS uvelichit stranicu pri fokuse */
  background: var(--card);
  color: var(--text);
}
.sel:focus { outline: none; border-color: var(--copper); }

/* --- Knopki --- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
}

.btn-primary { background: var(--copper); color: #fff; }
.btn-primary:active { background: var(--copper-dark); }
.btn-primary:disabled { background: #cbb5a4; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: var(--card); color: var(--navy); border: 1.5px solid var(--line); }
.btn-danger-ghost { background: var(--card); color: var(--red); border: 1.5px solid var(--line); }
.btn + .btn, .btn + a.btn { margin-top: 10px; }
a.btn { text-decoration: none; }

/* Ssylka "Vernutsya v reestr" - tolko na shirokom ekrane (kompyuter),
   na telefone reestr ne nuzhen i knopka ne pokazyvaetsya */
.desktop-only { display: none !important; }
@media (min-width: 700px) { .desktop-only { display: flex !important; } }

/* --- Uspeh --- */

.success-box { text-align: center; padding: 36px 16px; }
.success-box .big { font-size: 52px; margin-bottom: 10px; }
.success-box h2 { color: var(--navy); font-size: 19px; margin-bottom: 8px; }
.success-box p { color: var(--muted); font-size: 14.5px; margin-bottom: 22px; }

/* --- Spisok zadach --- */

/* Filtry perenosyatsya po strokam: vse vidno srazu, ekran vbok ne ezdit */
.filters-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.filters-row .chip { flex: none; }

/* --- Skladyvayushiesya razdely vkladki "Zadachi" --- */

.acc {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}

.acc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  padding: 13px 14px;
  text-align: left;
}

.acc-sign {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 7px;
  background: var(--bg);
  color: var(--navy);
  font-size: 17px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.acc.open .acc-sign { background: var(--navy); color: #fff; }

.acc-title { font-size: 15px; font-weight: 700; color: var(--navy); }

.acc-cnt {
  margin-left: auto;
  background: var(--copper);
  color: #fff;
  border-radius: 999px;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.acc-body { padding: 0 12px 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.acc-body .filters-row { margin-bottom: 10px; }
.acc-body .task-card { box-shadow: none; border: 1px solid var(--line); }
.acc-body .empty-list { padding: 22px 10px; }
.acc-body .empty-list .big { font-size: 30px; }
.sect-list { max-height: 60vh; overflow-y: auto; overscroll-behavior: contain; }

.task-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.task-card img {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: var(--line);
}

.task-card .t-body { flex: 1; min-width: 0; }
.task-card .t-title { font-weight: 700; font-size: 15px; color: var(--navy); }
.task-card .t-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.task-card .t-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }

.badge-st {
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 8px;
  color: #fff;
}

.st-new { background: var(--red); }
.st-confirmed { background: var(--amber); }
.st-pending_review { background: var(--blue); }
.st-closed { background: var(--green); }
.st-duplicate { background: #8a93a3; }

.badge-overdue {
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--red);
  background: #fdecec;
}

.empty-list { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14.5px; }
.empty-list .big { font-size: 44px; margin-bottom: 8px; }

/* --- Kartochka zamechaniya --- */

.back-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.back-btn { background: none; border: none; color: var(--navy); font-size: 15px; font-weight: 600; padding: 8px 8px 8px 0; }

.issue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.issue-head h2 { font-size: 18px; color: var(--navy); }
.issue-meta { font-size: 13.5px; color: var(--muted); }

.photos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photos-grid figure { min-width: 0; }
.photos-grid img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: var(--line); }
.photos-grid figcaption { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 5px; font-weight: 600; }
.photos-grid .no-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  border: 1.5px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 10px;
}

.mini-plan { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.mini-plan img { width: 100%; height: auto; }

.timeline { list-style: none; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; font-size: 14px; align-items: baseline; }
.timeline .tl-dot { color: var(--green); flex: none; }
.timeline .tl-dot.off { color: #c9ced8; }
.timeline .tl-when { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; flex: none; }
.timeline .tl-photo { color: var(--copper); font-weight: 600; white-space: nowrap; }

.comment-box { background: #f7f8fa; border-radius: 10px; padding: 11px 12px; font-size: 14.5px; }

/* --- Vvod imeni --- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay .panel {
  background: var(--card);
  border-radius: 18px;
  padding: 26px 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.overlay .logo { font-size: 40px; margin-bottom: 10px; }
.overlay h2 { color: var(--navy); font-size: 19px; margin-bottom: 6px; }
.overlay p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.overlay input {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px; /* men'she 16px - iOS uvelichit stranicu pri fokuse */
  background: var(--card);
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}
.overlay input:focus { outline: none; border-color: var(--copper); }
.overlay p.login-err {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
}

/* --- Toast --- */

/* --- Golosovoy vvod kommentariya --- */

.comment-row { position: relative; }
.comment-row textarea { padding-right: 52px; }

.mic-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #f0f1f5;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-btn.rec {
  background: var(--red);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 83, 79, 0.5); }
  50% { box-shadow: 0 0 0 9px rgba(217, 83, 79, 0); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  z-index: 60;
  max-width: 88vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.2s ease-out;
}

.toast.error { background: var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Desktop --- */

@media (min-width: 700px) {
  body { padding-bottom: 84px; }
  .photos-grid img, .photos-grid .no-photo { aspect-ratio: 4 / 3; }
}
