/* Touch-orientierte Tablet- und Handyansichten. */
.map-draw-tools,
.map-icon-palette {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.map-draw-tools {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.map-draw-tools button,
.map-icon-choice,
.map-object-choice {
  min-height: 34px;
  border: 1px solid #ced4da;
  border-radius: 0.45rem;
  background: #fff;
}
.map-icon-choice,
.map-object-choice {
  display: grid;
  place-items: center;
  gap: 0.15rem;
  padding: 0.15rem;
}
.map-icon-choice img,
.map-object-choice img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.map-icon-choice span,
.map-object-choice span {
  width: 100%;
  overflow: hidden;
  font-size: 0.55rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-object-catalog {
  display: grid;
  gap: 0.65rem;
  max-height: 320px;
  overflow: auto;
}
.map-object-category h3 {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: #59636e;
}

@media (max-width: 991.98px) {
  :root {
    --topbar-height: 60px;
  }
  .main-content {
    padding: 0.85rem;
    font-size: 0.9rem;
  }
  .card-body {
    padding: 0.8rem;
  }
  .form-label,
  .form-control,
  .form-select,
  .btn {
    font-size: 0.88rem;
  }
  .operations-header {
    margin-bottom: 0.7rem;
  }
  .operations-header .page-title {
    font-size: 1.45rem;
  }
  .operations-header > div:last-child {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .operations-header select {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  button,
  .btn,
  .form-select,
  .form-control {
    min-height: 44px;
  }
  .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .modal-dialog-scrollable {
    height: 100%;
  }
  .modal-body {
    overscroll-behavior: contain;
  }
  .incident-filter-panel .collapse:not(.show) {
    display: none;
  }
  .resource-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767.98px) {
  .topbar {
    gap: 0.45rem;
    padding: 0 0.55rem;
  }
  .top-brand strong {
    display: none;
  }
  .top-actions {
    margin-left: auto;
    gap: 0.35rem;
  }
  .connection-pill {
    padding: 0.3rem 0.45rem;
  }
  .main-content {
    padding: 0.55rem;
  }
  .operations-header {
    gap: 0.55rem;
  }
  .operations-header > div:first-child {
    width: 100%;
  }
  .operations-header > div:last-child {
    width: 100%;
  }
  .operations-content {
    padding: 0 1px 0.75rem;
  }
  .page-title {
    font-size: 1.3rem;
  }
  .metric-card {
    border-radius: 0.65rem;
  }

  /* Flächenlage: Sichtung und Dokumentation stehen am Handy im Vordergrund. */
  .area-list-toolbar {
    margin-bottom: 0.55rem !important;
  }
  .area-list-toolbar .card-body {
    padding: 0.65rem;
    gap: 0.55rem !important;
  }
  .area-list-toolbar label:first-child {
    order: 3;
    margin: 0 !important;
  }
  #area-visible-count {
    order: -1;
    margin: 0 !important;
    align-self: flex-start;
  }
  .area-table tr.area-incident-row {
    padding: 0.55rem;
    border-radius: 0.75rem;
    margin-bottom: 0.6rem;
  }
  .area-table td:nth-child(2) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }
  .area-table td:nth-child(2) .mt-1 {
    margin-top: 0 !important;
  }
  .area-table td:nth-child(3)::before {
    content: 'Bearbeitung: ';
    font-size: 0.72rem;
    color: #6c757d;
  }
  .area-table td:nth-child(5) {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .area-table td:last-child {
    display: flex;
    gap: 0.4rem;
    justify-content: stretch !important;
  }
  .area-table td:last-child .btn {
    flex: 1;
  }
  .mobile-sighting-report {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: #c8202f;
    color: #fff;
    border-color: #c8202f;
  }
  .area-incident-details td {
    padding: 0 !important;
  }
  .area-incident-details .card {
    border-radius: 0.7rem;
  }
  .sighting-report-new {
    width: 100%;
    min-height: 48px;
  }
  #sighting-report-form textarea {
    min-height: 150px;
  }
  #sighting-report-form input[type='file'] {
    min-height: 54px;
    padding: 0.75rem;
  }

  /* Lagekarte: Karte bleibt frei; Werkzeuge öffnen als mobile Bottom-Sheet. */
  .map-page {
    height: calc(100dvh - var(--topbar-height) - 1.1rem);
    min-height: 0;
    gap: 0.35rem;
  }
  .map-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, 44px);
    gap: 0.35rem;
  }
  .map-toolbar h1,
  #map-source,
  #map-save-view,
  #map-print,
  #map-export {
    display: none !important;
  }
  .map-toolbar #map-incident {
    width: 100% !important;
    max-width: none;
    min-width: 0;
  }
  .map-toolbar .btn {
    width: 44px;
    padding: 0;
  }
  .map-workspace {
    border-radius: 0.65rem;
  }
  .lage-map {
    min-height: 0;
    height: 100%;
  }
  .leaflet-control-zoom a,
  .leaflet-draw-toolbar a {
    width: 42px !important;
    height: 42px !important;
    line-height: 42px !important;
  }
  .leaflet-draw {
    display: none;
  }
  .map-mobile-toolbox {
    margin: 0 0.25rem 0.25rem 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .map-mobile-tools {
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 50%;
    background: #c8202f;
    color: #fff;
    box-shadow: 0 4px 16px #0005;
    font-size: 1.15rem;
  }
  .map-mobile-toolbox-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 60px;
    width: min(340px, calc(100vw - 1.5rem));
    max-height: min(72vh, 620px);
    overflow: auto;
    background: #fffffff8;
    border-radius: 0.85rem;
    box-shadow: 0 8px 30px #17212b55;
  }
  .map-mobile-toolbox.mobile-open .map-mobile-toolbox-panel {
    display: block;
  }
  .map-mobile-toolbox-panel .accordion-button {
    min-height: 48px;
  }
  .map-mobile-toolbox-panel .map-object-catalog {
    max-height: 42vh;
  }
  .map-checkbox-filter-list {
    max-height: 150px;
  }
  .leaflet-control-attribution {
    max-width: 70vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 420px) {
  .area-table td:nth-child(2) {
    grid-template-columns: 1fr;
  }
  .operations-header .page-title i {
    display: none;
  }
  .resource-metrics {
    gap: 0.35rem;
  }
  .resource-metrics > span {
    padding: 0.45rem;
  }
}
