/* Дизайн-система мини-приложения.
   Принцип: серьёзность Госуслуг без их интерфейса. Институциональная
   надёжность — номер, срок, основание. Простота — один экран, одно действие. */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --fg:        #14161a;
  --muted:     #6b7280;
  --line:      #e4e6ea;
  --accent:    #2563eb;
  --accent-bg: #eff4ff;
  --ok:        #15803d;
  --ok-bg:     #ecfdf3;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --danger:    #b91c1c;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(16,18,22,.05), 0 8px 24px rgba(16,18,22,.04);
  --tab-h:     64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1014;
    --surface:   #171a20;
    --fg:        #eceef2;
    --muted:     #9aa1ad;
    --line:      #262a32;
    --accent:    #6ea0ff;
    --accent-bg: #16203a;
    --ok:        #4ade80;
    --ok-bg:     #10241a;
    --warn:      #fbbf24;
    --warn-bg:   #2a1f08;
    --danger:    #f87171;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg:#0e1014; --surface:#171a20; --fg:#eceef2; --muted:#9aa1ad; --line:#262a32;
  --accent:#6ea0ff; --accent-bg:#16203a; --ok:#4ade80; --ok-bg:#10241a;
  --warn:#fbbf24; --warn-bg:#2a1f08; --danger:#f87171;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ── Шапка ───────────────────────────────────────────────────────── */
.top { padding: 20px 0 12px; }
.top h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.top .addr { color: var(--muted); font-size: 14px; margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 4px 9px;
  border-radius: 999px; margin-top: 8px;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Карточки ────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.tap { cursor: pointer; transition: transform .12s ease, border-color .12s; }
.card.tap:active { transform: scale(.985); border-color: var(--accent); }

/* Светофор: сначала вердикт, детали по тапу */
.verdict { display: flex; gap: 14px; align-items: flex-start; }
.verdict .icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 20px;
}
.verdict.ok   .icon { background: var(--ok-bg);   }
.verdict.warn .icon { background: var(--warn-bg); }
.verdict .title { font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.verdict .sub   { color: var(--muted); font-size: 14px; margin-top: 2px; }
.verdict .amount { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.verdict.warn .amount { color: var(--warn); }

.section-title {
  font-size: 13px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  margin: 22px 0 10px 2px;
}

/* ── Строки квитанции ────────────────────────────────────────────── */
.line {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.line:last-child { border-bottom: 0; }
.line .mark { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.line .mark.ok   { background: var(--ok); }
.line .mark.warn { background: var(--warn); }
.line .name { flex: 1; min-width: 0; }
.line .name b { display: block; font-weight: 550; font-size: 15px; }
.line .name span { color: var(--muted); font-size: 13px; }
.line .val { text-align: right; font-variant-numeric: tabular-nums; }
.line .val b { display: block; font-weight: 600; }
.line .val span { font-size: 13px; color: var(--warn); }
.line .chev { color: var(--muted); font-size: 18px; flex: none; }

/* ── Цепочка обоснования: главный экран продукта ─────────────────── */
.chain { position: relative; padding-left: 26px; margin: 4px 0; }
.chain::before {
  content: ''; position: absolute; left: 7px; top: 10px; bottom: 26px;
  width: 2px; background: var(--line);
}
.step { position: relative; padding: 10px 0; }
.step::before {
  content: ''; position: absolute; left: -23px; top: 16px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line);
}
.step.result::before { border-color: var(--warn); background: var(--warn); }
.step .lbl { font-size: 13px; color: var(--muted); }
.step .val { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.step .src {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px;
  font-size: 13px; color: var(--accent); background: var(--accent-bg);
  padding: 4px 9px; border-radius: 8px; cursor: pointer;
}
.step.result .val { font-size: 22px; color: var(--warn); }

/* ── Обращения ───────────────────────────────────────────────────── */
.appeal-num { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 16px; }
.deadline { font-size: 13px; color: var(--muted); margin-top: 3px; }
.deadline b { color: var(--fg); }

.track { display: flex; gap: 4px; margin-top: 12px; }
.track .seg { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.track .seg.done { background: var(--accent); }
.track-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); }

/* ── Кнопки ──────────────────────────────────────────────────────── */
.btn {
  display: block; width: 100%; padding: 14px; border: 0;
  border-radius: 12px; font-size: 16px; font-weight: 600;
  font-family: inherit; cursor: pointer; margin-top: 10px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost   { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn:active { opacity: .85; }

/* ── Бенчмарк ────────────────────────────────────────────────────── */
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--warn); border-radius: 4px; }
.bar-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 7px; }

/* ── Нижняя навигация ────────────────────────────────────────────── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs button {
  flex: 1; border: 0; background: none; font-family: inherit;
  padding: 9px 0 7px; color: var(--muted); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
.tabs button .ico { font-size: 20px; line-height: 1; }
.tabs button.active { color: var(--accent); }

/* ── Служебное ───────────────────────────────────────────────────── */
.muted { color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; opacity: .45; }
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--surface) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 8px;
}
@keyframes sh { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

.notice {
  font-size: 12px; color: var(--muted); text-align: center;
  padding: 14px 8px 4px; line-height: 1.45;
}
.sheet-back {
  position: fixed; inset: 0; background: rgba(8,10,14,.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  max-height: 82vh; overflow-y: auto; animation: up .22s ease;
}
@keyframes up { from { transform: translateY(100%) } to { transform: none } }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.sheet .doc-body {
  background: var(--bg); border-radius: 10px; padding: 14px;
  font-size: 14px; line-height: 1.6; margin-top: 12px; white-space: pre-wrap;
}
mark { background: var(--warn-bg); color: var(--fg); padding: 1px 3px; border-radius: 3px; }
