/* ДТП | Извозчик РФ — Mini App. Цвета из themeParams Telegram, по умолчанию тёмная тема.
   Палитра статусов и акцент — как в остальных мини-приложениях (Обращения). */
:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #0e1621);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #708499);
  --accent: var(--tg-theme-button-color, #2481cc);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #6ab3f3);
  --surface: color-mix(in srgb, var(--bg2) 55%, var(--bg));
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --s-new: #d99a00; --s-evaluated: #2f7fe0; --s-fixed: #1f9d68; --s-rejected: #d94452; --s-ins: #7a5af5; --s-nd: #0e9fb0;
  --danger: var(--s-rejected);
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px; --tab-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.4; }
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px); }
#app { max-width: 560px; margin: 0 auto; }
button, input, textarea { font-family: inherit; color: inherit; font-size: 16px; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

/* шапка */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--accent); color: var(--on-accent); }
.logo svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand-sub { color: var(--hint); font-size: 12px; margin-top: 2px; }
.who { margin-left: auto; color: var(--hint); font-size: 12px; text-align: right; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { border: 0; background: none; color: var(--link); font-weight: 600; padding: 6px 4px; cursor: pointer; flex: none; }

#screen { padding: 16px 16px 8px; }
h1 { font-size: 22px; line-height: 1.15; margin: 0 0 4px; font-weight: 750; letter-spacing: -.015em; }
h2 { font-size: 15px; color: var(--hint); font-weight: 650; margin: 22px 0 8px 2px; }
.muted { color: var(--hint); font-size: 13px; }
.empty { color: var(--hint); text-align: center; padding: 48px 16px; }

/* сводка */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.stat b { display: block; font-size: 19px; margin-top: 2px; }
.stat .muted { font-size: 12px; }
.stat.wide { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }

/* поиск */
.search { position: relative; margin-bottom: 12px; }
.search input { width: 100%; padding: 11px 14px 11px 38px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--hint); }
.listhead { display: flex; justify-content: space-between; color: var(--hint); font-size: 13px; margin: 0 2px 8px; }

/* список */
.card { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 13px 14px; margin-bottom: 10px; cursor: pointer; }
.card:active { transform: scale(.99); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.plate { font-weight: 750; letter-spacing: .02em; }
.plate small { color: var(--hint); font-weight: 500; letter-spacing: 0; }
.card .sub { color: var(--hint); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-weight: 700; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.st-new { --c: var(--s-new); } .st-evaluated { --c: var(--s-evaluated); } .st-fixed { --c: var(--s-fixed); } .st-rejected { --c: var(--s-rejected); } .st-insurance { --c: var(--s-ins); } .st-ins_closed { --c: var(--s-fixed); } .st-no_debt { --c: var(--s-nd); } .st-nd_closed { --c: var(--s-fixed); }
.btn.nd { background: var(--s-nd); color: #fff; }
.btn.ins { background: var(--s-ins); color: #fff; }

/* карточка заявки */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px 14px; }
.kv { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--hint); font-size: 13px; width: 112px; flex: none; padding-top: 1px; }
.kv .v { flex: 1; min-width: 0; word-wrap: break-word; }
.kv a { color: var(--link); text-decoration: none; }
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.bigsum { background: color-mix(in srgb, var(--s-evaluated) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--s-evaluated) 35%, transparent);
  border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 12px; }
.bigsum b { font-size: 24px; display: block; }
.note { border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); background: var(--bg2); cursor: zoom-in; }
.raw { white-space: pre-wrap; font-size: 13px; color: var(--hint); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; margin: 0; }
.hist { list-style: none; margin: 0; padding: 0 0 0 4px; }
.hist li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); }
.hist li:last-child { border-left-color: transparent; }
.hist li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--hint)); }
.hist .t { font-weight: 600; font-size: 14px; }
.hist .d { color: var(--hint); font-size: 13px; }

/* формы и кнопки */
.actions { display: grid; gap: 10px; margin: 18px 0 8px; }
.btn { border: 0; border-radius: var(--r-md); padding: 14px; font-weight: 650; cursor: pointer; background: var(--accent); color: var(--on-accent); width: 100%; }
.btn.secondary { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--link); }
.btn.danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.btn.ok { background: var(--s-fixed); color: #fff; }
.btn:disabled { opacity: .55; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--hint); font-weight: 600; }
.field input, .field textarea { padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); width: 100%; }
.field textarea { min-height: 96px; resize: vertical; }
.field input.big { font-size: 26px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 14px; cursor: pointer; }
.confirm { text-align: center; padding: 20px 8px; }
.confirm b { font-size: 30px; display: block; margin: 8px 0; }

/* вкладки */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar .in { display: flex; width: 100%; max-width: 560px; overflow-x: auto; }
.tab { flex: 1; min-width: 72px; height: var(--tab-h); border: 0; background: none; color: var(--hint); font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; position: relative; }
.tab .n { font-size: 17px; font-weight: 750; color: inherit; }
.tab.on { color: var(--accent); }
.tab.on::after { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px); transform: translateX(-50%); background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: 90%; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 30; display: grid; place-items: center; }
.viewer img { max-width: 100%; max-height: 100%; }

/* комментарий СБ и модалка */
.sbc { padding: 12px 14px; display: grid; gap: 8px; border-color: color-mix(in srgb, #8e6cf0 35%, transparent); }
.sbtext { white-space: pre-wrap; word-wrap: break-word; }
.modal { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 92vh; overflow-y: auto; }
.sheet textarea { min-height: 160px; }
