html,
body {
  height: 100%;
  overflow: hidden;
}

:root {
  --fire-red: #d3312a;
  --fire-orange: #ff8a3d;
  --ember-gold: #f2c230;
  --veld-green: #5f9f43;
  --water-blue: #1fa8dc;
  --ink-dark: #20252b;
  --app-bg: #f3f7f2;
  --panel-tint: #fffaf0;
}

.app-version-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.75rem;
  text-align: left;
}
.app-version-link:hover { text-decoration: underline; }
.app-version-link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.app-update-banner[hidden] { display: none !important; }

body {
  background:
    linear-gradient(135deg, rgba(31, 168, 220, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(211, 49, 42, 0.08), transparent 32%),
    var(--app-bg);
  min-height: 100vh;
}

#mapContextMenu {
  position: absolute;
  z-index: 2000;
  min-width: 180px;
}

#mapContextMenu.native-map-context-menu {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0.5rem 0;
}

.native-map-panel { position: relative; padding: 0 0.5rem; background: var(--bs-body-bg, #fff); }
.native-map-details { padding: 0.75rem 0; }

#mapContextMenu.map-context-menu-in-map {
  z-index: 100000;
}

.login-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  background:
    linear-gradient(rgba(20, 24, 28, 0.72), rgba(20, 24, 28, 0.72)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1800&q=75") center/cover;
}

.login-panel {
  width: min(100%, 430px);
  color: #fff;
}

.login-panel .form-label {
  color: #fff;
}

.login-panel .login-text-link {
  color: #fff !important;
  text-decoration-color: rgba(255, 255, 255, 0.65);
}

.login-panel .login-text-link:hover,
.login-panel .login-text-link:focus-visible {
  color: #ffd166 !important;
  background: transparent;
  text-decoration-color: currentColor;
}

.login-resource-links .btn {
  min-height: 2.5rem;
  white-space: normal;
}

.login-resource-links .btn:hover,
.login-resource-links .btn:focus-visible {
  color: #17202a;
  background-color: #fff;
  border-color: #fff;
}

@media (max-height: 600px) {
  .login-shell {
    place-items: start center;
    padding-block: 0.75rem;
  }
}

.dashboard-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(95, 159, 67, 0.08), transparent 42%),
    linear-gradient(315deg, rgba(255, 138, 61, 0.1), transparent 38%),
    var(--app-bg);
}

.sidebar-shell {
  width: 280px;
  height: 100vh;
  height: 100dvh;
  transition: width 0.18s ease;
  position: relative;
  z-index: 1020;
  overflow: hidden;
  background:
    linear-gradient(180deg, #1d2520 0%, #25282d 48%, #341d1b 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

#sideMenu {
  min-height: 0;
  overflow-y: auto;
}

.sidebar-shell.sidebar-narrow {
  width: 78px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--bs-border-radius);
  background: linear-gradient(135deg, var(--fire-red), var(--fire-orange));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
}

.dashboard-link .bi {
  width: 1.25rem;
  flex: 0 0 1.25rem;
  text-align: center;
  font-size: 1.1rem;
}

.dashboard-link:hover,
.dashboard-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(211, 49, 42, 0.95), rgba(255, 138, 61, 0.72));
}

.sidebar-narrow .sidebar-brand {
  justify-content: center;
}

.sidebar-narrow .sidebar-header {
  flex-direction: column;
  justify-content: center !important;
  padding: 0.75rem 0.5rem !important;
}

.sidebar-narrow .sidebar-label {
  display: none !important;
}

.sidebar-narrow .brand-mark {
  width: 36px;
  height: 36px;
  font-size: 0.875rem;
}

.sidebar-narrow .dashboard-link {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.sidebar-narrow #logoutBtn {
  width: 100%;
  padding-left: 0;
  padding-right: 0;
}

.card-header .dashboard-link {
  width: auto;
  color: var(--bs-body-color);
}

.card-header .dashboard-link:hover {
  color: var(--bs-body-color);
  background: var(--bs-tertiary-bg);
}

.dashboard-main {
  min-width: 0;
  flex: 1 1 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

.topbar {
  flex: 0 0 auto;
  min-height: 68px;
  z-index: 100;
  background:
    linear-gradient(90deg, rgba(255, 250, 240, 0.98), rgba(236, 248, 244, 0.98)) !important;
  border-bottom-color: rgba(211, 49, 42, 0.16) !important;
  box-shadow: 0 2px 12px rgba(32, 37, 43, 0.05);
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto;
  gap: 0.5rem;
  align-items: center;
}

.topbar.topbar-without-group .topbar-title {
  flex: 1 1 auto;
}

.mobile-topbar-action {
  display: none;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(211, 49, 42, 0.45);
  box-shadow: 0 0 0 0.2rem rgba(255, 138, 61, 0.16);
}

.dashboard-view {
  display: none;
}

.dashboard-view.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.dashboard-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card {
  border-color: rgba(32, 37, 43, 0.12);
  box-shadow: 0 6px 18px rgba(32, 37, 43, 0.06);
}

.card-header.bg-white {
  background:
    linear-gradient(90deg, rgba(255, 250, 240, 0.98), rgba(240, 248, 236, 0.98)) !important;
  border-bottom-color: rgba(95, 159, 67, 0.18);
}

#overviewView .card:nth-of-type(1),
#mapView .card {
  border-top: 3px solid var(--fire-orange);
}

#overviewView .card:nth-of-type(2),
#waterPointsView .card {
  border-top: 3px solid var(--water-blue);
}

#overviewView .overview-main-row > section:last-child .card,
#incidentsView .card {
  border-top: 3px solid var(--fire-red);
}

#usersView .card,
#groupsView .card,
#configView .card {
  border-top: 3px solid var(--veld-green);
}

.user-guide-shell {
  max-width: 1280px;
  margin-inline: auto;
}

.guide-role-tabs {
  max-width: 28rem;
}

.user-guide-accordion .accordion-button {
  font-weight: 600;
}

.user-guide-accordion .accordion-button:not(.collapsed) {
  color: var(--bs-danger-text-emphasis);
  background: var(--bs-danger-bg-subtle);
}

.guide-screenshot {
  display: block;
  width: 100%;
  max-height: 32rem;
  object-fit: contain;
  object-position: top left;
  background: var(--bs-light);
}

.guide-copy {
  line-height: 1.55;
}

.guide-copy p:last-child {
  margin-bottom: 0;
}

#warningBox {
  flex: 0 0 auto;
}

.dashboard-view.active > .card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.dashboard-view.active > .card > .card-header,
.dashboard-card-header {
  flex: 0 0 auto;
}

.dashboard-view.active > .card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#incidentsView.active > .card > .card-body,
#waterPointsView.active > .card > .card-body,
#usersView.active > .card > .card-body,
#groupsView.active > .card > .card-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#incidentsView.active > .card > .card-body > .row,
#waterPointsView.active > .card > .card-body > .row,
#usersView.active > .card > .card-body > .row,
#groupsView.active > .card > .card-body > .row {
  flex: 0 0 auto;
}

