:root {
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: rgba(245, 245, 245, 0.96);
  --ink: #111111;
  --muted: #5f5f5f;
  --line: rgba(0, 0, 0, 0.16);
  --line-strong: rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  position: relative;
}

#map {
  position: fixed;
  inset: 0;
}

.overlay {
  position: fixed;
  z-index: 2;
  display: grid;
  gap: 0.75rem;
  pointer-events: none;
}

.overlay > * {
  pointer-events: auto;
}

.overlay-top-left {
  top: 0.875rem;
  left: 0.875rem;
  width: min(300px, calc(100vw - 1.75rem));
}

.overlay-top-right {
  top: 0.875rem;
  right: 0.875rem;
  width: min(280px, calc(100vw - 1.75rem));
}

.overlay-bottom-center {
  left: 50%;
  bottom: 0.875rem;
  transform: translateX(-50%);
  width: min(540px, calc(100vw - 1.75rem));
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 0.75rem;
}

.brand-panel h1,
.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-row {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.18rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.meta-line a {
  color: inherit;
}

.filter-panel,
.settings-body {
  display: grid;
  gap: 0.5rem;
}

.filter-fields {
  display: grid;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.05rem;
  border-bottom: 1px solid var(--line);
}

.filter-fields.collapsed {
  display: none;
}

.field {
  display: grid;
  gap: 0.25rem;
}

.field label {
  font-size: 0.78rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.panel-header.compact {
  margin-bottom: 0.35rem;
}

.toggle-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 0.35rem 0.55rem;
  font: inherit;
  cursor: pointer;
}

.action-button {
  border: 1px solid #1e4b7a;
  background: #1e4b7a;
  color: #fff;
  padding: 0.45rem 0.7rem;
  font: inherit;
  cursor: pointer;
}

.action-button[disabled],
.toggle-button[disabled] {
  cursor: default;
  opacity: 0.65;
}

.brand-action-button {
  margin-top: 0.7rem;
  width: 100%;
}

.mobile-settings-toggle {
  position: fixed;
  left: 0.875rem;
  bottom: 4rem;
  z-index: 3;
  display: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
}

.mobile-settings-toggle-icon {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.check-row input {
  margin: 0;
}

.settings-body.collapsed {
  display: none;
}

.status-banner {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  box-shadow: var(--shadow);
  padding: 0.65rem 0.8rem;
  font-size: 0.84rem;
}

.report-toast {
  position: fixed;
  left: 50%;
  bottom: 0.875rem;
  z-index: 33;
  width: min(420px, calc(100vw - 1.75rem));
  transform: translateX(-50%);
  border: 1px solid rgba(20, 73, 35, 0.32);
  background: rgba(227, 245, 232, 0.97);
  color: #143b1f;
  box-shadow: var(--shadow);
  padding: 0.7rem 0.85rem;
  font-size: 0.84rem;
  pointer-events: none;
}

.maplibregl-popup {
  z-index: 31;
}

.maplibregl-popup-content {
  border-radius: 0;
  padding: 0;
  box-shadow: var(--shadow);
}

.maplibregl-popup-close-button {
  color: var(--ink);
  font-size: 1rem;
  padding: 0.25rem 0.4rem;
}

.popup-card {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.75rem;
}

.popup-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.25;
}

.popup-subtitle {
  margin: 0.32rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-wrap: balance;
}

.popup-row {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  line-height: 1.3;
}

.popup-row.warning {
  color: var(--muted);
  font-size: 0.75rem;
}

.popup-row.muted {
  color: var(--muted);
  font-size: 0.7rem;
}

.popup-details-toggle {
  margin-top: 0.2rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0000ee;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.popup-details-toggle:hover {
  color: #0000ee;
}

.popup-details-toggle:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.popup-details-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.popup-details-body {
  margin-top: 0.2rem;
}

.popup-actions {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  margin: 0.6rem 0;
  padding: 0.65rem 0;
  gap: 0.35rem;
  border-top: 1px solid #d8dde5;
  border-bottom: 1px solid #d8dde5;
}

.popup-action-disclosure {
  width: 100%;
}

.popup-action-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #1e4b7a;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.popup-action-toggle:hover {
  color: #163a5f;
}

.popup-action-toggle:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.popup-action-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.popup-action-body {
  margin-top: 0.35rem;
}

.popup-action-title {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #1f1f1f;
  text-wrap: balance;
}

.popup-action-button {
  border: 1px solid #1e4b7a;
  background: #1e4b7a;
  color: #fff;
  padding: 0.42rem 0.6rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(0.75rem, env(safe-area-inset-top))
    max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(0.75rem, env(safe-area-inset-left));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.44);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-width: 100%;
  margin: auto;
}

