:root {
  --radius: 12px;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #d9e2f0;
  --accent: #0b57d0;
  --good: #1e8e3e;
  --medium: #f29900;
  --bad: #d93025;
  --unknown: #9aa0a6;
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  --color-primary: #10b981;
  --color-primary-dark: #059669;
  --color-good: #22c55e;
  --color-moderate: #eab308;
  --color-bad: #ef4444;
  --color-unknown: #9ca3af;
  --header-height: 56px;
  --sidebar-width: 420px;  
  
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f9fafb;
  color: #111827;
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Header */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  z-index: 2000;
}

.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  max-width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: #374151;
}

.menu-btn:hover {
  background: #f3f4f6;
}

.logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #34d399, #10b981);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
  flex-shrink: 0;
}

.logo-icon {
  width: 22px;
  height: 22px;
  color: white;
}

.header-title {
  min-width: 0;
}

.header-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
}

.header-title p {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
}

.update-time {
  font-weight: 600;
  color: #374151;
}

/* Layout */


.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas: "sidebar map";
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
  overflow: hidden;
  background: var(--bg);
}


.sidebar {
  grid-area: sidebar;
  position: relative;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 900;
  overflow: hidden;
}

.map-wrap {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

/* Filters */

.filters {
  padding: 16px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.search-container {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9ca3af;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 12px 0 40px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  background: white;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.search-input::placeholder {
  color: #9ca3af;
}

.select-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.select-input:focus {
  background-color: white;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.update-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.update-btn:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.update-btn:active {
  transform: scale(0.98);
}

.update-btn .icon {
  width: 18px;
  height: 18px;
}

/* Marker label settings */

.label-settings {
  background: #fff;
  border-radius: 12px;
  padding: 10px 16px 14px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

.label-settings-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
}

.check-row input {
  width: auto;
  margin: 0;
}

/* Status */

.status {
  margin: 14px 16px 0;
  padding: 12px;
  border-radius: 10px;
  background: #e8f0fe;
  color: #174ea6;
  display: none;
  font-size: 14px;
  flex-shrink: 0;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
  font-weight: 500;
  color: #047857;
  flex-shrink: 0;
}

/* Legend chips */

.legend {
  margin: 14px 16px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* List */

.list {
  padding: 14px 16px 18px;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.panel-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 10px 12px;
  width: 100%;
  height: 48px;

  border: none;
  border-radius: 12px;

  background: linear-gradient(135deg, #1f2937, #000000);
  color: white;

  font-size: 15px;
  font-weight: 600;
  font-family: inherit;

  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);

  margin-bottom: 10px;
}

.panel-back-btn.visible {
  display: flex;
}

.panel-back-btn .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Station cards */

.station-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.station-card:hover {
  transform: translateY(-1px);
}

.station-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(11, 87, 208, 0.12), var(--shadow);
}

.station-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.station-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.station-code {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.badge {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge.good {
  background: var(--good);
}

.badge.medium {
  background: var(--medium);
}

.badge.bad {
  background: var(--bad);
}

.badge.unknown {
  background: var(--unknown);
}

.station-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 8px;
}

/* Station sections */

.station-sections {
  display: grid;
  gap: 8px;
}

.station-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #fbfdff;
}

.station-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.mini-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 7px;
  background: #f8fbff;
  min-width: 0;
}

.mini-label {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  line-height: 1.2;
}

.mini-value {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
}

.mini-value.good {
  color: var(--good);
}

.mini-value.medium {
  color: var(--medium);
}

.mini-value.bad {
  color: var(--bad);
}

.mini-value.unknown {
  color: var(--unknown);
}

/* Progress */

.mini-progress {
  margin-top: 4px;
}

.mini-progress-bar {
  position: relative;
  height: 4px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  border-radius: 999px;
}

.mini-progress-fill.good {
  background: var(--good);
}

.mini-progress-fill.medium {
  background: var(--medium);
}

.mini-progress-fill.bad {
  background: var(--bad);
}

.mini-progress-fill.unknown {
  background: var(--unknown);
}

.mini-progress-threshold {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 8px;
  background: #111827;
  border-radius: 2px;
  transform: translateX(-50%);
}

.mini-progress-scale {
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
}

/* Mini chart */

.air-chart {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #fbfdff;
  margin-bottom: 8px;
}

.air-chart-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.air-chart-bars {
  height: 56px;
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 2px;
  align-items: end;
}

.air-chart-bar {
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  opacity: 0.95;
}

.air-chart-empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.air-chart-axis {
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}

/* Map */

.leaflet-top.leaflet-left {
  top: 12px;
  left: 12px;
}

.map-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 500;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--muted);
  max-width: 360px;
}

.map-overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.map-overlay-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.overlay-icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.overlay-icon-btn:hover {
  background: #f3f4f6;
}

.overlay-icon-btn svg {
  width: 18px;
  height: 18px;
}

.hidden {
  display: none !important;
}

/* Marker */

.marker-wrap {
  position: relative;
  width: 54px;
  height: 54px;
}

.marker-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
}