#incidentList.list-group,
#waterPointList.list-group,
#userList.list-group,
#groupList.list-group {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

#overviewView.active {
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 0;
}

.kpi-row {
  flex: 0 0 auto;
}

.kpi-card {
  min-height: 50px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 240, 0.92));
  border-left: 4px solid var(--fire-orange);
}

.kpi-card .small {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-value {
  font-size: 1.35rem;
  color: var(--ink-dark);
}

.incident-metric-value {
  font-size: 1.35rem;
}

.incident-metric-card {
  min-height: 50px;
  border-color: var(--tblr-border-color, #dadfe5) !important;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 250, 240, 0.9));
}

.incident-metric-total { border-left-color: var(--water-blue) !important; }
.incident-metric-active { border-left-color: var(--fire-red) !important; }
.incident-metric-confirmed { border-left-color: var(--veld-green) !important; }
.incident-metric-rejected { border-left-color: var(--bs-secondary) !important; }

.card-navigation,
.card-primary-action {
  appearance: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.card-navigation.card {
  padding: 0;
}

.card-navigation.incident-metric-card {
  border-style: solid;
  border-width: 1px !important;
  border-left-width: 4px !important;
}

.actionable-card {
  position: relative;
}

.card-primary-action {
  padding: 0;
  border: 0;
  background: transparent;
}

.card-navigation:hover,
.actionable-card:hover {
  box-shadow: inset 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.actionable-card:hover .card-primary-action {
  text-decoration: underline;
}

.card-navigation:focus-visible,
.card-primary-action:focus-visible::after {
  outline: 3px solid var(--tblr-primary, #0d6efd);
  outline-offset: -3px;
  border-radius: inherit;
}

.card-primary-action:focus-visible {
  outline: none;
}

.card-navigation[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px var(--tblr-primary, #0d6efd);
}

.card-secondary-actions {
  position: relative;
  z-index: 2;
}

.page-filter-select {
  max-width: 14rem;
}

@media (max-width: 575.98px) {
  .page-filter-select.form-select-sm {
    min-height: 1.75rem;
    padding-top: 0.125rem;
    padding-bottom: 0.125rem;
    font-size: 0.78rem;
  }
}

.kpi-row article:nth-child(1) .kpi-card { border-left-color: var(--fire-red); }
.kpi-row article:nth-child(2) .kpi-card { border-left-color: var(--veld-green); }
.kpi-row article:nth-child(3) .kpi-card { border-left-color: var(--ember-gold); }
.kpi-row article:nth-child(4) .kpi-card { border-left-color: var(--water-blue); }

.overview-main-row {
  flex: 0 0 auto;
  min-height: 0;
}

.overview-main-row > [class*="col-"] {
  min-height: 0;
  display: flex;
}

.overview-main-row .card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.overview-main-row .card-body {
  min-height: 0;
  overflow: auto;
}

.weather-instrument { padding: 0.6rem 0.75rem; color: var(--tblr-body-color); background: linear-gradient(145deg,#fff,#f4f7fb); border-bottom: 1px solid var(--tblr-border-color); }
.weather-now { display: grid; grid-template-columns: minmax(8rem,1fr) auto auto; align-items: center; gap: 0.65rem; }
.weather-current-reading { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.weather-now-icon { display: grid; place-items: center; flex: 0 0 3.25rem; width: 3.25rem; height: 3.25rem; color: var(--tblr-primary); }
.weather-now-icon i { font-size: 2.9rem; animation: weather-float 3.2s ease-in-out infinite; }
.weather-current-temp { display: block; color: var(--tblr-body-color); font-size: clamp(1.9rem, 5vw, 2.65rem); font-weight: 700; line-height: .95; }
.weather-current-condition { display: block; margin-top: .25rem; color: var(--tblr-primary); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.weather-wind-dial { position: relative; width: 3.75rem; height: 3.75rem; border: 2px solid var(--tblr-primary); border-radius: 50%; background:#fff; box-shadow: 0 .15rem .45rem rgba(24,36,51,.12); }
.weather-dial-north { position: absolute; top: .12rem; left: 50%; color: var(--tblr-body-color); font-size: .55rem; transform: translateX(-50%); }
.weather-wind-needle { --wind-direction: 0deg; position: absolute; left: calc(50% - 2px); bottom: 50%; width: 4px; height: 1.4rem; border-radius: 1rem; background: linear-gradient(#f4ff30 0 55%, #ff5252 55%); transform: rotate(var(--wind-direction)); transform-origin: 50% 100%; transition: transform .5s ease; }
.weather-dial-center { position: absolute; left: 50%; top: 50%; width: .48rem; height: .48rem; border-radius: 50%; background: var(--tblr-body-color); transform: translate(-50%,-50%); }
.weather-current-stats { display: grid; gap: .16rem; min-width: 7.5rem; }
.weather-current-stats span { display: flex; align-items: baseline; gap: .2rem; color: var(--tblr-secondary-color); font-size: .62rem; white-space: nowrap; }
.weather-current-stats i { align-self: center; color: var(--tblr-primary); font-size: .85rem; }
.weather-current-stats strong { color: var(--tblr-body-color); font-size: .76rem; }
@media (max-width: 399.98px) {
  .weather-now { grid-template-columns: minmax(6.8rem,1fr) auto auto; gap: .35rem; }
  .weather-now-icon { flex-basis: 2.5rem; width: 2.5rem; height: 2.5rem; }
  .weather-now-icon i { font-size: 2.25rem; }
  .weather-current-temp { font-size: 1.7rem; }
  .weather-current-condition { font-size: .62rem; }
  .weather-current-stats { min-width: 6.4rem; }
  .weather-current-stats span { font-size: .54rem; gap: .12rem; }
  .weather-current-stats strong { font-size: .66rem; }
  .weather-current-stats i { font-size: .72rem; }
  .weather-wind-dial { width: 3.1rem; height: 3.1rem; }
  .weather-wind-needle { height: 1.15rem; }
}
.weather-day-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.weather-instrument-forecast { background: #f4f7fb; }

.fire-spread-signal { position: absolute; width: 5rem; height: 2.5rem; transform-origin: 0 50%; pointer-events: none; z-index: 1800; }
.fire-spread-signal span { position: absolute; left: .35rem; top: 50%; width: 1rem; height: 1rem; border: .22rem solid #d63939; border-left: 0; border-bottom: 0; border-radius: 0 100% 0 0; transform: translateY(-50%) rotate(45deg); opacity: 0; filter: drop-shadow(0 0 .16rem rgba(214,57,57,.8)); animation: fire-spread-wave 1.5s ease-out infinite; }
.fire-spread-signal span:nth-child(2) { width: 1.8rem; height: 1.8rem; animation-delay: .3s; }
.fire-spread-signal span:nth-child(3) { width: 2.6rem; height: 2.6rem; animation-delay: .6s; }
@keyframes fire-spread-wave { 0%,20% { opacity: 0; } 35%,65% { opacity: 1; } 85%,100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fire-spread-signal span { animation: none; opacity: .85; } }
.weather-day-card { --weather-accent: var(--tblr-primary); min-width: 0; overflow: hidden; color: var(--tblr-body-color); border: 1px solid var(--tblr-border-color); border-top: 3px solid var(--weather-accent); border-radius: 0.35rem; background: #fff; box-shadow: 0 .125rem .3rem rgba(24,36,51,.06); }
.weather-day-header { display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0.65rem 0.4rem; }
.weather-day-header strong { color: var(--tblr-body-color); letter-spacing: .06em; text-transform: uppercase; }
.weather-day-date { display: block; color: var(--tblr-secondary-color); font-size: 0.72rem; font-weight: 400; }
.weather-day-icon { color: var(--tblr-primary); font-size: 2.2rem; animation: weather-float 3.2s ease-in-out infinite; }
.weather-day-card:nth-child(2) .weather-day-icon { animation-delay: -1.1s; }
.weather-fdi { padding: 0 0.65rem 0.55rem; }
.weather-fdi-label { display: block; margin-bottom: 0.15rem; color: var(--tblr-secondary-color); font-size: 0.68rem; }
.weather-fdi-value { color: var(--tblr-body-color); font-size: 1.45rem; line-height: 1; }
.weather-fdi .progress { margin-top: 0.4rem; background: rgba(98,105,118,0.14); }
.weather-fdi .progress-bar { transition: width 650ms ease; }
.weather-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--tblr-border-color); }
.weather-metrics > div { display: grid; grid-template-columns: auto 1fr; column-gap: 0.35rem; align-items: center; min-width: 0; padding: 0.42rem 0.55rem; border-right: 1px solid var(--tblr-border-color); border-bottom: 1px solid var(--tblr-border-color); }
.weather-metrics > div:nth-child(even) { border-right: 0; }
.weather-metrics > div:nth-last-child(-n+2) { border-bottom: 0; }
.weather-metrics > div:last-child { grid-column: 1 / -1; border-right: 0; }
.weather-metrics i { grid-row: 1 / span 2; font-size: 1rem; }
.weather-metrics span { color: var(--tblr-secondary-color); font-size: 0.65rem; line-height: 1; }
.weather-metrics strong { min-width: 0; color: var(--tblr-body-color); font-size: 0.76rem; line-height: 1.25; overflow-wrap: anywhere; }
@keyframes weather-float { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .weather-now-icon i, .weather-day-icon { animation: none; } .weather-fdi .progress-bar { transition: none; } }

@media (min-width: 1200px) {
  .overview-main-row > [class*="col-"]:last-child > .card {
    max-height: calc(100dvh - 254px);
    position: sticky;
    top: 0;
  }
}

.fdi-gauge {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.fdi-chart-wrap {
  position: relative;
  width: min(100%, 180px);
  height: clamp(72px, 18vw, 108px);
  margin: 0 auto 0.15rem;
}

.fdi-chart-wrap canvas {
  display: block;
}

.fdi-gauge-summary {
  width: 100%;
  min-height: 2.65rem;
}

.fdi-gauge-summary .badge {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  white-space: normal;
}

.fdi-legend {
  color: var(--bs-secondary-color);
  line-height: 1.1;
  font-size: 0.72rem;
}

.legend-swatch {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  margin-right: 0.25rem;
  border-radius: 0.15rem;
  vertical-align: -0.1rem;
}

.fdi-safe { background: #1fa8dc; }
.fdi-moderate { background: #96c94c; }
.fdi-dangerous { background: #f2dc31; }
.fdi-very { background: #ff8a3d; }
.fdi-extreme { background: #f30d0d; }

.current-conditions-inline {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-inline: 0.25rem;
}

.condition-tile {
  min-height: 8.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.wind-compass-hub {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #121212;
  border: 3px solid #fff;
  transform: translate(-50%, -50%);
}

@media (min-width: 992px) {
  .dashboard-content {
    padding: 0.55rem !important;
  }

  #overviewView .card-header {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }

  #overviewView .badge {
    font-size: 0.64rem;
  }

  #overviewView.active {
    overflow-y: hidden;
  }
}

.wind-compass {
  position: relative;
  width: 86px;
  height: 86px;
  border: 2px solid #cfd6df;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), #c7cfd9 50%, transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), #c7cfd9 50%, transparent calc(50% + 1px)),
    #eef1f5;
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.42);
}

.compass-cardinal {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bs-secondary-color);
}

.compass-n { top: 5px; left: 50%; transform: translateX(-50%); }
.compass-e { right: 7px; top: 50%; transform: translateY(-50%); }
.compass-s { bottom: 5px; left: 50%; transform: translateX(-50%); }
.compass-w { left: 7px; top: 50%; transform: translateY(-50%); }

.wind-compass-arrow {
  position: absolute;
  left: calc(50% - 4px);
  bottom: 50%;
  width: 8px;
  height: 32px;
  border-radius: 999px 999px 2px 2px;
  background: var(--fire-red);
  transform-origin: 50% 100%;
  transform: rotate(0deg);
  transition: transform 0.25s ease;
}

.wind-compass-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 13px solid var(--fire-red);
  transform: translateX(-50%);
}

.temp-gauge {
  position: relative;
  width: 56px;
  height: 86px;
}

.temp-gauge-track {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 16px;
  height: 58px;
  border: 2px solid #cfd6df;
  border-radius: 999px 999px 0 0;
  background: #fff;
  overflow: hidden;
  transform: translateX(-50%);
  box-shadow: inset 0 0 0 3px #f3f5f8;
}

.temp-gauge-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 0;
  height: 0%;
  border-radius: 999px;
  background: linear-gradient(0deg, #1fa8dc 0%, #f2dc31 48%, #f30d0d 100%);
  transition: height 0.25s ease;
}

.temp-gauge-bulb {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #cfd6df;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 10%, transparent 11%),
    linear-gradient(0deg, #1fa8dc 0%, #f2dc31 48%, #f30d0d 100%);
  transform: translateX(-50%);
  box-shadow: 0 0 0 6px rgba(243, 13, 13, 0.08);
}

#overviewMapDock {
  flex: 1 1 auto;
}

#overviewMapDock .map-surface {
  height: 100%;
}

.card-header h3 {
  font-size: 1rem;
  margin: 0;
}

.form-panel {
  max-width: 760px;
}

.config-panel {
  max-width: none;
}

.config-panel .nav-link {
  min-height: 2.75rem;
}

.config-panel .tab-content {
  max-width: 1100px;
}

.map-surface {
  position: relative;
  height: clamp(280px, calc(100dvh - 238px), 620px);
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #cfe9d4, #d7e8f2);
}

.map-dock .map-surface {
  height: 100%;
  min-height: 0;
}

#mapView.active > .card,
#mapView.active .map-dock {
  min-height: 0;
}

#mapView.active .map-dock {
  flex: 1 1 auto;
}

.dashboard-view.active > .card > .list-group,
.dashboard-view.active > .card > .card-body > .list-group {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.list-group-item {
  background: rgba(255, 255, 255, 0.92);
}

.list-group-item:hover {
  background: rgba(255, 250, 240, 0.96);
}

#groupsView.active {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
}

#groupsView.active > .card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#groupsView.active > .card > .card-body,
#groupsView.active > .card > .list-group {
  min-height: 0;
  overflow: auto;
}

#groupForm .d-flex.flex-wrap.gap-2:last-child,
#configForm .d-flex.align-items-center.gap-2 {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 0.5rem;
  background: var(--bs-card-bg);
}

.severity-low { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.severity-medium { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.severity-high { background: #ffe0cc; color: #984b00; }
.severity-critical { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }

.btn-danger {
  --bs-btn-bg: var(--fire-red);
  --bs-btn-border-color: var(--fire-red);
  --bs-btn-hover-bg: #b92722;
  --bs-btn-hover-border-color: #b92722;
}

.btn-outline-danger {
  --bs-btn-color: var(--fire-red);
  --bs-btn-border-color: var(--fire-red);
  --bs-btn-hover-bg: var(--fire-red);
  --bs-btn-hover-border-color: var(--fire-red);
}

.alert-warning {
  --bs-alert-bg: #fff4cf;
  --bs-alert-border-color: #ffd36b;
  --bs-alert-color: #684300;
}


@media (max-width: 991px) {
  .dashboard-shell {
    display: flex;
    flex-direction: column;
  }

  .sidebar-shell {
    width: 100%;
    height: auto;
    max-height: none;
    flex: 0 0 auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  }

  .sidebar-shell.sidebar-narrow {
    width: 100%;
  }

  .sidebar-shell .sidebar-header,
  .sidebar-shell.sidebar-narrow .sidebar-header {
    flex-direction: row;
    justify-content: space-between !important;
    padding: 0.5rem 0.75rem !important;
  }

  .sidebar-shell .sidebar-brand,
  .sidebar-shell.sidebar-narrow .sidebar-brand {
    justify-content: flex-start;
  }

  .sidebar-shell .brand-mark,
  .sidebar-shell.sidebar-narrow .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 0.8rem;
  }

  .sidebar-shell .sidebar-header .sidebar-label {
    display: inline !important;
  }

  .sidebar-shell > .mt-auto {
    display: none;
  }

  #sideMenu {
    overflow-x: auto;
    overflow-y: hidden;
  }

  #sideMenu .nav {
    flex-direction: row !important;
    flex-wrap: nowrap;
    padding: 0.45rem 0.75rem !important;
    white-space: nowrap;
  }

  .sidebar-shell.sidebar-narrow .dashboard-link,
  .sidebar-shell .dashboard-link {
    min-width: 48px;
    justify-content: center;
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .dashboard-main {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: row;
    flex-wrap: wrap;
    min-height: 0;
    padding: 0.55rem 0.75rem !important;
    gap: 0.5rem !important;
  }

  .topbar > .d-flex:first-child {
    flex: 1 1 100%;
  }

  .topbar p {
    display: none;
  }

  .topbar h2 {
    font-size: 1.25rem;
    line-height: 1.15;
  }

  .topbar-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .desktop-topbar-action {
    display: none !important;
  }

  .mobile-topbar-action {
    display: block;
  }

  .mobile-topbar-action .dropdown-menu {
    min-width: 12rem;
  }

  .dashboard-content,
  .dashboard-view,
  .dashboard-view.active,
  .card,
  .card-body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .dashboard-view.active > .card > .card-header {
    flex-wrap: wrap;
  }

  #mapView .card-header {
    align-items: stretch !important;
    flex-direction: column;
    position: relative;
    width: 100%;
  }

  #mapView .card-header > .d-flex:first-child {
    flex-direction: row;
    align-items: center !important;
  }

  #mapControls {
    position: absolute;
    z-index: 40;
    top: calc(100% + 0.45rem);
    left: 0.75rem;
    right: 0.75rem;
    padding: 0.75rem;
    border: 1px solid rgba(32, 37, 43, 0.14);
    border-top: 3px solid var(--fire-orange);
    border-radius: var(--bs-border-radius);
    background:
      linear-gradient(180deg, rgba(255, 250, 240, 0.98), rgba(240, 248, 236, 0.98));
    box-shadow: 0 16px 34px rgba(32, 37, 43, 0.22);
  }

  #mapControls.show {
    display: grid;
    gap: 0.65rem;
  }

  #mapView.active > .card {
    flex: 0 0 auto;
  }

  #mapView .card-header {
    padding: 0.55rem 0.75rem;
  }

  #mapView .card-header h3 {
    font-size: 1rem;
    line-height: 1.1;
  }

  #mapView .card-header .btn,
  #boundaryMapControls {
    width: 100%;
  }

  #mapTypeToggle {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  #mapTypeToggle .btn {
    width: 100%;
    border-radius: var(--bs-border-radius) !important;
  }

  .form-panel {
    max-width: 100%;
  }

  #groupsView.active {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: auto;
  }
}

@media (max-width: 575px) {
  .dashboard-content {
    padding: 0.65rem !important;
  }

  .kpi-card {
    min-height: 54px;
    padding: 0.45rem 0.65rem;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  .topbar-actions .btn,
  .topbar-actions .form-select {
    width: 100%;
  }

  .dashboard-view.active > .card > .card-header {
    align-items: stretch !important;
    flex-direction: column;
  }

  .dashboard-view.active > .card > .card-header > * {
    width: 100%;
  }

  .dashboard-view.active > .card > .card-header .btn,
  .dashboard-view.active > .card > .card-header .form-select {
    width: 100%;
  }

  #incidentStatusFilter {
    width: 100% !important;
  }

  .map-surface {
    height: 42vh;
  }

  .map-dock .map-surface {
    height: 42vh;
    min-height: 260px;
  }

  .dashboard-view.active > .card > .list-group,
  .dashboard-view.active > .card > .card-body > .list-group {
    max-height: calc(100dvh - 300px);
  }

  #mapTypeToggle {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 991px) and (orientation: landscape), (max-width: 991px) and (max-height: 520px) {
  .sidebar-shell .sidebar-header,
  .sidebar-shell.sidebar-narrow .sidebar-header {
    display: none !important;
  }

  #sideMenu .nav {
    padding: 0.25rem 0.5rem !important;
  }

  .sidebar-shell.sidebar-narrow .dashboard-link,
  .sidebar-shell .dashboard-link {
    min-width: 42px;
    padding: 0.45rem 0.65rem;
  }

  .topbar {
    padding: 0.35rem 0.55rem !important;
    gap: 0.35rem !important;
  }

  .topbar > .d-flex:first-child {
    flex: 0 1 auto;
    min-width: 8rem;
  }

  .topbar h2 {
    font-size: 1rem;
  }

  .topbar-actions {
    flex: 1 1 auto;
    width: auto;
    grid-template-columns: minmax(9rem, 1fr) auto;
  }

  .topbar-actions .form-select,
  .topbar-actions .btn {
    min-height: 2rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .dashboard-content {
    padding: 0.35rem !important;
  }

  #mapView .card-header {
    flex-direction: row !important;
    align-items: center !important;
    padding: 0.4rem 0.55rem;
  }

  #mapView .card-header > .d-flex:first-child {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  #mapView .card-header .btn[data-bs-target="#mapControls"] {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  #mapControls {
    left: auto;
    right: 0.5rem;
    width: min(18rem, calc(100vw - 1rem));
  }

  #mapDock {
    padding: 0.35rem !important;
  }

  #mapView .map-surface,
  #mapView .map-dock .map-surface {
    height: max(180px, calc(100dvh - 158px));
    min-height: 180px;
  }
}

