/* Журнал персонала Overpack — Mini App.
   Цвета берём из темы Telegram, а в браузере подставляем свои: приложение
   обязано открываться и по прямой ссылке (раздел 2 ТЗ). */

:root {
  --bg:        var(--tg-theme-bg-color, #ffffff);
  --bg-2:      var(--tg-theme-secondary-bg-color, #f2f3f5);
  --fg:        var(--tg-theme-text-color, #16191d);
  --muted:     var(--tg-theme-hint-color, #74808d);
  --link:      var(--tg-theme-link-color, #2f7ee6);
  --btn:       var(--tg-theme-button-color, #2f7ee6);
  --btn-fg:    var(--tg-theme-button-text-color, #ffffff);
  --line:      color-mix(in srgb, var(--muted) 26%, transparent);

  --green:  #2ea36b;
  --yellow: #d9a21b;
  --red:    #d94f4f;
  --grey:   #9aa4b0;

  --r: 12px;
  --pad: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:   var(--tg-theme-bg-color, #17181c);
    --bg-2: var(--tg-theme-secondary-bg-color, #212228);
    --fg:   var(--tg-theme-text-color, #eceff3);
    --muted:var(--tg-theme-hint-color, #8b95a2);
  }
}

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

body {
  margin: 0;
  padding: 0 0 76px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 8px; }
a  { color: var(--link); text-decoration: none; }

.wrap { padding: var(--pad); max-width: 720px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap-it { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* ── Карточки ───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border-radius: var(--r);
  padding: var(--pad);
}
.card + .card { margin-top: 10px; }
.card.tap { cursor: pointer; }
.card.tap:active { opacity: .7; }

/* ── Светофор ───────────────────────────────────────────────────────────── */
.venue {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 12px;
  align-items: center;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }
.dot.grey { background: var(--grey); }

.bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--red) 55%, transparent); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--green); }

.nums { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Лента ──────────────────────────────────────────────────────────────── */
.entry { padding: 11px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .head { display: flex; gap: 8px; align-items: baseline; }
.entry .who { font-weight: 600; }
.entry .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.entry .det { margin-top: 4px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; line-height: 1.5; background: color-mix(in srgb, var(--muted) 18%, transparent);
}
.tag.fine { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red); font-weight: 600; }
.tag.ok   { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.tag.warn { background: color-mix(in srgb, var(--yellow) 24%, transparent); color: var(--yellow); }

/* ── Кнопки и поля ──────────────────────────────────────────────────────── */
button, .btn {
  font: inherit; border: 0; border-radius: 10px; padding: 11px 14px;
  background: var(--btn); color: var(--btn-fg); cursor: pointer;
}
button:active { opacity: .8; }
button[disabled] { opacity: .45; cursor: default; }
.btn-ghost { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--fg); }
.btn-wide { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 12px; border-radius: 999px; font-size: 14px;
  background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--fg);
}
.chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-fg); }

input, select, textarea {
  font: inherit; width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
textarea { min-height: 76px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; }
.field + .field { margin-top: 12px; }

/* ── Нижняя навигация ───────────────────────────────────────────────────── */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
nav.tabs button {
  background: none; color: var(--muted); border-radius: 0;
  padding: 9px 4px 10px; font-size: 11px; display: grid; gap: 3px; justify-items: center;
}
nav.tabs button b { font-size: 18px; font-weight: 400; line-height: 1; }
nav.tabs button[aria-current="page"] { color: var(--link); }

/* ── Прочее ─────────────────────────────────────────────────────────────── */
.ladder { display: grid; gap: 8px; }
.ladder .li { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
              padding: 9px 11px; border-radius: 10px; background: color-mix(in srgb, var(--muted) 12%, transparent); }
.step-pills { display: flex; gap: 4px; }
.step-pills i { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--muted) 40%, transparent); }
.step-pills i.on { background: var(--red); }

.avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: color-mix(in srgb, var(--muted) 20%, transparent); }
.avatar.ph { display: grid; place-items: center; font-size: 21px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 50; max-width: 90vw; box-shadow: 0 8px 26px rgba(0,0,0,.25);
}

.sheet {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  overflow-y: auto; padding-bottom: 24px;
}
.sheet header {
  position: sticky; top: 0; background: var(--bg); z-index: 2;
  padding: 12px var(--pad); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}

.list-item {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }

.preview { border-left: 3px solid var(--btn); padding: 10px 12px; border-radius: 0 10px 10px 0;
           background: color-mix(in srgb, var(--btn) 10%, transparent); }
.preview.fine { border-left-color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }

.center-screen { min-height: 78vh; display: grid; place-items: center; padding: var(--pad); }
