/* =========================================================================
   Чек-листы 1С — визуальная система
   «Операционная ясность»: спокойные охлаждённые нейтрали, уверенный индиго-акцент,
   сильная семантика статусов (Да/зелёный, Нет/красный). Светлая и тёмная темы.
   ========================================================================= */

:root {
  /* Нейтрали (чистые, слегка тёплые — под чёрно-белую айдентику) */
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #ececed;
  --ink: #16161a;
  --muted: #5f5f68;
  --faint: #70707a;   /* WCAG AA ≥4.5:1 на светлом фоне */
  --line: #e6e6e8;
  --line-strong: #d5d5d8;

  /* Акцент — фирменный красный World Class (из логотипа: #FF0000) */
  --brand: #ff0000;
  --brand-ink: #ffffff;
  --brand-soft: #ffe7e7;
  --accent-soft: var(--brand-soft);

  /* Тёмная «премиальная» шапка */
  --header-bg: #17171c;
  --header-ink: #ffffff;
  --header-sub: rgba(255, 255, 255, .62);
  --header-line: #2b2b31;
  --header-hover: rgba(255, 255, 255, .12);

  /* Семантика */
  --ok: #1a9e57;
  --ok-bg: #e4f5ec;
  --warn: #b26a00;
  --warn-bg: #fbeecc;
  --danger: #e00000;
  --danger-bg: #ffe7e7;

  /* Форма */
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 20px -12px rgba(16, 24, 40, .16);
  --shadow-lg: 0 12px 34px -14px rgba(16, 24, 40, .28);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --surface: #17171d;
    --surface-2: #202028;
    --ink: #f0f0f2;
    --muted: #9c9ca6;
    --faint: #8b8b95;   /* WCAG AA ≥4.5:1 на тёмном фоне */
    --line: #26262e;
    --line-strong: #35353f;

    --brand: #ff4444;
    --brand-ink: #ffffff;
    --brand-soft: #2a1313;
    --accent-soft: var(--brand-soft);

    --header-bg: #0b0b0f;
    --header-ink: #f4f4f6;
    --header-sub: rgba(255, 255, 255, .58);
    --header-line: #26262e;
    --header-hover: rgba(255, 255, 255, .1);

    --ok: #35c977;
    --ok-bg: #10271b;
    --warn: #f0b429;
    --warn-bg: #2a2312;
    --danger: #ff5a52;
    --danger-bg: #2c1414;

    --shadow-sm: none;
    --shadow: 0 8px 24px -16px rgba(0, 0, 0, .8);
    --shadow-lg: 0 16px 40px -18px rgba(0, 0, 0, .9);
  }

  /* Активная вкладка: фон «дорожки» темнее surface, а тень отключена — поэтому в тёмной
     теме поднимаем её фоном светлее дорожки + hairline, иначе «проваливается». */
  .tab.is-active {
    background: var(--line-strong);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0 0 .35em; line-height: 1.22; letter-spacing: -.01em; }
h1 { font-size: 1.05rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 720; letter-spacing: -.02em; }
h3 { font-size: 1rem; font-weight: 680; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.break { overflow-wrap: anywhere; }
.error {
  margin: 0;
  padding: 9px 12px;
  font-size: .86rem;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: var(--r-sm);
}

/* ===== Каркас ===== */
/* Бары и шапка — в одном sticky-контейнере: стекаются, не накладываются офлайн */
#appbar { position: sticky; top: 0; z-index: 30; }
.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;   /* компактнее — меньше занимает на мобильном (кнопки 44px не трогаем) */
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  color: var(--header-ink);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-line);
}
.topbar__title { flex: 1; min-width: 0; padding: 0 2px; }
.topbar__title h1 { margin: 0; color: var(--header-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { display: block; font-size: .74rem; color: var(--header-sub); margin-top: 1px; }

.icon-btn {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--header-ink);
  font-size: 1.15rem;
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--header-hover); }
.icon-btn:active { background: var(--header-hover); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 55%, transparent); }