.report-panel {
  padding: 0.85rem;
  max-width: 100%;
  overflow: hidden;
}

.report-panel-header {
  align-items: flex-start;
}

.report-panel-intro {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
}

.report-panel-intro p {
  margin: 0;
}

.report-form {
  display: grid;
  gap: 0.75rem;
}

.report-form>.field,
.report-form>.report-form-grid{
  margin-top: 0.5rem;
}

.report-form .field {
  gap: 0.32rem;
}

.report-form .field label {
  font-weight: 600;
  color: var(--ink);
}

.report-form-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.report-form-grid > .field {
  align-self: start;
}

.report-observed-grid {
  display: grid;
  align-items: flex-start;
  grid-template-columns: minmax(0, 1fr) minmax(7.75rem, 42%);
  column-gap: 0.55rem;
  margin-top: 0.22rem;
}

.report-observed-grid > *,
.report-observed-field {
  min-width: 0;
}

.report-observed-field {
  display: grid;
  gap: 0.2rem;
}

.report-observed-label {
  font-size: 0.76rem;
  line-height: 1.2;
  font-weight: 400;
  color: var(--muted);
}

.report-form textarea,
.report-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  min-height: 2.15rem;
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
}

.report-form textarea {
  resize: vertical;
  min-height: 6rem;
}

.report-form input[readonly] {
  background: #f4f4f4;
}

.report-form input:disabled {
  background: #f4f4f4;
  color: var(--ink);
}

.report-observed-field input {
  min-width: 0;
  max-width: 100%;
}

.report-observed-field input[type="date"],
.report-observed-field input[type="time"] {
  padding: 0.4rem 0.5rem;
  min-height: 2.1rem;
  min-inline-size: 0;
}

.is-webkit .report-observed-field input[type="date"],
.is-webkit .report-observed-field input[type="time"] {
  padding: 0;
  -webkit-min-logical-width: 0;
}

.is-webkit .report-observed-field input[type="date"]::-webkit-datetime-edit,
.is-webkit .report-observed-field input[type="date"]::-webkit-date-and-time-value,
.is-webkit .report-observed-field input[type="time"]::-webkit-datetime-edit,
.is-webkit .report-observed-field input[type="time"]::-webkit-date-and-time-value {
  padding: 0;
  line-height: 1.2;
}

.is-webkit .report-observed-field input[type="date"]::-webkit-calendar-picker-indicator,
.is-webkit .report-observed-field input[type="time"]::-webkit-calendar-picker-indicator {
  margin: 0;
}

.field-help {
  margin-top: 0.18rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.field-info {
  margin: 0.12rem 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
}

.field-info code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95em;
}

.field-info strong {
  color: var(--ink);
}

.field-info-inline {
  display: none;
}

.report-fleet-field:focus-within .field-info-inline {
  display: block;
}

.report-form-grid-info {
  margin-top: -0.06rem;
}

.field-help summary {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.16rem 0;
  cursor: pointer;
  list-style: none;
  color: #1e4b7a;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.field-help summary::-webkit-details-marker {
  display: none;
}

.field-help summary:hover {
  color: #163a5f;
}

.field-help summary:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.field-help-body {
  margin-top: 0.25rem;
  line-height: 1.35;
}

.field-help code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95em;
}

.field-error {
  margin-top: 0.18rem;
  font-size: 0.74rem;
  line-height: 1.25;
  color: #8b1f1f;
}

.field-error:empty {
  display: none;
}

