:root {
  --bg: #f3f5f8; --card: #fff; --text: #1b2430; --muted: #5d6b7c; --line: #dfe4ea;
  --accent: #1f5fa8; --accent-ink: #fff; --ok: #1d8a4a; --warn: #b7791f; --bad: #c0392b;
  --ok-bg: #e5f5ec; --warn-bg: #fdf4e3; --bad-bg: #fbe8e6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --card: #1a2129; --text: #e6ebf1; --muted: #9aa8b8; --line: #2b3541;
    --accent: #4d8fe0; --ok: #3cc178; --warn: #e3a948; --bad: #ef6b5c;
    --ok-bg: #16301f; --warn-bg: #33280f; --bad-bg: #3a1814; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: max(8px, env(safe-area-inset-top)) 16px 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
main { max-width: 860px; margin: 0 auto; padding: 12px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); margin-top: 10px; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-align: center; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { padding: 16px; font-size: 18px; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.btn.back { margin-right: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.row.tight { margin-top: 0; align-items: flex-end; }
.grow { flex: 1 1 140px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0; }
h3 { margin: 4px 0 10px; font-size: 16px; }
a { color: var(--accent); }
.inline { display: flex; gap: 6px; } .inline input { flex: 1; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; margin: 4px 0; }
.err:empty { display: none; }
.err.ok { color: var(--ok); }
.who { margin-left: auto; font-weight: 500; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

/* вход, парола, уведомление */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.gate-card h2 { margin: 0; font-size: 20px; }
.gate-card p { margin: 0; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 6px; }
ul.plain { margin: 0; padding-left: 20px; }

/* начало */
.hello { margin: 4px 0 14px; color: var(--muted); }
.home { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (min-width: 640px) { .home { grid-template-columns: repeat(4, 1fr); } }
.home.small { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; font: inherit; font-size: 19px; font-weight: 700; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px; cursor: pointer; text-align: left; text-decoration: none; min-height: 110px; }
.tile span { font-size: 30px; line-height: 1; }
.tile small { position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 1px 7px; }
.tile.soon { opacity: .55; cursor: default; }
.home.small .tile { flex-direction: row; align-items: center; font-size: 16px; padding: 14px; min-height: 0; } .home.small .tile span { font-size: 22px; }

/* акаунти */
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th, .users td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.users tr.off td { opacity: .6; }
.users .m { color: var(--muted); font-size: 13px; }

/* активност */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; margin-bottom: 12px; }
.person { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.person.on { border-left-color: var(--ok); }
.person.sel { outline: 2px solid var(--accent); }
.person.off { opacity: .55; }
.person b { font-size: 16px; }
.person .m { color: var(--muted); font-size: 13px; margin-top: 2px; }
.person .nums { display: flex; gap: 12px; margin-top: 6px; font-size: 14px; }
.person .nums .bad { color: var(--bad); font-weight: 600; }
.week { display: flex; gap: 3px; margin-top: 8px; }
.week i { flex: 1; height: 8px; border-radius: 3px; background: var(--line); }
.week i.y { background: var(--ok); }
.week-l { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }
.timeline .ev { display: grid; grid-template-columns: 50px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .t { font-variant-numeric: tabular-nums; color: var(--muted); }
.timeline .d { color: var(--muted); font-size: 12px; }
.timeline .ev.fail { color: var(--bad); }
.timeline .ev.login b { color: var(--ok); }
.timeline .empty { color: var(--muted); padding: 8px 0; }

/* гориво */
.row.tight + .row.tight { margin-top: 10px; }
label .m { color: var(--muted); font-size: 12px; min-height: 1em; }
label .m.warn { color: var(--warn); font-weight: 600; }
.photo-pick { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.photo-pick label.btn { flex-direction: row; color: var(--text); font-size: 16px; }
.photo-pick img { max-height: 90px; max-width: 120px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.fuel-month { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0 4px; border-bottom: 2px solid var(--line); }
.fuel-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.fuel-row .m { color: var(--muted); font-size: 13px; }
.fuel-row .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acts { display: flex; gap: 6px; white-space: nowrap; }
.empty { color: var(--muted); padding: 8px 0; }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; margin-bottom: 12px; }
.tot { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tot small { display: block; color: var(--muted); font-size: 13px; }
.tot b { font-size: 20px; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.users.num td, .users.num th { white-space: nowrap; }
.users.num td:nth-child(n+2) { font-variant-numeric: tabular-nums; }
.viewer { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; color: #fff; }
.viewer img { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 6px; }
