:root {
  color-scheme: light;
  --panel: #ffffff;
  --text: #18211f;
  --muted: #62706b;
  --line: #cdd9d3;
  --accent: #157f5b;
  --accent-dark: #0f6246;
  --danger: #b93131;
  --map-bg: #d8e5dc;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--map-bg);
}

button,
input,
.button {
  font: inherit;
  letter-spacing: 0;
}

.tracker {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 500;
}

.field {
  display: grid;
  gap: 4px;
}

.check-field {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #f8fbf9;
  font-size: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

.check-field input {
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
}

.check-field span {
  white-space: nowrap;
}

input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  min-width: 210px;
}

button {
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

button[data-active="true"] {
  background: var(--danger);
  border-color: var(--danger);
}

.logout {
  margin-left: auto;
  background: #3f5750;
  border-color: #3f5750;
}

.login-page {
  min-height: 100%;
  overflow: auto;
  background:
    linear-gradient(135deg, rgba(21, 127, 91, 0.12), rgba(37, 82, 117, 0.16)),
    var(--map-bg);
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 380px);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(24, 33, 31, 0.14);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-field {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
}

.login-field input {
  width: 100%;
  min-width: 0;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(185, 49, 49, 0.35);
  border-radius: 6px;
  color: var(--danger);
  background: rgba(185, 49, 49, 0.08);
}

#map {
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/*
 * Critical Leaflet layout fallback.
 * The full Leaflet stylesheet is loaded from the CDN, but without these rules
 * map tiles render as normal document-flow images on hosts that block it.
 */
.leaflet-container {
  position: relative;
  overflow: hidden;
  background: var(--map-bg);
  outline-offset: 1px;
}

.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-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-pane > svg,
.leaflet-pane > canvas {
  pointer-events: none;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  border: 0;
}

.leaflet-tile-container,
.leaflet-zoom-animated {
  transform-origin: 0 0;
}

.leaflet-tile-pane {
  inset: 0;
}

.leaflet-map-pane {
  inset: 0;
}

.leaflet-pane > svg {
  width: 100%;
  height: 100%;
}

.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
.leaflet-marker-pane,
.leaflet-tooltip-pane,
.leaflet-popup-pane {
  z-index: 1;
}

.leaflet-control-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 800;
}

.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: 26px;
  height: 26px;
  line-height: 26px;
  color: #000000;
  background: #ffffff;
  border-bottom: 1px solid #cccccc;
  text-align: center;
  text-decoration: none;
  font: bold 18px/26px Arial, Helvetica, sans-serif;
}

.leaflet-control-attribution {
  padding: 0 5px;
  color: #333333;
  background: rgba(255, 255, 255, 0.8);
  font-size: 11px;
}

.leaflet-interactive {
  cursor: pointer;
}

.leaflet-grab {
  cursor: grab;
}

.leaflet-dragging .leaflet-grab {
  cursor: grabbing;
}

.leaflet-touch .leaflet-control-zoom a {
  width: 30px;
  height: 30px;
  line-height: 30px;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-map-pane {
  z-index: 100;
}

.leaflet-control-attribution a {
  color: #0078a8;
}

.leaflet-container img {
  max-width: none;
  max-height: none;
}

.status {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

#statusText {
  color: var(--muted);
}

.debug-panel {
  max-height: 34vh;
  overflow: auto;
  background: #f8fbf9;
  border-top: 1px solid var(--line);
}

.debug-panel details {
  padding: 8px 12px 12px;
}

.debug-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.debug-grid h2 {
  margin: 0 0 6px;
  font-size: 14px;
}

.debug-list {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
}

.debug-item {
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
}

.debug-item strong {
  display: block;
  margin-bottom: 2px;
}

.debug-item code {
  word-break: break-word;
}

@media (max-width: 720px) {
  .toolbar {
    align-items: stretch;
  }

  .field,
  .check-field,
  input,
  button,
  .button {
    width: 100%;
  }

  .check-field {
    justify-content: center;
  }

  .logout {
    margin-left: 0;
  }

  #map {
    min-height: 60vh;
  }

  .debug-grid {
    grid-template-columns: 1fr;
  }
}
