:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dce2ea;
  --text: #16202e;
  --muted: #5a6778;
  --primary: #145374;
  --primary-hover: #0d3d56;
  --accent: #0f766e;
  --ok-bg: #e6f6ee;
  --ok-text: #146c43;
  --warn-bg: #fff5df;
  --warn-text: #945d00;
  --err-bg: #fdeaea;
  --err-text: #a61b1b;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #0f293a;
  color: #fff;
  border-bottom: 3px solid #1e6f9f;
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.7rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38bdf8;
  display: inline-block;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.nav-links a {
  color: #d7e7f4;
  padding: 0.38rem 0.72rem;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
}
.user-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.user-pill {
  font-size: 0.85rem;
  color: #e2edf6;
}
.inline-form { display: inline; margin: 0; }

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.25rem;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.page-head h1 { margin: 0 0 0.2rem 0; font-size: 1.5rem; }
.muted { color: var(--muted); margin: 0; font-size: 0.92rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  margin-bottom: 1rem;
}
.card h2 { margin-top: 0; font-size: 1.12rem; }

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.kpi-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 1.55rem; font-weight: 700; margin-top: 0.2rem; color: var(--primary); }
.kpi-sub { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
}
.grid-map {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}
@media (max-width: 960px) {
  .grid-map { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 0.28rem; min-width: 150px; }
.field label { font-size: 0.84rem; font-weight: 600; color: var(--text); }
.field input, .field select, .field textarea {
  padding: 0.45rem 0.6rem;
  border: 1px solid #c5cfdc;
  border-radius: 6px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.48rem 0.9rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: #edf2f7; color: var(--text); border-color: #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; text-decoration: none; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.btn-sm { padding: 0.3rem 0.62rem; font-size: 0.82rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th, td { padding: 0.52rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #f8fafc; font-weight: 600; color: #334155; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #f9fbfd; }

.badge {
  display: inline-block;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #e9eff6;
  color: #243b53;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-err { background: var(--err-bg); color: var(--err-text); }

.alert {
  padding: 0.68rem 0.9rem;
  border-radius: 7px;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.alert-info { background: #e8f3fb; color: #104a73; border-color: #bfdcf2; }
.alert-success { background: var(--ok-bg); color: var(--ok-text); border-color: #b7e4c7; }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); border-color: #f3d796; }
.alert-error { background: var(--err-bg); color: var(--err-text); border-color: #f5bcbc; }

.auth-wrapper { display: flex; justify-content: center; padding: 2.5rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }

.leaflet-box { width: 100%; height: 540px; border-radius: 8px; border: 1px solid var(--border); }
.leaflet-box-sm { width: 100%; height: 340px; border-radius: 8px; border: 1px solid var(--border); }
.legend { display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 0.8rem; margin-top: 0.5rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
