/* Мини-приложение «Транспортный участок». Фирменные цвета бота, мобильный экран первым. */

:root {
  --bg: #FAF8F5;
  --card: #FFFFFF;
  --card-2: #F3F0EA;
  --text: #2B2A29;
  --muted: #6E6A63;
  --line: #E6E1D9;
  --accent: #77946D;
  --accent-ink: #FFFFFF;
  --accent-soft: #EDF2EB;
  --warn: #E89B2E;
  --warn-soft: #FBF0DC;
  --danger: #C4453A;
  --danger-soft: #F8E5E3;
  --radius: 14px;
  --tap: 48px;
  --shadow: 0 1px 2px rgba(43, 42, 41, .06), 0 6px 16px rgba(43, 42, 41, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1918;
    --card: #242322;
    --card-2: #2E2C2A;
    --text: #F2EFEA;
    --muted: #A29C93;
    --line: #38352F;
    --accent: #8FAE84;
    --accent-ink: #16211A;
    --accent-soft: #2B332A;
    --warn: #F0AC4B;
    --warn-soft: #3A2F1C;
    --danger: #E0655A;
    --danger-soft: #3B2320;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ---------- шапка ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar__in {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__who { min-width: 0; flex: 1; }
.topbar__role { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.topbar__name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__btn {
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

/* ---------- каркас ---------- */
.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px calc(84px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1 1 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.tabbar button.on { color: var(--accent); font-weight: 600; }
.tabbar .ico { font-size: 20px; line-height: 1; }

/* ---------- блоки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; }
.card__title { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.card__sub { font-size: 13px; color: var(--muted); margin: -6px 0 10px; }

.h2 { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.h2:first-child { margin-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.nowrap { white-space: nowrap; }

.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn + .btn { margin-top: 8px; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 38px; width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; }
.btn--link { background: none; border: 0; color: var(--accent); width: auto; min-height: 36px; padding: 0; font-weight: 600; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { margin-top: 0; }

/* ---------- поля ---------- */
.field { margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field__hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field__err { font-size: 13px; color: var(--danger); margin-top: 6px; }

.input, .textarea, .select {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input--big { font-size: 22px; font-weight: 700; letter-spacing: .02em; }

/* карточки-кнопки выбора */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.chip__sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.chips--stack { flex-direction: column; }
.chips--stack .chip { width: 100%; }

/* список с поиском */
.picker__list {
  margin-top: 8px;
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.picker__item {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.picker__item:last-child { border-bottom: 0; }
.picker__item.on { background: var(--accent-soft); font-weight: 700; }
.picker__chosen {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 12px;
  font-weight: 600;
}

/* ---------- плитки и таблицы ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.tile__v { font-size: 22px; font-weight: 700; line-height: 1.15; }
.tile__k { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile--warn { border-color: var(--warn); background: var(--warn-soft); }
.tile--danger { border-color: var(--danger); background: var(--danger-soft); }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.t th:first-child, table.t td:first-child { text-align: left; white-space: normal; min-width: 120px; }
table.t tr:last-child td { border-bottom: 0; }

/* бары */
.bar { margin-bottom: 10px; }
.bar__top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 4px; }
.bar__track { height: 10px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.bar__fill { height: 100%; background: var(--accent); border-radius: 6px; }

/* алерты */
.alert {
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 8px;
  font-size: 14px;
}
.alert--red { border-color: var(--danger); background: var(--danger-soft); }
.alert--orange { border-color: var(--warn); background: var(--warn-soft); }

/* строки списков */
.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 11px 12px;
  margin-bottom: 8px;
}
.item__t { font-weight: 600; }
.item__s { font-size: 13px; color: var(--muted); margin-top: 2px; }
/* строки плана красим так же, как алерты в отчёте */
.item--red { border-color: var(--danger); background: var(--danger-soft); }
.item--orange { border-color: var(--warn); background: var(--warn-soft); }
.item--off { opacity: .5; }

/* пояснение в карточке — например, что смена открыта на правку */
.note {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--card-2);
  color: var(--muted);
}
.badge--green { background: var(--accent-soft); color: var(--accent); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

/* аккордеон */
details.acc { border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 8px; overflow: hidden; }
details.acc > summary {
  min-height: var(--tap);
  display: flex; align-items: center;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
details.acc[open] > summary::after { content: "▴"; }
details.acc > .acc__body { padding: 0 12px 12px; border-top: 1px solid var(--line); padding-top: 12px; }

pre.text {
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--card-2);
  border-radius: 12px;
  padding: 12px;
  margin: 0;
  overflow-x: auto;
}

/* ---------- состояния ---------- */
.skel { background: var(--card-2); border-radius: 12px; height: 64px; margin-bottom: 10px; animation: pulse 1.3s ease-in-out infinite; }
.skel--tall { height: 120px; }
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.state { text-align: center; padding: 26px 14px; color: var(--muted); }
.state__t { font-weight: 700; color: var(--text); margin-bottom: 6px; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: 92vw;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast--err { background: var(--danger); color: #fff; }

.backlink { margin-bottom: 10px; }

/* ---------- фото чека ---------- */
.filehide { display: none; }

.shot { display: flex; gap: 12px; align-items: flex-start; }
.shot__img {
  flex: none;
  width: 92px; height: 92px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  overflow: hidden;
}
.shot__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot__side { flex: 1; min-width: 0; }
.shot__status { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.shot__status--ok { color: var(--accent); font-weight: 600; }
.shot .btn { width: auto; }
.shot .btn + .btn { margin-top: 0; }

.thumb {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); text-align: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb--wait { animation: pulse 1.3s ease-in-out infinite; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .88);
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* крупный код приглашения */
.code {
  font: 700 30px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
  text-align: center;
  padding: 14px 10px;
  border-radius: 12px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  user-select: all;
}
