
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Segoe UI, Arial, sans-serif; background: #f5f7fb; color: #18263a; }
.app-header { padding: 14px 18px; background: #fff; border-bottom: 1px solid #dfe6ef; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.app-header h1 { margin: 0; font-size: 22px; }
.app-header p { margin: 4px 0 0; color: #4b6078; }
.app-header nav { display: flex; gap: 10px; align-items: center; }
.app-header a { text-decoration: none; background: #eaf2fb; color: #1d5da0; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(245, 249, 255, 0.88);
  display: grid;
  place-items: center;
  padding: 16px;
}
.app-loading[hidden] { display: none !important; }
.app-loading-card {
  width: min(420px, 94vw);
  background: #fff;
  border: 1px solid #d8e5f5;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(24, 46, 78, 0.12);
  padding: 14px;
}
.app-loading-title { font-weight: 700; color: #1d4f84; margin-bottom: 6px; }
.app-loading-status { color: #48617c; font-size: 13px; }
.app-loading-progress {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: #e8f0fb;
  overflow: hidden;
}
.app-loading-progress span {
  display: block;
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, #2a6ebb, #4b8fd8);
  transition: width .18s ease;
}
.search-status {
  position: fixed;
  top: 74px;
  right: 14px;
  z-index: 4200;
  pointer-events: none;
}
.search-status[hidden] { display: none !important; }
.search-status-card {
  width: min(360px, 92vw);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #d7e5f6;
  border-radius: 11px;
  box-shadow: 0 8px 22px rgba(18, 43, 74, 0.14);
  padding: 10px 11px;
}
.search-status-text {
  font-size: 13px;
  font-weight: 650;
  color: #1f4f85;
}
.search-status-metrics {
  margin-top: 4px;
  font-size: 11px;
  color: #5a6f88;
}
body.app-loading-active { overflow: hidden; }
.layout { padding: 14px; display: grid; grid-template-columns: 350px 1fr; gap: 12px; }
.layout > * { min-width: 0; }
.panel { background: #fff; border: 1px solid #dfe6ef; border-radius: 12px; padding: 12px; }
.panel { min-width: 0; }
.controls {
  grid-row: span 4;
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 24px);
  overflow: auto;
}
.controls h2, .panel h2 { margin: 0 0 10px; font-size: 16px; }
label { display: block; font-size: 13px; margin-bottom: 10px; color: #31445c; }
input, select, button { width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #ccd7e6; border-radius: 8px; font: inherit; font-size: 14px; }
select {
  -webkit-appearance: menulist;
  appearance: auto;
  background-color: #fff;
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.muted { color: #687d95; font-size: 12px; }
.search-input-wrap {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-input-wrap input {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.enter-search-inline {
  display: none;
  width: auto;
  margin-top: 0;
  padding: 8px 10px;
  white-space: nowrap;
  background: #eaf2fb;
  color: #1d5da0;
  border-color: #c8dff4;
  font-weight: 600;
  transition: transform .08s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}
.enter-search-action {
  background: #eaf2fb;
  color: #1d5da0;
  border-color: #c8dff4;
  font-weight: 600;
  transition: transform .08s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}
.enter-search-action:hover,
.enter-search-inline:hover {
  background: #dfeeff;
  border-color: #9ec6ef;
  box-shadow: 0 2px 8px rgba(42, 110, 187, 0.16);
}
.enter-search-action:focus-visible,
.enter-search-inline:focus-visible {
  outline: 2px solid #7fb0e5;
  outline-offset: 1px;
}
.enter-search-action:active,
.enter-search-inline:active {
  transform: translateY(1px) scale(0.995);
  background: #d3e7ff;
}
.enter-search-action[data-searching="1"],
.enter-search-inline[data-searching="1"] {
  cursor: wait;
  opacity: 0.85;
  box-shadow: none;
}
.controls-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.controls-actions button { margin-top: 0; }
#resetFilters {
  background: #fff4f2;
  border-color: #f0c8c0;
  color: #9a3a2c;
  font-weight: 600;
  transition: transform .08s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}
#resetFilters:hover {
  background: #ffeae6;
  border-color: #e6a89b;
  box-shadow: 0 2px 8px rgba(173, 76, 54, 0.16);
}
#resetFilters:focus-visible {
  outline: 2px solid #e58a75;
  outline-offset: 1px;
}
#resetFilters:active {
  transform: translateY(1px) scale(0.995);
  background: #ffdcd5;
}
#resetFilters[data-resetting="1"] {
  cursor: wait;
  opacity: 0.85;
  box-shadow: none;
}
.app-meta-footer {
  margin: 0 14px 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  background: #fff;
  border: 1px solid #dfe6ef;
  border-radius: 12px;
}
.app-meta-footer .muted { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.kpi {
  background: #f7fbff;
  border: 1px solid #d9e6f7;
  border-radius: 999px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
}
.kpi .v { font-size: 15px; font-weight: 700; color: #12487f; line-height: 1; }
.kpi .l { font-size: 11px; color: #4f647c; white-space: nowrap; }
#map { height: 360px; border-radius: 10px; }
.chart-panel { height: auto; }
.chart-mode { display: flex; gap: 14px; flex-wrap: wrap; margin: 2px 0 10px; font-size: 12px; color: #364d66; }
.chart-mode label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.chart-mode input { width: auto; margin: 0; }
.chart-wrap { height: clamp(220px, 34vh, 320px); overflow: hidden; position: relative; }
#trendChart { width: 100% !important; height: 100% !important; display: block; }
.table-wrap { max-width: 100%; overflow-x: auto; overflow-y: auto; max-height: 420px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 7px 8px; border-bottom: 1px solid #edf2f7; text-align: left; white-space: nowrap; }
thead th { position: sticky; top: 0; background: #f7fbff; z-index: 1; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.pager button { width: auto; }
.toggle-advanced { display: none; background: #eef5ff; color: #1d5da0; border-color: #c8dff4; font-weight: 600; font-size: 13px; }
.toggle-advanced:hover { background: #e0efff; }
.advanced-filters { margin-top: 10px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .controls { grid-row: auto; position: static; top: auto; max-height: none; overflow: visible; }
  .layout { padding: 12px; }
  .app-header { padding: 12px 14px; }
  .app-header nav { flex-wrap: wrap; }
  .toggle-advanced { display: block; }
  .enter-search-action { display: none; }
  .enter-search-inline { display: inline-flex; align-items: center; justify-content: center; }
  .advanced-filters { display: none; }
  .advanced-filters.show { display: block; }
  #map { height: 320px; }
  .chart-panel { height: auto; }
  .chart-wrap { height: clamp(220px, 32vh, 300px); }
  .table-wrap { max-height: 360px; }
  .kpis { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}
@media (max-width: 768px) {
  .layout { padding: 10px; gap: 10px; }
  .panel { padding: 10px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .enter-search-inline { display: none; }
  .enter-search-action { display: block; }
  .controls-actions { grid-template-columns: 1fr 1fr; }
  .toggle-advanced { grid-column: 1 / -1; }
  .app-meta-footer { margin: 0 10px 10px; flex-direction: column; align-items: flex-start; gap: 6px; }
  .app-header { gap: 10px; }
  .app-header h1 { font-size: 20px; }
  .app-header p { font-size: 13px; }
  .app-header nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-header a { white-space: nowrap; }
  .advanced-filters { display: none; }
  .advanced-filters.show { display: block; }
  #map { height: 280px; }
  .chart-panel { height: auto; }
  .chart-wrap { height: 250px; }
  .table-wrap { max-height: 300px; -webkit-overflow-scrolling: touch; }
  table { font-size: 11px; }
  th, td { padding: 6px 7px; }
  #txTable th:nth-child(3), #txTable td:nth-child(3),
  #txTable th:nth-child(4), #txTable td:nth-child(4),
  #txTable th:nth-child(6), #txTable td:nth-child(6),
  #txTable th:nth-child(9), #txTable td:nth-child(9),
  #txTable th:nth-child(10), #txTable td:nth-child(10),
  #txTable th:nth-child(12), #txTable td:nth-child(12) { display: none; }
  .pager { justify-content: space-between; flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .layout { padding: 8px; gap: 8px; }
  .panel { padding: 9px; border-radius: 10px; }
  .app-meta-footer { margin: 0 8px 8px; padding: 9px; border-radius: 10px; }
  label { font-size: 12px; }
  input, select, button { padding: 7px 9px; font-size: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 6px; }
  .kpi .v { font-size: 18px; }
  #map { height: 240px; }
  .chart-panel { height: auto; }
  .chart-wrap { height: 220px; }
  .table-wrap { max-height: 260px; }
  #txTable th:nth-child(2), #txTable td:nth-child(2) { display: none; }
  .search-status {
    right: 8px;
    top: 66px;
  }
  .search-status-card {
    width: min(320px, calc(100vw - 16px));
    padding: 8px 10px;
  }
}
