:root {
  --green: #6cb33f;
  --green-dark: #4c8a2a;
  --orange: #f26522;
  --bg: #f2f5ef;
  --card: #ffffff;
  --text: #1e2b17;
  --muted: #7a8574;
  --border: #e3e8dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12180f;
    --card: #1d2418;
    --text: #eef3e8;
    --muted: #9aa892;
    --border: #2c3626;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-top: 64px;
  padding-bottom: 64px;
  -webkit-tap-highlight-color: transparent;
}

/* верхняя панель */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  height: 64px; display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.logo {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.22); display: flex;
  align-items: center; justify-content: center; font-size: 22px;
}
.title { font-weight: 700; font-size: 16px; }
.subtitle { font-size: 12px; opacity: .85; }

/* контент */
main { padding: 12px; max-width: 640px; margin: 0 auto; }
.tab.hidden, .hidden { display: none !important; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-title { font-weight: 700; margin-bottom: 8px; font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; margin-top: 6px; }

/* баланс */
.balance-card {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: #fff; border: none;
}
.balance-card.low { background: linear-gradient(135deg, #b3401e, var(--orange)); }
.balance-label { font-size: 13px; opacity: .9; }
.balance-value { font-size: 32px; font-weight: 800; margin: 4px 0 8px; }
.balance-rows { font-size: 13px; line-height: 1.6; }
.balance-rows b { font-weight: 700; }

/* итоги сводки */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.total-box {
  background: var(--bg); border-radius: 10px; padding: 8px 10px;
  font-size: 12px; color: var(--muted);
}
.total-box b { display: block; font-size: 17px; color: var(--text); margin-top: 2px; }

.fuel-line { font-size: 13px; line-height: 1.7; }
.fuel-line b { font-weight: 700; }
.fuel-block { margin-bottom: 8px; }
.fuel-block .cap { font-weight: 700; font-size: 13px; margin-bottom: 2px; }

.topfuel { font-size: 13px; line-height: 1.8; }

/* сегменты периодов */
.segmented, .dimtabs {
  display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.segmented button, .dimtab {
  flex: 1; min-width: 60px; padding: 8px 6px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 10px; font-size: 13px; cursor: pointer;
}
.segmented button.active, .dimtab.active {
  background: var(--green); border-color: var(--green); color: #fff; font-weight: 600;
}
.subtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.subtab {
  flex: 1; padding: 10px; border-radius: 12px; font-size: 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.subtab.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }

/* списки срезов */
.rows .row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
  font-size: 14px; cursor: pointer;
}
.rows .row:last-child { border-bottom: none; }
.row .r-label { flex: 1; }
.row .r-sub { display: block; font-size: 12px; color: var(--muted); }
.row .r-val { white-space: nowrap; font-weight: 700; color: var(--green-dark); }
@media (prefers-color-scheme: dark) { .row .r-val { color: #8fd05e; } }
.row .r-ops { color: var(--muted); font-weight: 400; font-size: 12px; }

/* формы */
.input {
  width: 100%; padding: 11px 12px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); color: var(--text); font-size: 14px;
}
.btn-primary {
  width: 100%; padding: 13px; margin: 10px 0;
  background: var(--orange); color: #fff; border: none;
  border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
}

/* карта */
#map {
  height: 62vh; min-height: 380px; border-radius: 14px;
  border: 1px solid var(--border); z-index: 1;
}
.azs-pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: var(--green); border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.azs-pin span { transform: rotate(45deg); font-size: 15px; }
.leaflet-popup-content { font-size: 13px; }

/* таблица цен */
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th, .ptable td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--border); }
.ptable th:first-child, .ptable td:first-child { text-align: left; }
.ptable th { color: var(--muted); font-weight: 600; font-size: 12px; }
.ptable td.vat { font-weight: 700; }

/* нижняя навигация */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
}
.navbtn {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 11px; cursor: pointer; padding: 4px 0;
}
.navbtn .ic { display: block; font-size: 20px; margin-bottom: 2px; }
.navbtn.active { color: var(--green); font-weight: 700; }

/* карточка карты */
.kv { font-size: 13px; line-height: 1.7; }
.kv b { font-weight: 700; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600; margin-right: 4px;
}
.chip.ok { background: #e4f2d8; color: var(--green-dark); }
.chip.bad { background: #fde3d8; color: #b3401e; }
@media (prefers-color-scheme: dark) {
  .chip.ok { background: #24371b; color: #9fd96f; }
  .chip.bad { background: #3d1f14; color: #ff9d78; }
}

/* тост */
.toast {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 9px 16px;
  border-radius: 20px; font-size: 13px; z-index: 900;
}