/* Final mobile-first shell override. Keep this block last. */
@media (max-width: 991.98px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .dashboard-shell {
    min-height: 100dvh;
    height: auto;
    display: block;
    overflow: visible;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .dashboard-main {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    display: block;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 1010;
    min-height: 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch !important;
    gap: 0.4rem !important;
    padding: 0.45rem 0.65rem !important;
  }

  .topbar-title {
    min-width: 0;
    flex: none;
  }

  .topbar p {
    display: block;
    font-size: 0.58rem;
    letter-spacing: 0;
    line-height: 1;
    margin-bottom: 0.12rem !important;
  }

  .topbar h2 {
    font-size: clamp(1.12rem, 5vw, 1.45rem);
    line-height: 1.05;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
  }

  .topbar-actions .mobile-topbar-action {
    position: absolute;
    top: 0.45rem;
    right: 0.65rem;
    width: auto;
  }

  .topbar-actions .form-select,
  .topbar-actions .btn {
    width: 100%;
    min-height: 2.05rem;
    font-size: 0.86rem;
  }

  .topbar-actions .mobile-topbar-action .btn {
    width: 2.05rem;
    min-height: 2.05rem;
  }

  .desktop-topbar-action {
    display: none !important;
  }

  .mobile-topbar-action {
    display: block;
  }

  .dashboard-content {
    display: block;
    min-height: 0;
    padding: 0.65rem !important;
    overflow: visible;
  }

  .dashboard-view,
  .dashboard-view.active {
    display: none;
    min-height: 0;
    max-width: 100%;
    overflow: visible;
  }

  .dashboard-view.active {
    display: block;
  }

  .dashboard-view.active > .card,
  .dashboard-view.active > .card > .card-body,
  .overview-main-row .card,
  .overview-main-row .card-body {
    display: block;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .card {
    border-radius: 0.85rem;
    overflow: hidden;
  }

  .card-header,
  .dashboard-view.active > .card > .card-header {
    padding: 0.75rem 0.85rem;
    align-items: stretch !important;
  }

  .card-header h3 {
    font-size: 1.05rem;
  }

  .kpi-row {
    margin-bottom: 0.5rem !important;
  }

  .kpi-card {
    min-height: 3.1rem;
  }

  .kpi-card .small {
    font-size: 0.58rem;
    line-height: 1.1;
  }

  .kpi-value {
    font-size: 1.12rem;
  }

  .fdi-chart-wrap {
    width: min(100%, 142px);
    height: 66px;
    margin-bottom: 0;
  }

  .fdi-gauge {
    gap: 0.05rem;
  }

  .fdi-gauge-summary {
    min-height: 2.15rem;
  }

  .fdi-gauge-summary .small,
  .fdi-gauge-summary .badge,
  .fdi-legend {
    font-size: 0.62rem;
  }

  .fdi-legend {
    gap: 0.35rem !important;
  }

  .legend-swatch {
    width: 0.5rem;
    height: 0.5rem;
  }

  .incident-metrics .small {
    font-size: 0.66rem;
    line-height: 1.1;
  }

  .incident-metric-value {
    font-size: 1.05rem;
  }

  .dashboard-view.active > .card > .list-group,
  .dashboard-view.active > .card > .card-body > .list-group,
  #incidentList.list-group {
    max-height: none;
    overflow: visible;
  }

  .form-panel {
    max-width: none;
  }

  .config-panel .card-body,
  .config-panel .card-footer {
    padding: 0.75rem;
  }

  .config-panel .nav-link {
    min-height: 2.5rem;
    padding: 0.5rem 0.35rem;
    font-size: 0.78rem;
  }

  .config-panel .card-footer .btn {
    width: 100%;
  }

  .guide-role-tabs {
    max-width: none;
  }

  .user-guide-accordion .accordion-button {
    padding: 0.75rem;
    font-size: 0.875rem;
  }

  .user-guide-accordion .accordion-body {
    padding: 0.75rem;
    font-size: 0.82rem;
  }

  .modal-dialog {
    margin: 0.75rem;
  }

  .modal-footer {
    gap: 0.5rem;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
  }

  .sidebar-shell,
  .sidebar-shell.sidebar-narrow {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1040;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch;
    overflow: hidden;
    border-right: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    border-bottom: 0;
    box-shadow: 0 -10px 28px rgba(32, 37, 43, 0.22);
  }

  .sidebar-shell .sidebar-header,
  .sidebar-shell.sidebar-narrow .sidebar-header {
    display: none !important;
  }

  #sideMenu {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  #sideMenu::-webkit-scrollbar {
    display: none;
  }

  #sideMenu .nav {
    height: 100%;
    min-width: max-content;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem !important;
    padding: 0.4rem 0.45rem calc(0.4rem + env(safe-area-inset-bottom, 0px)) !important;
    white-space: nowrap;
  }

  .sidebar-shell .dashboard-link,
  .sidebar-shell.sidebar-narrow .dashboard-link {
    width: 4.25rem;
    min-width: 4.25rem;
    height: 3.2rem;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.12rem !important;
    padding: 0.3rem 0.25rem !important;
    border-radius: 0.8rem;
    color: rgba(255, 255, 255, 0.72);
  }

  .sidebar-shell .dashboard-link .bi,
  .sidebar-shell.sidebar-narrow .dashboard-link .bi {
    width: auto;
    flex: 0 0 auto;
    font-size: 1.22rem;
  }

  .sidebar-shell .dashboard-link .sidebar-label,
  .sidebar-shell.sidebar-narrow .dashboard-link .sidebar-label {
    display: block !important;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.6rem;
    line-height: 1.05;
  }

  .sidebar-shell > .mt-auto {
    display: flex !important;
    align-items: center;
    flex: 0 0 auto;
    margin-top: 0 !important;
    padding: 0.4rem 0.45rem calc(0.4rem + env(safe-area-inset-bottom, 0px)) !important;
    border-top: 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.14);
  }

  #currentUser {
    display: none !important;
  }

  #logoutBtn,
  .sidebar-shell.sidebar-narrow #logoutBtn {
    width: 3.2rem;
    height: 3.2rem;
    margin-top: 0 !important;
    padding: 0 !important;
    border-radius: 0.8rem;
  }

  #logoutBtn .sidebar-label {
    display: none !important;
  }

  #mapView.active {
    min-height: calc(100dvh - 72px - env(safe-area-inset-bottom, 0px));
  }

  #mapView.active > .card {
    min-height: calc(100dvh - 166px - env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
  }

  #mapView .card-header,
  #mapView .card-header.bg-white {
    position: relative;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.55rem;
    align-items: center !important;
    padding: 0.7rem;
  }

  #mapView .card-header > .d-flex:first-child {
    width: auto;
    min-width: 0;
    flex-direction: row;
    align-items: center !important;
  }

  #mapView .card-header h3 {
    font-size: 1.15rem;
  }

  #mapView .card-header .btn[data-bs-target="#mapControls"] {
    width: auto;
    min-height: 2.35rem;
    white-space: nowrap;
  }

  #mapControls {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0.65rem;
    left: 0.65rem;
    z-index: 50;
    width: auto;
    padding: 0.75rem;
    border: 1px solid rgba(32, 37, 43, 0.14);
    border-top: 3px solid var(--fire-orange);
    border-radius: 0.85rem;
    background: rgba(255, 250, 240, 0.98);
    box-shadow: 0 18px 36px rgba(32, 37, 43, 0.24);
  }

  #mapControls.show {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  #boundaryMapControls,
  #mapTypeToggle {
    width: 100%;
  }

  #mapTypeToggle {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #mapTypeToggle .btn,
  #locateBtn,
  #showWaterPointsBtn {
    width: 100%;
  }

  #mapDock {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.45rem !important;
  }

  #mapView .map-surface,
  #mapView .map-dock .map-surface {
    height: calc(100dvh - 226px - env(safe-area-inset-bottom, 0px));
    min-height: 21rem;
    border-radius: 0.75rem;
  }

}

