/* Муравей — дизайн «вариант C» */
:root {
  --bg: #eef1ee;
  --card: #fff;
  --text: #111;
  --muted: #5f6b64;
  --line: #c9d2cc;
  --accent: #1f6f4a;
  --accent-text: #fff;
  --head: #144a33;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --ok-bg: #e5f4ea;
  --repair: #eceff1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16201a;
    --card: #1f2a23;
    --line: #35443b;
    --text: #e8efe9;
    --muted: #9aa9a0;
    --accent: #4fb784;
    --accent-text: #08130d;
    --head: #0d2f1f;
    --bad: #ff8a80;
    --bad-bg: #3a1d1b;
    --warn: #ffcc66;
    --warn-bg: #362b12;
    --ok-bg: #173022;
    --repair: #262b28;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
.hide, [hidden] { display: none !important; }

/* Шапка */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--head); color: #fff;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 10px;
}
.topline { display: flex; align-items: center; gap: 8px; min-height: 44px; }
h1#title {
  flex: 1; min-width: 0; margin: 0;
  font-size: 20px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.net { font-size: 12px; background: var(--bad); color: #fff; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.topbtn {
  height: 44px; padding: 0 16px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .15); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.topbtn:active { background: rgba(255, 255, 255, .25); }
.topnav {
  margin-top: 8px;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center;
  background: rgba(255, 255, 255, .12); border-radius: 8px;
}
.navbtn {
  width: 48px; height: 44px; border: 0; padding: 0;
  background: transparent; color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; touch-action: manipulation;
}
.navbtn:active { background: rgba(255, 255, 255, .15); border-radius: 8px; }
.navpick {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0; overflow: hidden; margin: 0; color: #fff; cursor: pointer;
}
.navpick span { font-size: 11px; opacity: .75; text-transform: uppercase; letter-spacing: .04em; line-height: 1.2; }
.navpick input {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 220px; min-height: 0;
  margin: 0 auto; border: 0; border-radius: 0; background: transparent; color: #fff;
  text-align: center; font-size: 17px; font-weight: 700;
  padding: 2px 0; height: 26px; line-height: 22px;
}
.navpick input::-webkit-date-and-time-value { text-align: center; }
.navpick input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .8; }
.navpick input:focus { outline: none; }

/* Плавающая кнопка «+ Отчёт» */
.fab {
  position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 25;
  height: 56px; padding: 0 22px; border: 0; border-radius: 28px;
  background: var(--accent); color: var(--accent-text);
  font-size: 18px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); cursor: pointer; touch-action: manipulation;
}
body.fab-on main#view { padding-bottom: 90px; }

/* Нижние вкладки */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1 1 0; min-width: 0; min-height: 56px; border: 0; background: none;
  color: var(--muted); padding: 8px 2px 6px; font-size: 11px; font-weight: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; touch-action: manipulation;
}
.tabs svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; box-sizing: content-box; padding: 2px 14px; border-radius: 14px;
}
.tabs button[data-tab="more"] svg { stroke-width: 3.2; }
.tabs button.on { color: var(--accent); font-weight: 600; }
.tabs button.on svg { background: var(--ok-bg); }

/* Уведомление */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(156px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 560px; margin: 0 auto;
  background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 10px; font-size: 15px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .2);
}

/* Основа */
main#view { padding: 12px; max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 12px 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1 1 0; min-width: 0; }
.row > .grow { flex: 1; min-width: 120px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 16px; font-weight: 600; text-decoration: none;
  touch-action: manipulation; cursor: pointer;
}
.btn.main { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
.btn.danger, button.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
button.link, .link {
  display: block; width: 100%; text-align: left; min-height: 48px;
  border: 0; background: none; color: var(--accent);
  padding: 8px 0; font-size: 16px; text-decoration: none; cursor: pointer;
}
button:disabled { opacity: .5; }

/* Поля */
input, select, textarea {
  font-size: 16px; min-height: 44px; width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text);
  padding: 8px 10px; font-family: inherit;
}
input[type="date"], input[type="month"] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; text-align: left;
}
input[type="checkbox"] {
  width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0;
  accent-color: var(--accent); flex: none;
}
select { -webkit-appearance: auto; appearance: auto; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
label > input, label > select, label > textarea { display: block; margin-top: 4px; }
.check {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; width: auto; max-width: 100%;
  font-size: 16px; color: var(--text); margin: 4px 0; cursor: pointer;
}
.check > input[type="checkbox"] { display: inline-block; margin: 0; }
textarea { min-height: 220px; font-family: ui-monospace, Consolas, monospace; line-height: 1.5; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 359px) { .grid2 { grid-template-columns: 1fr; } }

/* Переключатель Текст/Форма */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: var(--card); color: var(--text);
  padding: 8px 14px; min-height: 40px; font-size: 16px; cursor: pointer;
}
.seg button.on { background: var(--accent); color: var(--accent-text); }

/* Сообщения */
.msg { border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.msg.bad { background: var(--bad-bg); color: var(--bad); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.ok { background: var(--ok-bg); color: var(--text); }
.msg ul { margin: 4px 0 0; padding-left: 18px; }

.muted { color: var(--muted); font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big { font-size: 22px; font-weight: 600; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Таблицы */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }

pre.copy {
  white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; margin: 6px 0; font-size: 14px;
}

/* Машины */
.car { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: var(--card); }
.car.off { opacity: .6; }
.car .head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 8px; font-weight: 600; font-size: 17px;
}
.pill {
  font-size: 13px; font-weight: 600; background: var(--ok-bg); color: var(--text);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; margin: 0 0 8px; }
.kv span { background: var(--bg); border-radius: 8px; padding: 6px 8px; font-size: 12px; color: var(--muted); }
.kv b { display: block; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }

/* Люди */
.person {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.person .who { min-width: 0; }
.person .who > div:first-child { font-weight: 500; }
.person b { font-size: 19px; font-weight: 800; white-space: nowrap; }

/* Итоги */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 4px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }

/* График */
.sched { width: 100%; border-collapse: collapse; }
.sched td, .sched th { text-align: center; padding: 6px; font-size: 13px; min-width: 64px; height: 48px; }
.sched td:first-child, .sched th:first-child {
  text-align: left; position: sticky; left: 0; background: var(--card); min-width: 80px; z-index: 1;
}
.sched td.cell { cursor: pointer; }
.sched td.bad { background: var(--bad-bg); color: var(--bad); }
.sched td.warn { background: var(--warn-bg); color: var(--warn); }
.sched td.repair { background: var(--repair); color: var(--muted); }
.sched td.offday { background: var(--warn-bg); color: var(--warn); }

/* Окна */
dialog {
  width: min(560px, calc(100vw - 16px)); max-width: none;
  padding: 0; border: 0; border-radius: 12px;
  background: var(--card); color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
dialog form > h2 { margin: 0; padding: 14px 16px; font-size: 18px; border-bottom: 1px solid var(--line); flex: none; }
dialog form > h2:focus { outline: none; }
.dlg-body {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 12px 16px;
}
.dlg-foot {
  flex: none; display: flex; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--card);
}
.dlg-foot .btn { flex: 1 1 0; min-height: 50px; }

.login { max-width: 360px; margin: 40px auto; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