.marker-ring.r1 {
  width: 54px;
  height: 54px;
  opacity: 0.10;
}

.marker-ring.r2 {
  width: 38px;
  height: 38px;
  opacity: 0.18;
}

.marker-ring.r3 {
  width: 26px;
  height: 26px;
  opacity: 0.28;
}

.marker-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.marker-label {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  box-shadow: var(--shadow);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.marker-label.hidden {
  display: none;
}

/* Pollutant legend overlay */

.pollutant-legend {
  position: absolute;
  right: 12px;
  bottom: 64px;
  z-index: 500;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
  width: 230px;
  max-width: calc(100vw - 24px);
}

.pollutant-legend-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.pollutant-legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.pollutant-legend-list.hidden {
  display: none;
}

.pollutant-legend-item {
  font-size: 12px;
  line-height: 1.35;
  padding-left: 18px;
  position: relative;
}

.pollutant-legend-item b {
  font-size: 13px;
  color: var(--text);
}

.pollutant-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 0;
  top: 3px;
}

/* Mobile */

@media (max-width: 980px) {
  :root {
    --header-height: 52px;
    --sidebar-width: min(360px, 92vw);
  }
 
 .app {
  grid-template-columns: 1fr;
  grid-template-areas: "map";
  height: calc(100dvh - var(--header-height));
  margin-top: var(--header-height);
}

  .leaflet-control-container,
  .leaflet-top,
  .leaflet-bottom,
  .leaflet-control,
  .leaflet-bar,
  .leaflet-control-layers {
    z-index: 800 !important;
  }

  .header {
    height: var(--header-height);
    z-index: 2000;
  }

  .header-content {
    padding: 0 0px;
  }

  .menu-btn {
    display: flex;
  }

  .logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .logo-icon {
    width: 18px;
    height: 18px;
  }

  .header-title h1 {
    font-size: 16px;
  }

  .header-title p {
    font-size: 11px;
  }

  .header-right {
    font-size: 11px;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100dvh - var(--header-height));
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1900;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  }

  .sidebar:not(.mobile-hidden) {
    transform: translateX(0);
  }

  .sidebar.mobile-hidden {
    transform: translateX(-100%);
  }

  .filters {
    padding: 10px 12px;
    gap: 8px;
  }

  .label-settings {
    padding: 10px 12px 12px;
  }

  .label-settings-title {
    font-size: 11px;
  }

  .check-row {
    font-size: 12px;
  }

  .stats-bar {
    padding: 10px 12px;
    font-size: 12px;
  }

  .status {
    margin: 10px 12px 0;
    padding: 10px;
    font-size: 12px;
  }

  .legend {
    margin: 10px 12px 0;
    gap: 6px;
  }

  .legend span {
    font-size: 11px;
    padding: 5px 8px;
  }

  .list {
    padding: 10px 12px 12px;
  }

  .station-card {
    padding: 8px;
    margin-bottom: 8px;
  }

  .station-title {
    font-size: 14px;
  }

  .station-meta {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .mini-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .mini-item {
    padding: 5px 6px;
  }

  .mini-label {
    font-size: 9px;
  }

  .mini-value {
    font-size: 12px;
  }

  .leaflet-top.leaflet-left {
    top: 10px;
    left: 10px;
  }

  .map-overlay {
    top: 8px;
    right: 8px;
    max-width: 250px;
    font-size: 11px;
    padding: 8px 10px;
  }
  
  .map-overlay-head {
    gap: 8px;
    margin-bottom: 8px;
  }

  .overlay-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .overlay-icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .marker-label {
    left: 50%;
    top: 10px;
    transform: translate(-50%, -100%);
    font-size: 10px;
    padding: 3px 4px;
    max-width: 110px;
    text-align: center;
  }

  .pollutant-legend {
    right: 10px;
    bottom: 64px;
    width: 200px;
    max-width: calc(100vw - 20px);
    padding: 8px 10px;
  }

  .pollutant-legend-item {
    font-size: 11px;
    line-height: 1.3;
  }
}