:root {
  --rogers-red: #e1251b;
  --page-bg: #f3f6fa;
  --surface: #ffffff;
  --text: #172033;
  --text-strong: #0f172a;
  --muted: #64748b;
  --border: #d8e0ea;
  --border-strong: #c3cfdd;
  --red: #d71920;
  --orange: #ff7a00;
  --yellow: #ffd400;
  --green: #087f3f;
  --blue: #1d5fa7;
  --clear: #087f3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page-bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

button,
select,
textarea,
input {
  font-family: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  min-height: 56px;
  padding: 8px 18px;
  background: #ffffff;
  border-bottom: 3px solid var(--rogers-red);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}

.brand-block {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-block h1 {
  margin: 0;
  color: var(--rogers-red);
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.brand-block .eyebrow {
  display: none;
}

.brand-block p {
  margin: 0;
  color: #334155;
  font-size: 15px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.primary-btn,
.secondary-btn {
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  min-height: 34px;
}

.primary-btn {
  color: #ffffff;
  background: #0ea5e9;
  border-color: #0284c7;
}

.primary-btn:hover {
  background: #0284c7;
}

.secondary-btn {
  color: var(--rogers-red);
  background: #ffffff;
  border-color: var(--rogers-red);
}

.secondary-btn:hover {
  background: #fff5f5;
}

.alert-strip {
  margin: 14px 18px 0;
  padding: 13px 15px;
  background: #dcecff;
  border: 1px solid #8ec5ff;
  border-left: 4px solid #0ea5e9;
  border-radius: 8px;
  color: #123867;
  line-height: 1.45;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.alert-strip strong {
  color: #004a98;
}

.top-filters {
  display: grid;
  grid-template-columns: minmax(170px, 0.9fr) minmax(240px, 1.2fr) minmax(210px, 1fr) minmax(190px, 0.9fr);
  gap: 12px;
  align-items: end;
  margin: 14px 18px 0;
  padding: 13px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.top-filters .field {
  margin: 0;
  min-width: 0;
  max-width: none;
  width: 100%;
}

label {
  display: block;
  margin: 0 0 6px;
  color: #526174;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

select,
textarea,
input {
  width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

.top-filters select {
  height: 36px;
}

select:focus,
textarea:focus,
input:focus {
  border-color: #5aa7e8;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

.summary-strip {
  margin: 14px 18px 0;
}

.summary-strip .summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.summary-card {
  position: relative;
  display: block;
  min-height: 78px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--blue);
}

.summary-card.red::before {
  background: var(--red);
}

.summary-card.orange::before {
  background: var(--orange);
}

.summary-card.yellow::before {
  background: var(--yellow);
}

.summary-card.clear::before {
  background: var(--green);
}

.summary-card.blue::before {
  background: var(--blue);
}

.summary-card .value {
  margin: 3px 0 4px;
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
  color: var(--text-strong);
}

.summary-card.red .value {
  color: var(--red);
}

.summary-card.orange .value {
  color: var(--orange);
}

.summary-card.yellow .value {
  color: #a16207;
}

.summary-card.clear .value {
  color: var(--green);
}

.summary-card.blue .value {
  color: var(--blue);
}

.summary-card .label {
  color: #475569;
  font-size: 12px;
  line-height: 1.3;
}

.summary-placeholder {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-full {
  display: block;
  padding: 14px 18px 18px;
}

.main-content-full {
  display: grid;
  gap: 14px;
  width: 100%;
}

.map-card {
  position: relative;
  width: min(100%, 1180px);
  margin-left: auto;
  margin-right: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.map-toolbar {
  min-height: 56px;
  padding: 10px 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-toolbar h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 800;
}

.map-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

#map {
  display: block;
  width: 100%;
  height: 430px;
  min-height: 430px;
  background: #dbe7f3;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: #dbe7f3;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.leaflet-control-zoom a {
  color: var(--text-strong);
}

.status-badge {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 902;
  max-width: 360px;
  width: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.map-toolbar .legend {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 901;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: -1px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.dot.red {
  background: var(--red);
}

.dot.orange {
  background: var(--orange);
  border: 1px solid #b54700;
}

.dot.yellow {
  background: var(--yellow);
  border: 1px solid #9a6b00;
}

.dot.clear {
  background: var(--green);
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

.leaflet-popup-content {
  margin: 12px 14px;
  color: var(--text);
  min-width: 240px;
}

.popup-title {
  margin-bottom: 4px;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 800;
}

.popup-meta {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
  margin-top: 10px;
}

.popup-grid div {
  font-size: 12px;
  line-height: 1.35;
}

.popup-grid strong {
  color: var(--muted);
}

.table-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  margin-top: 14px;
}

.table-title-row {
  padding: 13px 15px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.table-title-row h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 800;
}

.table-title-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.table-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 30px;
  padding: 0 10px;
  background: #eff7ff;
  border: 1px solid #8ec5ff;
  color: #004a98;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.table-scroll {
  overflow-y: auto;
  overflow-x: auto;
  max-height: 680px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #526174;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

tbody tr {
  height: 38px;
}

tbody tr:hover {
  background: #f8fbff;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
}

.badge.red {
  background: #ffe8e8;
  color: var(--red);
  border-color: #ffb4b4;
}

.badge.orange {
  background: #fff1df;
  color: #9a3412;
  border-color: var(--orange);
}

.badge.yellow {
  background: #fff8bf;
  color: #713f12;
  border-color: var(--yellow);
}

.badge.clear {
  background: #e8fff1;
  color: var(--green);
  border-color: #86efac;
}

dialog {
  width: min(920px, 94vw);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-card {
  display: grid;
  gap: 12px;
}

.dialog-card h2 {
  margin: 0;
  color: var(--text-strong);
}

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

#thresholdText {
  min-height: 520px;
  resize: vertical;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.error-box {
  background: #fff1f1;
  border: 1px solid #ffb4b4;
  color: #991b1b;
  border-radius: 8px;
  padding: 12px;
}

@media (max-width: 1200px) {
  .status-badge {
    max-width: 300px;
  }
}

@media (max-width: 1100px) {
  .top-filters {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .summary-strip .summary-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 900px) {
  .map-card {
    width: 100%;
  }

  #map {
    height: 390px;
    min-height: 390px;
  }

  .status-badge {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
    text-align: center;
  }

  .map-toolbar .legend {
    left: 14px;
    right: 14px;
    bottom: 56px;
    transform: none;
    justify-content: center;
  }
}

@media (max-width: 700px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .header-actions button {
    flex: 1;
  }

  .top-filters {
    grid-template-columns: 1fr;
  }

  .summary-strip .summary-grid {
    grid-template-columns: 1fr;
  }
}