@media (max-width: 575.98px) {
  .weather-day-grid { gap: 0.35rem; padding: 0.35rem !important; }
  .weather-day-header, .weather-fdi { padding-left: 0.45rem; padding-right: 0.45rem; }
  .weather-fdi-label { font-size: 0.62rem; }
  .weather-fdi-value { font-size: 1.2rem; }
  .weather-fdi .badge { font-size: 0.58rem; }
  .weather-metrics > div { padding: 0.35rem; column-gap: 0.25rem; }
  .weather-metrics strong { font-size: 0.68rem; }
  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: 2.65rem;
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }

  .kpi-value {
    font-size: 0.95rem;
  }

  .fdi-chart-wrap {
    width: min(100%, 118px);
    height: 56px;
  }

  .fdi-gauge-summary {
    min-height: 2rem;
  }

  #mapView.active > .card {
    min-height: calc(100dvh - 152px - env(safe-area-inset-bottom, 0px));
  }

  #mapView .map-surface,
  #mapView .map-dock .map-surface {
    height: calc(100dvh - 216px - env(safe-area-inset-bottom, 0px));
    min-height: 20rem;
  }
}

/* Notification controls extend the Bootstrap/Tabler top bar without changing page flow. */
.tabler-app #groupSelectContainer {
  min-width: min(18rem, 42vw);
}

