/* ТОП-ТОЗА. Оформление — как ФинРепорт: светлый фон, белые карточки со
   скруглением, зелёный акцент, тонкие линии, шрифт Inter.
   Сначала телефон (цех и дорога), потом компьютер.

   Два правила, которые не отменяет никакая перекраска:
   1) цвет несёт смысл — красный это тревога, зелёный «готово», янтарный «ждёт»;
   2) у мойщика мокрые руки, у водителя одна рука на телефоне: кнопки на
      телефоне не уменьшаются, какой бы мелкой ни была вёрстка на компьютере. */
:root {
  color-scheme: light;
  /* палитра ФинРепорта */
  --em: #00B956;            /* главный акцент: действие, выбранное, «готово» */
  --em-dark: #00A04A;
  --em-soft: rgba(0,185,86,.12);
  --blue: #2563EB;          /* ссылки и второстепенные действия */
  --blue-dark: #1D4ED8;
  --link: #2563EB;
  --text: #16192A;
  --muted: #667085;        /* 4,8:1 на белом: читается на солнце и за мокрым стеклом */
  --line: #EAEDF3;
  --bg: #F4F6F9;
  --panel: #FFFFFF;
  --red: #F0455A;
  --green: #00B956;
  --amber: #F59E0B;
  --gold-bg: #FEF3C7;
  --gold-ink: #92400E;
  --font: Inter, "Golos Text", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --shadow-md: 0 10px 30px -8px rgba(16,24,40,.12);
  --nav: 58px;
  --head-h: 48px;           /* высота шапки: её же знает липкий поиск */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Скрытое — скрыто. Браузер прячет [hidden] слабым правилом display:none, и
   любой наш класс с display:flex его перебивает: так на экране входа висела
   пустая рамка «Приложение для Android», хотя файл не выложен */
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); color: var(--text); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(0,185,86,.055), transparent 60%),
    radial-gradient(700px 380px at -10% 30%, rgba(37,99,235,.04), transparent 55%),
    var(--bg);
  background-attachment: scroll; }
a { color: var(--link); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
.wrap { max-width: 760px; margin: 0 auto; background: var(--panel); min-height: 100%;
  padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 16px); }

/* ---------- шапка ---------- */
.head { position: sticky; top: 0; z-index: 5; background: var(--panel);
  padding-top: env(safe-area-inset-top); box-shadow: inset 0 -1px 0 var(--line); }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: var(--head-h); }
.top .ttl { flex: 1; text-align: center; font-size: 14px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; }
.top .side { min-width: 64px; display: flex; white-space: nowrap; }
.top .side.r { justify-content: flex-end; }
.ico { color: var(--link); background: none; border: 0; padding: 4px; cursor: pointer; font-size: 15px; }

/* Шапка с главными числами. В ФинРепорте это белая плитка с зелёным
   акцентом, а не цветная заливка: на солнце читается лучше */
.sky { background: var(--panel); color: var(--text);
  padding: 16px 16px 18px; padding-top: calc(14px + env(safe-area-inset-top));
  box-shadow: inset 0 -1px 0 var(--line); }
.sky .who { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.sky .name { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.03em; color: var(--em); }
.figs { display: flex; margin-top: 16px; gap: 8px; }
.figs > div { flex: 1; text-align: center; background: #EDF1F6; border: 1px solid #D7DDE7;
  border-radius: var(--radius-sm); padding: 10px 6px; }
.figs .label { font-size: 11px; color: var(--muted); }
.figs .value { font-size: 20px; font-weight: 700; margin-top: 2px; letter-spacing: -.02em; }

/* ---------- поиск ---------- */
.search { padding: 10px 16px; position: sticky; top: calc(var(--head-h) + env(safe-area-inset-top)); z-index: 4;
  background: var(--panel); box-shadow: inset 0 -1px 0 var(--line); }
.search input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); padding: 0 12px; outline: none; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.search input:focus { border-color: var(--em); box-shadow: 0 0 0 3px var(--em-soft); }

/* ---------- строки ---------- */
.group { font-size: 17px; font-weight: 600; padding: 18px 16px 6px; display: flex; align-items: baseline; gap: 8px;
  letter-spacing: -.01em; }