.report-notice,
.report-form-message {
  border: 1px solid rgba(161, 116, 15, 0.32);
  background: rgba(255, 248, 228, 0.95);
  color: #6d4b00;
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.report-form-message.is-error {
  border-color: rgba(139, 31, 31, 0.32);
  background: rgba(255, 240, 240, 0.97);
  color: #8b1f1f;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top:0.25rem;
}

.report-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.search-results {
  margin-top: 0.35rem;
  max-height: min(40vh, 320px);
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.search-results.empty {
  padding: 0.55rem 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.search-result {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.6rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
  background: var(--panel-strong);
  outline: none;
}

.search-result-title {
  display: block;
  font-size: 0.84rem;
  line-height: 1.2;
}

.search-result-meta {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.74rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .overlay {
    gap: 0.5rem;
  }

  .overlay-top-left {
    top: 0.5rem;
    left: 0.5rem;
    width: calc(100vw - 1rem);
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
    align-items: start;
    gap: 0.5rem;
  }

  .overlay-top-right {
    top: auto;
    left: 0.5rem;
    right: auto;
    bottom: 7.25rem;
    width: min(248px, calc(100vw - 1rem));
  }

  .overlay-bottom-center {
    bottom: 3.75rem;
    width: min(320px, calc(100vw - 1rem));
  }

  .panel {
    padding: 0.55rem 0.6rem;
  }

  .brand-panel h1,
  .panel-header h2 {
    font-size: 0.92rem;
  }
  .brand-panel>.action-button {
  font-size: 0.75rem;
  padding: 0.45rem 0.3rem;
  }

  .brand-action-button {
  margin-top: 0.28rem;
  }

  .meta-row {
    margin-top: 0.28rem;
    gap: 0.14rem;
    font-size: 0.66rem;
    line-height: 1.25;
  }

  .meta-line a {
    word-break: break-word;
  }

  .filter-panel {
    gap: 0.2rem;
  }

  .filter-fields {
    gap: 0.32rem;
    padding-bottom: 0.38rem;
    margin-bottom: 0;
  }
  
  .settings-body {
    gap: 0.36rem;
  }
  
  .panel-header {
    gap: 0.45rem;
    margin-bottom: 0.32rem;
  }

  .panel-header.compact {
    margin-bottom: 0.12rem;
  }

  .field {
    gap: 0.07rem;
  }

  .field label {
    font-size: 0.68rem;
  }

  .field input {
    min-height: 1.5rem;
    padding: 0.15rem 0.45rem;
    font-size: 0.785rem;
  }

  .search-results {
    max-height: min(34vh, 220px);
  }

  .search-result {
    padding: 0.45rem 0.5rem;
  }

  .search-result-title {
    font-size: 0.78rem;
  }

  .search-result-meta {
    font-size: 0.68rem;
  }

  .status-banner {
    padding: 0.5rem 0.65rem;
    font-size: 0.76rem;
  }

  .report-toast {
    bottom: 3.75rem;
    width: min(320px, calc(100vw - 1rem));
    padding: 0.55rem 0.65rem;
    font-size: 0.76rem;
  }

  .settings-panel {
    display: none;
  }

  .settings-panel.mobile-open {
    display: block;
  }

  .settings-panel .toggle-button {
    padding: 0.24rem 0.45rem;
    font-size: 0.78rem;
  }

  .check-row {
    gap: 0.45rem;
    font-size: 0.78rem;
  }

  .mobile-settings-toggle {
    display: grid;
  }

  .modal-dialog {
    width: 100%;
  }

  .report-panel {
    padding: 0.7rem;
  }

  .report-form {
    gap: 0.6rem;
  }

  .report-form .field {
    gap: 0.28rem;
  }

  .report-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .report-observed-grid {
    grid-template-columns: minmax(0, 1fr) minmax(7.25rem, 41%);
    column-gap: 0.45rem;
  }

  .report-observed-label {
    font-size: 0.66rem;
  }

  .report-observed-field input {
    font-size: 0.76rem;
  }

  .report-form input {
    min-height: 2.15rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .report-observed-field input[type="date"],
  .report-observed-field input[type="time"] {
    padding: 0;
  }

  .report-actions {
    flex-direction: column-reverse;
  }

  .report-actions > * {
    width: 100%;
  }

  .field-info,
  .field-help {
    font-size: 0.72rem;
  }
}