.tabler-app #groupSelectContainer .form-select {
  width: 100%;
  min-width: 0;
}

.notification-menu {
  width: min(24rem, calc(100vw - 1rem));
}

.notification-list {
  max-height: min(28rem, 65vh);
  overflow-y: auto;
}

.notification-list .list-group-item {
  white-space: normal;
}

.alert-rule .form-check-label,
.alert-rule .form-label {
  line-height: 1.25;
}

@media (max-width: 991.98px) {
  .tabler-app .topbar,
  .tabler-app .topbar.topbar-without-group {
    grid-template-columns: minmax(0, 1fr) auto !important;
  }

  .tabler-app .topbar.topbar-without-group .topbar-title {
    grid-column: 1 !important;
  }

  .tabler-app .topbar-actions {
    grid-column: 2;
    width: auto !important;
    min-width: 0;
    margin-left: auto !important;
    display: flex !important;
    align-items: center;
    gap: 0.35rem;
  }

  .tabler-app #groupSelectContainer {
    width: clamp(8.5rem, 42vw, 13rem);
    min-width: 0;
  }

  .tabler-app .topbar-actions .btn-icon {
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    padding: 0;
  }
}

@media (max-width: 991.98px) and (orientation: landscape), (max-width: 991.98px) and (max-height: 540px) {
  .dashboard-shell {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    grid-template-columns: minmax(8rem, auto) minmax(13rem, 1fr);
    align-items: center !important;
    padding: 0.35rem 0.5rem !important;
  }

  .topbar p {
    display: none;
  }

  .topbar h2 {
    font-size: 1.05rem;
  }

  .topbar-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-actions .form-select,
  .topbar-actions .btn {
    min-height: 1.85rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
  }

  .dashboard-content {
    padding: 0.35rem !important;
  }

  .sidebar-shell,
  .sidebar-shell.sidebar-narrow {
    height: calc(54px + env(safe-area-inset-bottom, 0px));
  }

  #sideMenu .nav {
    padding: 0.25rem 0.35rem calc(0.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sidebar-shell .dashboard-link,
  .sidebar-shell.sidebar-narrow .dashboard-link,
  #logoutBtn,
  .sidebar-shell.sidebar-narrow #logoutBtn {
    height: 2.75rem;
  }

  .sidebar-shell .dashboard-link,
  .sidebar-shell.sidebar-narrow .dashboard-link {
    width: 3.75rem;
    min-width: 3.75rem;
  }

  #logoutBtn,
  .sidebar-shell.sidebar-narrow #logoutBtn {
    width: 3rem;
  }

  #mapView.active > .card {
    min-height: calc(100dvh - 108px - env(safe-area-inset-bottom, 0px));
  }

  #mapView .card-header,
  #mapView .card-header.bg-white {
    padding: 0.4rem 0.5rem;
  }

  #mapView .card-header h3 {
    font-size: 1rem;
  }

  #mapView .card-header .btn[data-bs-target="#mapControls"] {
    min-height: 2rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
  }

  #mapControls {
    left: auto;
    right: 0.4rem;
    width: min(18rem, calc(100vw - 0.8rem));
  }

  #mapDock {
    padding: 0.3rem !important;
  }

  #mapView .map-surface,
  #mapView .map-dock .map-surface {
    height: calc(100dvh - 122px - env(safe-area-inset-bottom, 0px));
    min-height: 10rem;
  }
}