.group small { font-size: 13px; color: var(--muted); font-weight: 400; }
/* Разделитель между строками чуть темнее линии ФинРепорта: в цеху (влажное
   стекло, блики) и на солнце волосяная #EAEDF3 на белом пропадает, и соседние
   заказы сливаются в одно полотно */
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  box-shadow: inset 0 -1px 0 #DDE1E9; }
a.row, button.row { color: inherit; width: 100%; text-align: left; background: none; border: 0; cursor: pointer; }
a.row:active, button.row:active { background: var(--em-soft); }
.row .body { flex: 1; min-width: 0; }
.row .ttl { font-size: 15px; }
.row .sub { color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.row .val { font-weight: 600; white-space: nowrap; text-align: right; }
.row .val small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.chev { color: var(--muted); flex: none; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.off { opacity: .5; }

/* Значки состояния. Три разных сообщения, а не три оттенка:
     красный — «вмешайся», янтарный — «ждёт, но идёт», серый — просто пометка.
   Спокойные делаем мягкими (светлая заливка, тёмный текст — читаются и на
   солнце, и в печати), а красный оставляем громким: на доске цеха и на улице
   его должно выхватывать боковым зрением */
.pill { display: inline-block; border-radius: 999px; padding: 2.5px 9px; font-size: 11px; font-weight: 600;
  letter-spacing: .1px; color: #475467; background: var(--line); vertical-align: 1px; }
.pill.green { background: #D1FAE5; color: #065F46; }
.pill.grey { background: var(--line); color: #475467; }
.pill.amber { background: var(--gold-bg); color: var(--gold-ink); }
.pill.red { background: #D62B42; color: #fff; }
/* Значок на заливке своего цвета становится сплошным — иначе «🟠 дольше 2 суток 7»
   читается так, будто семёрка часть названия, а не счётчик дел */
.row.warn .pill.amber, details.alert.amber > summary .pill.amber { background: var(--amber); color: #fff; }
.row.calm .pill.green, .row.done .pill.grey { background: var(--panel); }

.kv { display: flex; gap: 12px; padding: 10px 16px; box-shadow: inset 0 -1px 0 var(--line); }
.kv .k { width: 120px; color: var(--muted); flex: none; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }

/* ---------- кнопки и формы ---------- */
/* Кнопки как в ФинРепорте — зелёный градиент и мягкая тень. Высота 44 остаётся:
   её держат мокрые руки мойщика и одна рука водителя, а не красота */
.btn { display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 18px; border-radius: var(--radius-sm); border: 0;
  background: linear-gradient(180deg, #0AC463, var(--em)); color: #fff;
  font-weight: 600; cursor: pointer; transition: transform 120ms var(--ease-out), box-shadow .15s;
  box-shadow: 0 1px 2px rgba(0,140,64,.3), inset 0 1px 0 rgba(255,255,255,.18); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(16,24,40,.04); }
/* Опасное действие не кричит: громким на экране должно быть то, что требует
   вмешательства, а не кнопка, по которой и так нажимают осознанно */
.btn.danger { background: #FEE2E2; color: #991B1B; box-shadow: inset 0 0 0 1.5px #FCA5A5; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; }
.link { background: none; border: 0; color: var(--link); padding: 0; cursor: pointer; }
.link.red { color: var(--red); }

.field { padding: 8px 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; background: #fff; font-size: 16px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--em);
  box-shadow: 0 0 0 3px var(--em-soft); }
.field textarea { min-height: 72px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); padding: 0 16px; }

/* ---------- лист снизу (форма поверх экрана) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex;
  align-items: flex-end; justify-content: center; animation: fade 180ms var(--ease-out); }
.sheet { background: var(--panel); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 8px 0 calc(16px + env(safe-area-inset-bottom));
  animation: up 260ms var(--ease-out); }
.sheet h3 { margin: 8px 16px 4px; font-size: 18px; }
.sheet .err { color: var(--red); padding: 4px 16px; font-size: 14px; }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(30px); opacity: 0 } }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 16px; } }

/* ---------- нижние вкладки ---------- */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px); box-shadow: 0 -1px 0 var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
nav.tabs .in { max-width: 760px; margin: 0 auto; display: flex; height: var(--nav); }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; color: var(--muted); }
nav.tabs a.on { color: var(--em); }
nav.tabs a .g { font-size: 20px; line-height: 1; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: #16181d; color: #fff; padding: 10px 16px; border-radius: 10px;
  z-index: 30; font-size: 14px; max-width: 90vw; animation: fade 180ms; }
.toast.err { background: var(--red); }

table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist td, table.hist th { padding: 8px 16px; text-align: left; box-shadow: inset 0 -1px 0 var(--line); }
table.hist th { font-size: 12px; color: var(--muted); font-weight: 500; }
table.hist td.n { text-align: right; white-space: nowrap; }

/* Переключатель периода в сводке: выбранное всюду зелёное — один цвет выбора */
.seg { display: flex; border-radius: var(--radius-sm); overflow: hidden; margin: 14px 0 0; border: 1px solid var(--line); }
.seg button { flex: 1; height: 38px; border: 0; font: inherit; font-size: 14px; cursor: pointer;
  background: var(--panel); color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--em); color: #fff; font-weight: 600; }

/* Фильтр по этапу в заказах водителя: лента фишек со счётчиками.
   Высота 44 — водитель жмёт одной рукой, часто на ходу и на холоде */
.myfilter { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 2px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.myfilter::-webkit-scrollbar { display: none; }
.fchip { flex: none; height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--panel); font: inherit; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; }
.fchip small { color: var(--muted); font-size: 13px; margin-left: 4px; }
.fchip.on { background: var(--em); border-color: var(--em); color: #fff; font-weight: 600; }
.fchip.on small { color: rgba(255,255,255,.8); }

/* Снимки места: пятна и повреждения */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.photos figure { margin: 0; }
.photos img { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; display: block; background: #eef0f3; }
.photos figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }

/* Карточка ФинРепорта: белое поле со скруглением и мягкой тенью.
   На телефоне применяем к «листам» и выделенным блокам */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 12px; }

/* Строки-состояния. Раньше цвет писали прямо в разметке шестнадцатеричным
   кодом, и перекраска до них не доходила. Теперь состояние — это класс */
.row.alarm { background: #FEF2F2; box-shadow: inset 3px 0 0 var(--red), inset 0 -1px 0 #DDE1E9; }
.row.warn { background: var(--gold-bg); box-shadow: inset 3px 0 0 var(--amber), inset 0 -1px 0 #DDE1E9; }
.row.calm { background: #ECFDF3; box-shadow: inset 3px 0 0 var(--em), inset 0 -1px 0 #DDE1E9; }
.row.done { background: var(--bg); box-shadow: inset 3px 0 0 var(--line), inset 0 -1px 0 #DDE1E9; }

/* Раскрывающийся блок тревоги: заголовок цветной, строки внутри белые */
details.alert > summary { padding: 12px 16px; cursor: pointer; font-weight: 600; list-style: none; }
details.alert > summary::-webkit-details-marker { display: none; }
details.alert.red > summary { background: #FEF2F2; box-shadow: inset 3px 0 0 var(--red); }
details.alert.amber > summary { background: var(--gold-bg); box-shadow: inset 3px 0 0 var(--amber); }
details.alert .row { background: var(--panel); }
details.alert .row.alarm, a.row.alarm:active { background: #FEF2F2; }
details.alert .row.warn, a.row.warn:active { background: var(--gold-bg); }
details.alert .row.calm, a.row.calm:active { background: #ECFDF3; }
details.alert .row.done, a.row.done:active { background: var(--bg); }
/* Отклик у цветной строки — потемнением, а не подменой цвета */
a.row.alarm:active, a.row.warn:active, a.row.calm:active, a.row.done:active { filter: brightness(.96); }
/* В кассе ссылка висит на внутреннем блоке строки, и нажатие не отзывалось
   ничем: оператор жал второй раз, не поняв, что первое нажатие прошло */
.row:has(> a.body:active) { background: var(--em-soft); }

/* Галочка в списках: главный элемент доски цеха и листов выдачи.
   Мокрый или замёрзший палец промахивается по 24 пикселям, поэтому 28
   с запасом по месту вокруг — это та же забота, что и высота кнопок 44 */
input.tick { width: 28px; height: 28px; accent-color: var(--em); margin: 2px; }
label.row:has(input.tick) { cursor: pointer; }
label.row:active { background: var(--em-soft); }