.sync-count {
  position: absolute;
  top: 1px;
  right: -1px;
  min-width: 17px;
  padding: 0 4px;
  font-size: .66rem;
  font-weight: 700;
  line-height: 17px;
  color: #fff;
  background: var(--brand);
  border: 2px solid var(--header-bg);
  border-radius: var(--r-pill);
}
.sync-ico { display: inline-block; }

/* Единый набор иконок (line-стиль, наследует цвет текста) */
.ic {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.18em;
}
.menu-item__ic .ic { width: 1.5em; height: 1.5em; }
.menu-item__chev .ic { width: 1.2em; height: 1.2em; stroke-width: 2; }
.file-chip .ic, .bubble--note .ic, .composer__attach .ic { vertical-align: -0.2em; }
.file-chip.is-busy { opacity: .55; pointer-events: none; }
.icon-btn.is-spinning .sync-ico { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 14px calc(28px + var(--safe-b));
}
/* #view фокусируется программно при смене маршрута (tabindex=-1) — гасим UA-обводку
   по кромке padding; ловит фокус ради скринридера/клавиатуры, а не для визуального кольца. */
.view:focus, .view:focus-visible { outline: none; }

.offline-bar {
  padding: 7px 12px;
  text-align: center;
  font-size: .8rem;
  font-weight: 600;
  background: var(--warn-bg);
  color: var(--warn);
}
.update-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 12px;
  font-size: .84rem;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
}
.update-btn {
  font: inherit;
  font-size: .82rem;
  padding: 4px 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
}
.update-btn:disabled { opacity: .6; cursor: default; }

/* ===== Карточки ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

/* ===== Формы ===== */
.form { display: grid; gap: 15px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }

input[type="text"], input[type="url"], input[type="password"], input[type="search"],
input[type="tel"], input[type="number"], select, textarea {
  width: 100%;
  padding: 12px 13px;
  font-family: inherit;
  font-size: 16px; /* без зума на iOS */
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { resize: vertical; line-height: 1.4; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;                          /* место под каретку */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8a92' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}
select:disabled { opacity: .6; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: var(--ring);
}

/* ===== Свой combobox для логина (замена <datalist> — надёжен на мобильных) ===== */
.field.combo { position: relative; }
.combo-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
}
.combo-list li {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  font-size: .95rem;
  color: var(--ink);
  cursor: pointer;
}
.combo-list li:hover,
.combo-list li:active,
.combo-list li.is-active { background: var(--brand-soft); color: var(--brand); }
.combo-list li.combo-more {
  cursor: default;
  min-height: 32px;
  font-size: .82rem;
  color: var(--muted);
  background: none;
}

.check-row { display: flex; align-items: center; gap: 11px; font-size: .92rem; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

/* ===== Кнопки ===== */
.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn--primary {
  color: var(--brand-ink);
  background: var(--brand);
  border-color: transparent;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 70%, transparent);
}
.btn--primary:hover { border-color: transparent; background: color-mix(in srgb, var(--brand) 90%, #000); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn--danger:hover { border-color: var(--danger); }

/* ===== Вход ===== */
.login { max-width: 400px; margin: 0 auto; padding-top: 5vh; }
.login__brand { text-align: center; margin-bottom: 20px; }
.login__brand img { border-radius: 20px; box-shadow: var(--shadow); }
.login__brand h2 { margin-top: 12px; }
.login__brand p { margin: 4px 0 0; font-size: .9rem; color: var(--muted); }

.auth-tabs { margin-bottom: 4px; }

.phone { display: flex; align-items: stretch; gap: 8px; }
.phone__cc {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 48px;
  padding: 0 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.phone input { flex: 1; }

.conn-details { border-top: 1px solid var(--line); padding-top: 4px; }
.conn-details > summary {
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 0;
  list-style: none;
}
.conn-details > summary::-webkit-details-marker { display: none; }
.conn-details > summary::before { content: "⚙ "; }
.conn-details[open] > summary { margin-bottom: 10px; }
.conn-details .field + .field { margin-top: 12px; }

/* ===== Нижняя навигация ===== */
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex;
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottomnav button {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 2px 8px;
  font: inherit;
  font-size: .66rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color .15s ease;
}
.bottomnav button span:not(.bn__badge) {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottomnav button svg { width: 24px; height: 24px; }
.bottomnav button:hover { color: var(--ink); }
.bottomnav button.is-active { color: var(--brand); }
.bn__badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 17px; height: 17px;
  display: inline-grid; place-items: center;
  padding: 0 5px;
  font-size: .64rem; font-weight: 700; line-height: 1;
  color: #fff; background: var(--brand);
  border: 2px solid var(--surface);
  border-radius: var(--r-pill);
}

/* Плавающая кнопка «Новая заявка» */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(68px + var(--safe-b));
  z-index: 26;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: 50%;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--brand) 75%, transparent), var(--shadow);
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.fab:hover { filter: brightness(.94); }
.fab:active { transform: scale(.94); }
.fab:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow); }