#map:fullscreen,
#mapDock:fullscreen,
#mapDock:fullscreen .map-surface {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  border-radius: 0;
}

#map:-webkit-full-screen,
#mapDock:-webkit-full-screen,
#mapDock:-webkit-full-screen .map-surface {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
}

@media (max-width: 991.98px) and (orientation: landscape) {
  body[data-active-view="mapView"] .topbar {
    padding: 0.25rem 0.45rem !important;
  }

  body[data-active-view="mapView"] .topbar p {
    display: none;
  }

  body[data-active-view="mapView"] .topbar h2 {
    font-size: 0.98rem;
  }

  body[data-active-view="mapView"] .topbar-actions .form-select,
  body[data-active-view="mapView"] .topbar-actions .btn {
    min-height: 1.9rem;
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
  }

  body[data-active-view="mapView"] .dashboard-content {
    padding: 0 !important;
  }

  body[data-active-view="mapView"] #mapView > .card {
    border: 0;
    border-radius: 0;
    min-height: calc(100dvh - 96px - env(safe-area-inset-bottom, 0px));
  }

  body[data-active-view="mapView"] #mapView .card-header {
    border-radius: 0;
    padding: 0.25rem 0.45rem;
  }

  body[data-active-view="mapView"] #mapDock {
    padding: 0 !important;
  }

  body[data-active-view="mapView"] #map,
  body[data-active-view="mapView"] #mapView .map-surface,
  body[data-active-view="mapView"] #mapView .map-dock .map-surface {
    height: calc(100dvh - 96px - env(safe-area-inset-bottom, 0px));
    min-height: calc(100dvh - 96px - env(safe-area-inset-bottom, 0px));
    border-radius: 0;
  }
}

