:root {
  --bg: #0e0f17;
  --card: #171826;
  --bd: #232433;
  --txt: #e9e9f2;
  --dim: #8a8aa0;
  --mut: #62627a;
  --accent: #7b9cff;
  --teal: #86d8e0;
  --tab: #12121b;
  --tabtxt: #6b6b82;
  --err: #e87e8a;
  --ok: #88e2a6;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
}
body { padding-bottom: 70px; }

#view {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px;
}

/* ---- Tab bar ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--tab);
  border-top: 1px solid var(--bd);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 7px 2px;
  font-size: 10.5px;
  font-family: inherit;
  color: var(--tabtxt);
  background: none;
  border: none;
  cursor: pointer;
}
.tab.on { color: var(--accent); }
.tab .e { font-size: 18px; display: block; line-height: 1; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 11px;
}
.row {
  display: flex;
  align-items: center;
  gap: 11px;
}
.card.row { display: flex; align-items: center; gap: 11px; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #232440;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}

/* ---- Segmented control ---- */
.seg {
  display: flex;
  gap: 4px;
  background: #101019;
  border: 1px solid var(--bd);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 14px;
}
.seg button {
  flex: 1;
  min-height: 38px;
  padding: 8px 6px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.seg .on { background: var(--card); color: var(--txt); }

/* ---- Fuel-level segmented control (vehicle act) ---- */
.fuel-seg { display: flex; gap: 6px; }
.fuel-seg .fuel-btn {
  flex: 1;
  min-width: 0;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--card);
  color: var(--dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
/* selected state — the old .pill had no .on rule at all, so nothing showed */
.fuel-seg .fuel-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #0e0f17;
  font-weight: 700;
}

/* ---- Typography ---- */
.h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.sub { color: var(--dim); font-size: 13px; margin-bottom: 16px; }
.meta { font-size: 12px; color: var(--dim); }

/* ---- States ---- */
.skel, .empty, .err, .loading {
  text-align: center;
  color: var(--dim);
  font-size: 14px;
  padding: 40px 12px;
}
.err { color: var(--err); }
.skel { color: var(--mut); }

/* ---- Buttons ---- */
.mainbtn {
  width: 100%;
  min-height: 48px;
  background: var(--accent);
  color: #0a0a14;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
}
.mainbtn:active { filter: brightness(0.94); }

.btn {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--bd);
  border-radius: 11px;
  background: var(--card);
  color: var(--txt);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { filter: brightness(0.94); }
.btn.ok { background: #1f3a2a; border-color: #2c5640; color: var(--ok); }
.btn.no { background: #3a1f24; border-color: #563038; color: var(--err); }
.btn.ghost { background: transparent; color: var(--accent); border-color: #3a3b4d; }

/* ---- Fields ---- */
.field { margin-bottom: 12px; }
label {
  display: block;
  color: var(--dim);
  font-size: 13px;
  margin-bottom: 6px;
}
.inp {
  width: 100%;
  min-height: 44px;
  background: #101019;
  border: 1px solid var(--bd);
  border-radius: 9px;
  color: var(--txt);
  font: inherit;
  font-size: 15px;
  padding: 11px;
}
.inp:focus { outline: none; border-color: var(--accent); }
textarea.inp { resize: vertical; min-height: 88px; }

/* ---- Tags ---- */
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.tag.green { background: #1f3a2a; color: var(--ok); }
.tag.amber { background: #3a3320; color: #e3c178; }
.tag.purple { background: #2a2440; color: #b7a6ff; }
.tag.teal { background: #1c3a40; color: var(--teal); }

/* ---- Home hub grid + tiles ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  margin-top: 16px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 104px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  color: var(--txt);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tile:active { filter: brightness(0.94); }
.tile.loading { opacity: 0.5; }
.tile-e { font-size: 22px; line-height: 1; }
.tile-n { font-size: 30px; font-weight: 700; line-height: 1.05; margin-top: auto; }
.tile-l { font-size: 13px; color: var(--dim); }

/* ---- Unread notification dot ---- */
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
}

/* ---- Back link ---- */
.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 8px;
  cursor: pointer;
}

/* ── Standalone web / PWA chrome (rendered only when NOT inside Telegram) ──
   Mirrors the Telegram MainButton (bottom CTA) and BackButton (top-left). */
#webMain {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: none;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--bd);
}
#webMainBtn {
  width: 100%; height: 50px; border: none; border-radius: 14px;
  background: var(--accent); color: #0e0f17;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
body.has-webmain #webMain { display: block; }
/* lift the tabbar above the action bar; pad content so neither overlaps it */
body.web-shell.has-webmain #tabbar { bottom: 72px; }
body.web-shell.has-webmain #view { padding-bottom: 152px; }

#webBack {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 10px;
  z-index: 60; display: none;
  background: rgba(23,24,38,.92); color: var(--accent);
  border: 1px solid var(--bd); border-radius: 10px;
  padding: 7px 13px; font-size: 14px; font-weight: 600; cursor: pointer;
}
body.has-webback #webBack { display: block; }
body.web-shell.has-webback #view { padding-top: 46px; }

/* ── Web/PWA login screen ── */
body.login-mode #tabbar, body.login-mode #webMain, body.login-mode #webBack { display: none !important; }
.login-wrap { min-height: 78vh; display: flex; align-items: center; justify-content: center; padding: 16px 0; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid var(--bd); border-radius: 18px;
  padding: 26px 20px;
}
.login-brand { font-size: 22px; font-weight: 800; letter-spacing: .01em; }
.login-sub { color: var(--dim); font-size: 13px; margin-top: 3px; }
.login-err { color: var(--err); font-size: 13px; min-height: 18px; margin: 4px 2px 2px; }
