:root {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #1c2530;
  --muted: #6b7785;
  --line: #dfe4ea;
  --primary: #2563eb;
  --primary-ink: #fff;
  --danger: #dc2626;
  --ok-bg: #e7f6ec; --ok-ink: #1a7a3c;
  --err-bg: #fdecec; --err-ink: #b42318;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}

/* ---------- generic ---------- */
.muted { color: var(--muted); }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.btn {
  display: inline-block; padding: 9px 14px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer;
  text-decoration: none; font-size: 14px; line-height: 1;
}
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); border-color: #f0c2c2; }
.btn.small { padding: 6px 9px; font-size: 13px; }

.alert { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.error { background: var(--err-bg); color: var(--err-ink); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; margin: 16px 0;
}
.card h1, .card h2 { margin: 0 0 6px; }

/* ---------- login / error ---------- */
.center-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login { width: 320px; max-width: 100%; }
.login h1 { margin-bottom: 0; }
label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--ink);
  background: #fff;
}
.login .btn { width: 100%; margin-top: 6px; text-align: center; }

/* ---------- admin chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.topbar nav a { margin-left: 14px; color: var(--primary); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { text-decoration: underline; }
.container { max-width: 1000px; margin: 0 auto; padding: 0 16px 40px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { text-align: center; }
.stat-num { font-size: 34px; font-weight: 700; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.form-grid .btn { height: fit-content; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
tr.expired { background: #fff6f6; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
table input[type=text], table select { padding: 6px 7px; font-size: 13px; min-width: 70px; }

/* ---------- map ---------- */
#map { position: absolute; inset: 0; }

.filter-toggle {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  box-shadow: 0 1px 6px rgba(0,0,0,.2);
}
.filter-panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw;
  background: #fff; z-index: 20; box-shadow: 2px 0 12px rgba(0,0,0,.15);
  transform: translateX(-105%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.filter-panel.open { transform: translateX(0); }
.filter-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.filter-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.filter-footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.chk { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--ink); font-size: 15px; }
.chk input { width: auto; margin: 0; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }

/* popup */
.maplibregl-popup-content { font-family: inherit; border-radius: 10px; padding: 12px 14px; }
.popup-title { font-weight: 700; margin-bottom: 8px; font-size: 15px; }
.fuel-row { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; border-top: 1px solid var(--line); }
.fuel-row:first-of-type { border-top: none; }
.fuel-name { font-weight: 600; }
.fuel-price { white-space: nowrap; }
.fuel-disp { color: var(--muted); font-size: 12px; }

/* desktop: panel always visible, map shifted */
@media (min-width: 800px) {
  .filter-toggle, .icon-btn { display: none; }
  .filter-panel { transform: translateX(0); }
  #map { left: 280px; }
}