/* Tabler shell rebuild */
.tabler-app.dashboard-shell {
  background: var(--tblr-bg-surface-secondary, #f6f8fb);
}

.tabler-app .sidebar-shell {
  width: 15rem;
  min-width: 15rem;
  height: 100dvh;
  padding: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: #182433 !important;
  box-shadow: none;
}

.tabler-app .sidebar-header {
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.tabler-app .brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, var(--fire-red), var(--fire-orange));
  color: #fff;
  font-weight: 800;
}

.tabler-app #sideMenu {
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.tabler-app #sideMenu .navbar-nav {
  width: 100%;
  gap: 0.15rem;
  padding: 0.5rem;
}

.tabler-app .dashboard-link {
  width: 100%;
  min-width: 0;
  height: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 0;
  border-radius: var(--tblr-border-radius, 0.375rem);
  color: rgba(255, 255, 255, 0.76);
  text-align: left;
}

.tabler-app .dashboard-link .nav-link-icon {
  width: 1.35rem;
  min-width: 1.35rem;
  display: inline-flex;
  justify-content: center;
  font-size: 1.2rem;
}

.tabler-app .dashboard-link:hover,
.tabler-app .dashboard-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.tabler-app .dashboard-link.active {
  box-shadow: inset 3px 0 0 var(--fire-orange);
}

.tabler-app .sidebar-user {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.tabler-app .dashboard-main {
  min-width: 0;
  flex: 1 1 auto;
  height: 100dvh;
  overflow: hidden;
  background: transparent;
}

.tabler-app .topbar {
  min-height: 4.25rem;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 1rem;
  padding: 0.75rem 1rem !important;
  background: var(--tblr-bg-surface, #fff) !important;
  border-bottom: 1px solid var(--tblr-border-color, #dadfe5) !important;
  box-shadow: none;
}

.tabler-app .topbar-title {
  min-width: 0;
  margin: 0 !important;
}

.tabler-app .topbar-actions {
  width: auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tabler-app .topbar-actions .form-select {
  min-width: min(18rem, 42vw);
}

.tabler-app .dashboard-content {
  display: block;
  min-height: 0;
  overflow: auto;
}

.tabler-app .card {
  border-color: var(--tblr-border-color, #dadfe5);
  box-shadow: var(--tblr-box-shadow-card, 0 1px 2px rgba(0, 0, 0, 0.04));
}

.tabler-app .card-header.bg-white {
  background: var(--tblr-card-bg, #fff) !important;
  border-bottom-color: var(--tblr-border-color, #dadfe5);
}

.tabler-app .card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

@media (min-width: 992px) {
  .tabler-app .sidebar-shell {
    display: flex !important;
    flex-direction: column !important;
  }

  .tabler-app #sideMenu.collapse {
    display: flex !important;
    flex-direction: column !important;
  }

  .tabler-app .dashboard-link {
    justify-content: flex-start !important;
    padding: 0.65rem 0.85rem !important;
  }

  .tabler-app .dashboard-link .sidebar-label,
  .tabler-app .sidebar-brand .sidebar-label {
    display: inline !important;
    opacity: 1;
  }

  .tabler-app .sidebar-user {
    width: 100%;
    margin-top: auto;
  }

  .tabler-app #logoutBtn {
    width: 100% !important;
  }

  .tabler-app #mapView.active {
    min-height: calc(100dvh - 7.25rem);
  }

  .tabler-app #mapView.active > .card {
    min-height: calc(100dvh - 8.5rem);
    display: flex;
    flex-direction: column;
  }

  .tabler-app #mapView .map-dock {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem !important;
  }

  .tabler-app #mapView .map-surface,
  .tabler-app #mapView .map-dock .map-surface {
    height: calc(100dvh - 15rem);
    min-height: 32rem;
  }
}

@media (max-width: 991.98px) {
  .tabler-app.dashboard-shell {
    height: auto;
    min-height: 100dvh;
    display: block;
    overflow: visible;
    padding-bottom: 0;
  }

  .tabler-app .sidebar-shell,
  .tabler-app .sidebar-shell.sidebar-narrow {
    position: sticky !important;
    inset: 0 auto auto 0 !important;
    z-index: 1040;
    width: 100% !important;
    min-width: 0;
    height: auto !important;
    display: block !important;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 0.5rem 1.5rem rgba(24, 36, 51, 0.16);
  }

  .tabler-app .sidebar-header,
  .tabler-app .sidebar-shell.sidebar-narrow .sidebar-header {
    display: flex !important;
    flex-direction: row;
    min-height: 3.25rem;
    padding: 0.35rem 0.75rem !important;
  }

  .tabler-app .brand-mark {
    width: 2rem;
    height: 2rem;
    font-size: 0.78rem;
  }

  .tabler-app .sidebar-shell .sidebar-label,
  .tabler-app .sidebar-shell.sidebar-narrow .sidebar-label {
    display: inline !important;
  }

  .tabler-app #sideMenu {
    overflow: visible;
  }

  .tabler-app #sideMenu.collapse:not(.show) {
    display: none !important;
  }

  .tabler-app #sideMenu.show {
    display: block !important;
  }

  .tabler-app #sideMenu .navbar-nav {
    padding: 0.25rem 0.75rem 0.75rem !important;
  }

  .tabler-app .sidebar-shell .dashboard-link,
  .tabler-app .sidebar-shell.sidebar-narrow .dashboard-link {
    width: 100%;
    min-width: 0;
    height: auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.65rem !important;
    padding: 0.55rem 0.65rem !important;
    border-radius: 0.5rem;
  }

  .tabler-app .dashboard-main {
    width: 100%;
    min-height: 0;
    height: auto;
    display: block;
    overflow: visible;
  }

  .tabler-app .topbar {
    position: sticky;
    top: 3.25rem;
    z-index: 1030;
    min-height: 0;
    display: grid !important;
    flex-direction: initial !important;
    grid-template-columns: minmax(0, 1fr) clamp(8.5rem, 42vw, 13rem);
    gap: 0.5rem !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0.35rem 0.75rem !important;
  }

  .tabler-app .topbar.topbar-without-group {
    grid-template-columns: minmax(0, 1fr);
  }

  .tabler-app .topbar-title {
    grid-column: 1;
    min-width: 0;
  }

  .tabler-app .topbar.topbar-without-group .topbar-title {
    grid-column: 1 / -1;
  }

  .tabler-app .topbar h2 {
    font-size: 1.08rem;
    line-height: 1.05;
  }

  .tabler-app .topbar-actions {
    grid-column: 2;
    width: 100%;
    min-width: 0;
    margin-left: 0;
    display: block;
  }

  .tabler-app .topbar-actions .form-select {
    min-width: 0;
    width: 100%;
    min-height: 2rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.9rem;
  }

  .tabler-app .dashboard-content {
    margin-top: 0 !important;
    padding: 0.25rem 0.75rem 0.75rem !important;
    overflow: visible;
  }

  .tabler-app .kpi-row {
    margin-top: 0 !important;
    margin-bottom: 0.45rem !important;
  }
}

