:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6c6c70;
  --line: #d1d1d6;
  --accent: #0a64d6;
  --ok: #1f9d47;
  --warn: #c98a00;
  --fail: #d70015;
  --info: #8e8e93;
  --ok-bg: #e5f6ea;
  --warn-bg: #fff4d6;
  --fail-bg: #ffe5e7;
  --info-bg: #ededf0;
  --tap: 48px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #a1a1a6;
    --line: #38383a;
    --accent: #4ea1ff;
    --ok: #32d74b;
    --warn: #ffd60a;
    --fail: #ff453a;
    --info: #8e8e93;
    --ok-bg: #0f2a17;
    --warn-bg: #2f2706;
    --fail-bg: #3a1012;
    --info-bg: #2c2c2e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  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;
}

.app { max-width: 600px; margin: 0 auto; padding-bottom: 32px; }
main { padding: 0 12px; }
h1 { font-size: 20px; margin: 0; }
h2.group-head { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin: 20px 4px 8px; }
button { font: inherit; color: inherit; }

/* Верхняя панель */
.bar {
  position: sticky; top: 0; z-index: 2;
  display: grid; grid-template-columns: 96px 1fr 96px; align-items: center;
  min-height: 52px; padding: 4px 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar h1 { text-align: center; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .icon { justify-self: end; }
.back, .icon {
  min-width: var(--tap); min-height: var(--tap); border: 0; background: none; color: var(--accent);
  font-size: 18px; padding: 0 8px; cursor: pointer; text-align: left;
}
.icon { font-size: 24px; text-align: center; }
body.busy .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Потянуть вниз */
.pull {
  height: var(--pull, 0px); overflow: hidden; text-align: center; color: var(--muted);
  font-size: 14px; line-height: 40px; transition: height .15s;
}
.pull.ready { color: var(--accent); }

/* Итог */
.summary {
  margin: 12px 0; padding: 14px 16px; border-radius: 14px; background: var(--card);
  border-left: 6px solid var(--info);
}
.summary.st-ok { border-left-color: var(--ok); }
.summary.st-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.summary.st-fail { border-left-color: var(--fail); background: var(--fail-bg); }
.summary-main { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.age { margin-top: 6px; color: var(--muted); }
.age-warn { color: var(--warn); font-weight: 600; }
.age-fail { color: var(--fail); font-weight: 600; }
.checked { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* Семафор */
.dot {
  flex: none; display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--info); margin-top: 3px;
}
.dot.st-ok { background: var(--ok); }
.dot.st-warn { background: var(--warn); }
.dot.st-fail { background: var(--fail); }
.dot.st-info { background: var(--info); }

/* Разделы */
.block { background: var(--card); border-radius: 14px; margin: 12px 0; overflow: hidden; }
.block > summary {
  min-height: var(--tap); padding: 12px 16px; font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.block > summary::-webkit-details-marker { display: none; }
.block > summary::after { content: "›"; margin-left: auto; color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
.block:not([open]) > summary::after { transform: none; }
.group-title { display: inline-flex; align-items: center; gap: 4px; }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; min-height: 56px;
  color: inherit; text-decoration: none; border-top: 1px solid var(--line);
}
.rows > .row:first-child { border-top: 0; }
.block .rows > .row:first-child { border-top: 1px solid var(--line); }
main > .rows { background: var(--card); border-radius: 14px; overflow: hidden; }
.row:active { background: var(--info-bg); }
.row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.chev { color: var(--muted); font-size: 22px; align-self: center; }
.tag { margin-left: 8px; font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 6px; background: var(--ok-bg); color: var(--ok); }

/* Проверки */
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.block .items { border-radius: 0; }
.item { display: flex; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.items > .item:first-child { border-top: 0; }
.block .items > .item:first-child { border-top: 1px solid var(--line); }
.item-body { min-width: 0; flex: 1; }
.item-title { font-weight: 600; }
.detail { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.detail-list { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.since { font-size: 13px; color: var(--muted); margin-top: 2px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Вход */
.center { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 15vh 24px 24px; gap: 14px; }
.logo { border-radius: 22px; }
.primary {
  min-height: 56px; width: 100%; max-width: 360px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 600; cursor: pointer;
}
.primary:disabled { opacity: .5; }
.link { border: 0; background: none; color: var(--accent); min-height: var(--tap); padding: 0 12px; cursor: pointer; }
.hint { color: var(--muted); font-size: 15px; max-width: 360px; }
.msg { color: var(--fail); min-height: 1.3em; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.foot { text-align: center; margin-top: 24px; }

/* Режим разработки */
.dev { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 14px; color: var(--muted); }
.seg { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.seg.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  body.busy .icon { animation: none; }
  .pull, .block > summary::after { transition: none; }
}

/* В строках списка — не больше двух строк пояснения; полностью — на экране площадки/машины. */
.row .row-sub { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