/* Отступ снизу, когда есть нижняя навигация */
body.has-bottomnav .view { padding-bottom: calc(76px + var(--safe-b)); }

/* ===== Экран «Сервис» (меню) ===== */
.menu-list { display: grid; gap: 10px; }
.menu-item {
  display: flex; align-items: center; gap: 13px;
  width: 100%;
  padding: 15px 16px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .06s ease, border-color .15s ease;
}
.menu-item:hover { border-color: var(--line-strong); }
.menu-item:active { transform: translateY(1px); }
.menu-item:focus-visible { outline: none; box-shadow: var(--ring); }
.menu-item__ic {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 1.2rem;
  background: var(--brand-soft);
  border-radius: 12px;
}
.menu-item__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.menu-item__title { font-weight: 650; }
.menu-item__chev { color: var(--faint); font-size: 1.4rem; line-height: 1; }

/* ===== Строки ввода (посещаемость, счётчики) ===== */
.io-rows { display: grid; gap: 12px; }
.io-row { display: grid; grid-template-columns: 1fr 7rem; gap: 12px; align-items: center; }
.io-row__label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.io-row__hint { font-style: normal; font-weight: 400; }
.io-row input { text-align: right; font-variant-numeric: tabular-nums; }

.search-row { margin-bottom: 12px; }
.search-row input { background-image: none; }

/* ===== Вкладки-фильтры ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.tab {
  flex: 1;
  min-height: 44px;
  padding: 8px 6px;
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.tab:focus-visible { outline: none; box-shadow: var(--ring); }

/* ===== Карточки-элементы списка ===== */
.card--task, .card--issue { cursor: pointer; transition: transform .06s ease, border-color .15s ease, box-shadow .15s ease; }
.card--task:hover, .card--issue:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.card--task:active, .card--issue:active { transform: translateY(1px); }
.card--task:focus-visible, .card--issue:focus-visible { outline: none; box-shadow: var(--ring); }

.card__head, .card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__head { margin-bottom: 8px; }
.card__foot { margin-top: 12px; color: var(--muted); }
.card--task h3, .card--issue h3 { font-size: 1.02rem; }
.card--task [data-object], .card--issue [data-where] { margin: 2px 0 0; }