@media (min-width: 992px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .dashboard-shell {
    height: 100vh;
    height: 100dvh;
    display: flex;
    overflow: hidden;
    padding-bottom: 0;
  }
}

/* Boundary editing keeps its compact confirmation toolbar above the map. */
#mapDock {
  position: relative;
}

#boundaryMapToolbar {
  position: absolute;
  top: 0.65rem !important;
  right: 0.65rem;
  left: auto;
  z-index: 50;
  padding: 0.5rem;
  border: 1px solid rgba(32, 37, 43, 0.14);
  border-top: 3px solid var(--fire-orange);
  border-radius: var(--tblr-border-radius);
  background: rgba(255, 250, 240, 0.98);
  box-shadow: 0 18px 36px rgba(32, 37, 43, 0.24);
}

@media (max-width: 991.98px) {
  .tabler-app .sidebar-shell,
  .tabler-app .sidebar-shell.sidebar-narrow {
    overflow: visible !important;
  }

  .tabler-app #sideMenu.collapsing,
  .tabler-app #sideMenu.collapse.show {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 1050;
    max-height: calc(100dvh - 3.75rem);
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--sidebar-bg, #182433);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 1rem 2rem rgba(24, 36, 51, 0.28);
  }
}

/* Role visibility must win over legacy navigation display utilities. */
.tabler-app .admin-only.d-none {
  display: none !important;
}

/* Keep mobile navigation available while the operational content scrolls. */
@media (max-width: 991.98px) {
  .tabler-app {
    --mobile-nav-height: 3.75rem;
    --mobile-topbar-height: 3.25rem;
  }

  .tabler-app .notification-menu.show {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - var(--mobile-nav-height) - var(--mobile-topbar-height) - 0.5rem);
    overflow: hidden;
  }

  .tabler-app .notification-menu.show .notification-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .tabler-app .sidebar-shell,
  .tabler-app .sidebar-shell.sidebar-narrow {
    position: fixed !important;
    inset: 0 0 auto 0 !important;
    height: var(--mobile-nav-height) !important;
  }

  .tabler-app .sidebar-header,
  .tabler-app .sidebar-shell.sidebar-narrow .sidebar-header {
    height: var(--mobile-nav-height);
    min-height: var(--mobile-nav-height);
  }

  .tabler-app .dashboard-main {
    padding-top: calc(var(--mobile-nav-height) + var(--mobile-topbar-height));
  }

  .tabler-app .topbar {
    position: fixed !important;
    inset: var(--mobile-nav-height) 0 auto 0;
    min-height: var(--mobile-topbar-height);
    z-index: 1030;
  }
}

/* Native iOS map: controls and actions stay on the map, clear of Google attribution. */
.native-map-surface .native-map-overlay { position:absolute; inset:0; z-index:1000; pointer-events:none; transform:translateZ(0); }
.native-map-controls { position:absolute; inset:0; pointer-events:none; }
.native-map-overlay .fire-spread-signal { z-index:0; }
.native-map-controls { z-index:1; }
.native-map-controls button,.native-map-controls select { pointer-events:auto; box-shadow:0 1px 4px #0004; }
.native-map-type-label { position:absolute; top:10px; left:10px; max-width:calc(100% - 78px); }
.native-fullscreen { position:absolute; top:10px; right:10px; min-width:42px; min-height:42px; }
.native-map-zoom { position:absolute; right:10px; bottom:70px; }
.boundary-centre-control { min-width:44px; min-height:44px; margin:10px; font-size:22px; box-shadow:0 1px 4px #0004; }
#firmsRefreshStatus { flex-shrink:0; }
.native-map-controls .boundary-centre-control { position:absolute; left:10px; bottom:70px; margin:0; }
.native-map-zoom button { min-width:42px; min-height:42px; font-size:22px; }
.native-map-surface .native-map-details { position:absolute; width:min(320px,calc(100% - 16px)); padding:12px; border-radius:8px; background:var(--bs-body-bg,#fff); pointer-events:auto; overflow:auto; z-index:1020; }
.native-map-details .btn-close { margin:0 0 8px 8px; }
#mapContextMenu.native-map-context-menu { position:absolute; width:max-content; max-width:calc(100% - 16px); margin:0; overflow:auto; pointer-events:auto; z-index:1030; }
.native-map-message { position:absolute; bottom:36px; left:8px; right:8px; background:var(--bs-body-bg,#fff); }
.native-map-message:empty { display:none; }
#map.native-map-fullscreen { position:fixed !important; inset:0 !important; width:100vw !important; height:100dvh !important; min-height:0 !important; z-index:1050; border-radius:0; }
body.native-map-expanded { overflow:hidden !important; }
.native-map-fullscreen .native-map-type-label,.native-map-fullscreen .native-fullscreen { top:max(10px,env(safe-area-inset-top)); }
