:root {
  --bg: #eef3f1;
  --panel: #ffffff;
  --line: #d6e0dd;
  --text: #14231f;
  --muted: #60706b;
  --accent: #1f7a5c;
  --accent-dark: #155840;
  --danger: #ba3f3f;
  --shadow: 0 14px 34px rgba(18, 35, 31, .12);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 16px;
  background: #10231d;
  color: #fff;
}
.topbar strong { display: block; font-size: 17px; }
.topbar span { color: #bdd2ca; font-size: 12px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 6px; }
.topbar a, button.link {
  color: #eaf3ef;
  text-decoration: none;
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  padding: 9px 10px;
}
button.link { border: 0; cursor: pointer; }
main {
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px;
}
h1 { margin: 0 0 6px; font-size: 25px; }
h2 { margin: 0 0 10px; font-size: 17px; }
p { margin: 0 0 12px; color: var(--muted); }
.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #b8dccd;
  background: #e3f2eb;
  border-radius: 7px;
}
.panel, .status-card, .app-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.auth {
  max-width: 440px;
  margin: 42px auto;
  padding: 18px;
}
form, .stack, .profile-form { display: grid; gap: 12px; }
label {
  display: grid;
  gap: 5px;
  color: #364944;
  font-size: 13px;
}
input, select, button {
  font: inherit;
}
input, select {
  width: 100%;
  min-height: 43px;
  border: 1px solid #c7d3d0;
  border-radius: 5px;
  padding: 9px 10px;
  background: #fff;
}
button {
  min-height: 43px;
  border: 0;
  border-radius: 5px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
a { color: var(--accent-dark); }
.page-title { margin: 8px 0 16px; }
.app-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.app-card {
  display: grid;
  gap: 8px;
  min-height: 165px;
  padding: 18px;
  text-decoration: none;
  color: var(--text);
}
.app-card span {
  color: var(--muted);
  font-size: 13px;
}
.app-card strong {
  font-size: 24px;
}
.app-card:hover {
  border-color: #94bdae;
  box-shadow: var(--shadow);
}
.profile-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
}
.profile-form button { align-self: end; }
.map-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  min-height: calc(100vh - 92px);
}
.map-panel {
  position: relative;
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #d9e4df;
}
#map { position: absolute; inset: 0; }
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}
.leaflet-container {
  overflow: hidden;
  touch-action: pan-x pan-y;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}
.leaflet-tile {
  filter: inherit;
  visibility: hidden;
}
.leaflet-tile-loaded {
  visibility: inherit;
}
.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control {
  position: relative;
  z-index: 1000;
  pointer-events: auto;
  float: left;
  clear: both;
}
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; float: right; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  background: #fff;
  color: #10231d;
  border-bottom: 1px solid #cbd8d4;
  font-size: 20px;
  font-weight: 700;
}
.leaflet-control-zoom a:last-child { border-bottom: 0; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.82);
  padding: 2px 6px;
  font-size: 11px;
}
.leaflet-container {
  width: 100% !important;
  height: 100% !important;
  background: #d9e4df;
}
.leaflet-container img,
.leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}
.leaflet-control-layers {
  border: 0 !important;
  border-radius: 6px !important;
  box-shadow: var(--shadow) !important;
  font-size: 14px;
}
.leaflet-control-layers-expanded {
  padding: 8px 10px !important;
}
.leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 14px;
  color: var(--text);
}
.locate-btn, .fire-btn {
  position: absolute;
  z-index: 700;
  right: 12px;
  width: auto;
  min-height: 39px;
  box-shadow: var(--shadow);
}
.locate-btn { top: 12px; }
.fire-btn { top: 60px; background: var(--danger); }
.info-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}
.status-card {
  padding: 14px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.metric-grid div, .weather-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fbfa;
}
.metric-grid span, .weather-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.metric-grid strong {
  display: block;
  min-height: 21px;
  overflow-wrap: anywhere;
}
.weather-list {
  display: grid;
  gap: 8px;
}
.weather-item strong {
  display: block;
  margin-bottom: 6px;
}
.weather-line {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  font-size: 13px;
}
.localities {
  display: grid;
  gap: 7px;
  line-height: 1.45;
  color: var(--text);
  overflow-wrap: anywhere;
}
.localities div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.localities div:last-child { border-bottom: 0; padding-bottom: 0; }
.localities span { color: var(--muted); white-space: nowrap; }
.localities .municipality-row {
  border: 1px solid #b8dccd;
  border-radius: 6px;
  background: #e7f4ee;
  padding: 9px 10px;
}
.localities .municipality-row span {
  color: var(--accent-dark);
  font-weight: 700;
}
.leaflet-tooltip.distance-label {
  border: 0;
  background: #10231d;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
@media (max-width: 980px) {
  .map-shell { grid-template-columns: 1fr; }
  .map-panel { min-height: 58vh; }
  .info-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-card:first-child { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  main { padding: 10px; }
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .topbar nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar a, button.link { text-align: center; }
  h1 { font-size: 22px; }
  .app-grid, .profile-form, .info-panel { grid-template-columns: 1fr; }
  .auth { margin: 18px auto; padding: 14px; }
  .map-shell { min-height: 0; gap: 10px; }
  .map-panel {
    min-height: 56vh;
    border-radius: 0;
    margin: -10px -10px 0;
    border-left: 0;
    border-right: 0;
  }
  .status-card { padding: 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .weather-line { grid-template-columns: 1fr; }
  .locate-btn, .fire-btn { right: 10px; }
}