/* Скелетоны загрузки (первый заход без кэша) */
.skel-row { padding: 13px 4px; border-bottom: 1px solid var(--line); }
.skel {
  height: 12px; margin: 8px 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: skel-shimmer 1.3s ease-in-out infinite;
}
.skel--w40 { width: 40%; }
.skel--w60 { width: 60%; }
.skel--w70 { width: 70%; }
@keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* Плотная строка списка заявок */
#issue-cards { display: flex; flex-direction: column; }
/* Заголовок секции результатов серверного поиска */
.list-cap { margin: 16px 0 4px; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
/* Кнопка «Загрузить ещё» под списком заявок */
.load-more { display: block; width: 100%; margin: 14px 0 4px; }
.issue-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.issue-row:first-child { border-top: 1px solid var(--line); }
.issue-row:active { background: var(--surface-2); }
.issue-row:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
.issue-row__body { flex: 1; min-width: 0; }
.issue-row__title {
  font-size: .92rem; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.issue-row__sub { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.issue-row__sub + .issue-row__sub { margin-top: 1px; }
/* Правый столбец: статус, номер, дата — выровнены вправо */
.issue-row__side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.issue-row__num { white-space: nowrap; }
.issue-row__date { white-space: nowrap; }
/* Непрочитанные сообщения по заявке */
.issue-row__unread {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; line-height: 1;
  color: #fff; background: var(--brand); border-radius: 999px;
}
.issue-row.has-unread .issue-row__title { font-weight: 700; }

/* Компактная сетка формы создания заявки */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid .field { margin: 0; }
.form-grid .field--full { grid-column: 1 / -1; }

/* ===== Бейджи / статусы ===== */
.badge, .status {
  padding: 3px 10px;
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .01em;
  border-radius: var(--r-pill);
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.badge--new { background: var(--warn-bg); color: var(--warn); }
.badge--progress { background: color-mix(in srgb, var(--ink) 9%, var(--surface)); color: var(--ink); }
.badge--done { background: var(--ok-bg); color: var(--ok); }

.status.st--new { background: var(--warn-bg); color: var(--warn); }
.status.st--work { background: color-mix(in srgb, var(--ink) 9%, var(--surface)); color: var(--ink); }
.status.st--done { background: var(--ok-bg); color: var(--ok); }
.status.st--reject { background: var(--danger-bg); color: var(--danger); }
.status.st--closed { background: var(--surface-2); color: var(--muted); }
.status--sm { padding: 1px 8px; font-size: .68rem; }

.chip-issues { color: var(--danger); font-weight: 650; }

/* ===== Прогресс ===== */
.progress { height: 7px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.progress__bar {
  height: 100%; width: 0;
  background: var(--brand);
  border-radius: var(--r-pill);
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.progress__bar.is-full { background: var(--ok); }

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

/* ===== Заголовок группы / зоны ===== */
.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 4px 10px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}

/* Фото зоны (слайд обхода): тумблер + ленивое изображение */
.zone-photo-btn {
  flex: none;
  padding: 5px 12px;
  font: inherit;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  border-radius: 999px;
  cursor: pointer;
}
.zone-photo-btn:disabled { opacity: .6; cursor: default; }
.zone-photo { margin: 2px 4px 12px; }
.zone-photo img {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

/* ===== Чек-лист: пункт ===== */
.item { padding: 16px; transition: border-color .15s ease; }
.item.is-answered { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.item.is-issue { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }

.item__q { display: flex; gap: 9px; margin-bottom: 14px; }
.item__n { flex: none; color: var(--faint); font-weight: 700; font-variant-numeric: tabular-nums; }
.item__text { flex: 1; font-size: 1.02rem; line-height: 1.35; }

/* Переключатель Да / Нет */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ans {
  padding: 13px 8px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.ans:hover { border-color: var(--line-strong); }
.ans:active { transform: translateY(1px); }
.ans:focus-visible { outline: none; box-shadow: var(--ring); }
.ans:disabled { cursor: default; opacity: .65; }
.ans--yes.is-active {
  color: #fff; background: var(--ok); border-color: transparent;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--ok) 70%, transparent);
}
.ans--no.is-active {
  color: #fff; background: var(--danger); border-color: transparent;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--danger) 70%, transparent);
}

/* Замечание */
.issue { margin-top: 12px; font-size: .85rem; }
.issue__head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--danger); }
.issue__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.issue b { font-weight: 700; }
.issue__route { margin-top: 5px; padding-left: 16px; color: var(--muted); }
.issue__comment { width: 100%; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: inherit; font: inherit; }

/* Фото */
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.photos:empty { margin-top: 0; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 9px 13px;
  font: inherit;
  font-size: .86rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip:active { background: var(--brand-soft); }
.file-chip:focus-visible { outline: none; box-shadow: var(--ring); }
.photo-thumb { position: relative; width: 74px; height: 74px; }
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  cursor: zoom-in;
}

/* Просмотр фото на весь экран */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, .92);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.lightbox__close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 30px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, .35);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.lightbox__dl {
  position: absolute;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 11px 22px;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border-radius: var(--r-pill);
  text-decoration: none;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .6);
  cursor: pointer;
}
.photo-remove {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  padding: 0; font-size: 15px; line-height: 1;
  color: #fff; background: var(--danger);
  border: 2px solid var(--surface); border-radius: 50%;
  cursor: pointer;
}
/* Расширенная зона нажатия ≥44px без увеличения видимого значка */
.photo-remove::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
}
.vh {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
/* Ссылка «перейти к содержимому»: скрыта, пока не получит фокус */
.skip-link {
  position: fixed;
  top: -100px; left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  font: inherit; font-weight: 650; font-size: .9rem;
  color: var(--brand-ink);
  background: var(--brand);
  border: 0;
  border-radius: var(--r-sm);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: calc(8px + var(--safe-t, 0px));
  outline: none;
  box-shadow: var(--ring), var(--shadow);
}
.photo-add {
  display: inline-flex; align-items: center;
  margin-top: 12px;
  padding: 9px 14px;
  font-size: .86rem; font-weight: 650;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s ease;
}
.photo-add:hover { background: color-mix(in srgb, var(--brand) 18%, var(--surface)); }
.attach-row { display: flex; gap: 10px; margin-top: 10px; }
.attach-row .photo-add { flex: 1; justify-content: center; gap: 6px; margin: 0; padding: 12px; }

/* ===== Детальные экраны ===== */
/* Липкая кнопка действия — всегда под большим пальцем (экран чек-листа) */
.detail__actions {
  position: sticky;
  bottom: 0;
  margin: 20px -14px 0;
  padding: 14px 14px calc(14px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.detail__head {
  padding: 12px 14px;
  position: sticky;
  top: var(--appbar-h, 56px);       /* прижата вплотную под #appbar (высоту задаёт JS) */
  z-index: 4;
  /* гасим верхний отступ #view (14px) — стартует прямо под баром и не «едет» при
     скролле; ширина как была (боковые отступы #view сохранены) */
  margin: -14px 0 12px;
  border-top: none;
  border-top-left-radius: 0;        /* острые верхние углы — как продолжение #appbar */
  border-top-right-radius: 0;
  box-shadow: 0 6px 16px -12px rgba(0, 0, 0, .35);
}
.detail__head h2 {
  margin-bottom: 3px;
  font-size: 1rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.detail__head [data-where] { margin-bottom: 2px; }

.issue-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin: 9px 0 0; }
.issue-meta__i { font-size: .8rem; line-height: 1.3; min-width: 0; }
.issue-meta__i span { color: var(--muted); }
.issue-meta__i span::after { content: ": "; }
.issue-meta__i b { font-weight: 500; }

/* Обсуждение — переписка чатом */
.chat { display: flex; flex-direction: column; }
.chat:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
/* Карточка заявки: колонка на высоту экрана — лента заполняет, композер прижат вниз даже при коротком чате */
.view.is-detail { display: flex; flex-direction: column; min-height: calc(100vh - var(--appbar-h, 56px)); }
@supports (height: 100dvh) { .view.is-detail { min-height: calc(100dvh - var(--appbar-h, 56px)); } }
.view.is-detail .detail { flex: 1 1 auto; display: flex; flex-direction: column; }
.view.is-detail .chat { flex: 1 1 auto; }
.chat__row { display: flex; flex-direction: column; max-width: 84%; margin-top: 2px; }
.chat__row.is-head { margin-top: 10px; }
.chat__row--in { align-self: flex-start; align-items: flex-start; }
.chat__row--out { align-self: flex-end; align-items: flex-end; }
.chat__name { font-size: .73rem; font-weight: 600; color: var(--muted); margin: 0 8px 2px; }
.bubble {
  padding: 7px 10px;
  border-radius: 14px;
  font-size: .88rem;
  line-height: 1.4;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.chat__row--in .bubble { border-bottom-left-radius: 5px; }
.chat__row--out .bubble {
  background: var(--brand-soft);
  border-color: transparent;
  border-bottom-right-radius: 5px;
}
.bubble--note { color: var(--muted); font-size: .82rem; }
.bubble__text { white-space: pre-wrap; word-break: break-word; }
.bubble__link { color: var(--brand); text-decoration: underline; word-break: break-all; }
.bubble__foot { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 3px; }
.bubble__time { font-size: .67rem; color: var(--muted); }
.chat__row .file-chip { max-width: 100%; }
.chat__row .bubble__time { margin: 2px 6px 0; }

/* Смена статуса / системное событие — плашкой по центру */
.chat__sys {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 92%;
  margin: 10px 0 2px;
  padding: 3px 11px;
  font-size: .73rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  text-align: center;
}
.chat__sys-time { opacity: .8; }

/* Вложения без строки истории */
.chat__att { align-self: stretch; margin-top: 14px; }
.chat__att-cap { font-size: .73rem; color: var(--muted); margin: 0 0 6px; }
.chat__att-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* Строка ответа по заявке (composer) — закреплена внизу экрана в длинной ленте */
.composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  /* гасим нижний отступ #view (28px + safe) — композер вплотную к низу и не «ходит» */
  margin: 14px 0 calc(-28px - var(--safe-b));
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-b));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -6px 16px -10px rgba(0, 0, 0, .28);
}
.composer__row { display: flex; align-items: flex-end; gap: 8px; }
.composer__text {
  flex: 1; min-height: 38px; max-height: 140px; resize: none;
  padding: 8px 10px; line-height: 1.35;
}
/* «Отправить»: активна (фирменная) — когда есть что отправить; иначе приглушена и некликабельна */
.composer__send { flex: none; width: auto; margin: 0; padding: 9px 16px; }
.composer__send:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; opacity: 1; cursor: default; }
.composer__attach {
  flex: none; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--muted);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.composer__attach:active { background: var(--surface-2); }
.composer__files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pending-file {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .8rem; padding: 4px 4px 4px 10px;
  background: var(--surface-2); border-radius: 999px;
}
.pending-file__rm {
  position: relative;
  border: 0; background: none; cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%;
  color: var(--muted); font-size: 1rem; line-height: 1;
}
/* Расширенная зона нажатия ≥44px без увеличения видимого значка */
.pending-file__rm::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
}
.pending-file__rm:active { background: var(--line); }
/* Кнопка открытия попапа параметров */
.composer__params {
  display: flex; align-items: center; gap: 8px;
  width: 100%; margin-top: 8px; padding: 9px 12px; min-height: 40px;
  font: inherit; font-size: .88rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
}
.composer__params span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.composer__params .ic { color: var(--faint); flex: none; }
.composer__params:focus-visible { outline: none; box-shadow: var(--ring); }
/* Выбрано — кнопка выглядит как значение, а не подсказка */
.composer__params.is-set { color: var(--ink); border-color: var(--line-strong); }
.composer__params.is-set .ic { color: var(--brand); }
.composer__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.composer__grid .field { margin: 0; }
.composer .error { margin-top: 8px; }

/* Попап параметров заявки (нижний лист) */
.sheet {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .4);
}
.sheet__panel {
  width: 100%; max-width: 640px;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 16px 16px calc(16px + var(--safe-b));
  box-shadow: 0 -10px 30px -12px rgba(0, 0, 0, .5);
  max-height: 82vh; overflow-y: auto;
}
.sheet__title { font-weight: 700; font-size: 1rem; margin-bottom: 12px; }
.sheet__done {
  width: 100%; margin-top: 14px; min-height: 44px; padding: 12px;
  font: inherit; font-weight: 600; color: #fff;
  background: var(--brand); border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.sheet__done:focus-visible { outline: none; box-shadow: var(--ring); }

/* Прокрутка вниз — прячем прижатую шапку карточки */
.detail__head { transition: transform .22s ease; }
body.hide-head .detail__head { transform: translateY(calc(-100% - 12px)); }

/* ===== Настройки ===== */
.settings h3 { margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; }

/* ===== Тост ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  z-index: 50;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 11px 18px;
  font-size: .88rem;
  font-weight: 550;
  color: #fff;
  background: #1c2333;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s cubic-bezier(.4, 0, .2, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

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