:root {
  --navy: #0e2a47;
  --navy-deep: #091d33;
  --navy-soft: #1b4168;
  --gold: #b8963e;
  --gold-soft: #f4ecd9;
  --canvas: #f4f5f7;
  --panel: #ffffff;
  --line: #dde2e8;
  --ink: #17212b;
  --muted: #5b6876;
  --rain: #1f5fbf;
  --water: #0f7f76;
  --air: #6b3fb5;
  --alert: #c2521a;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Vazirmatn", "Noto Sans Arabic", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.8;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  text-decoration: none;
}

.identity img {
  width: auto;
  height: 58px;
}

.identity-text {
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

.identity-text small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.identity-text strong {
  color: var(--navy);
  font-size: 20px;
  font-weight: 800;
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.tab {
  font: inherit;
  font-weight: 700;
  font-size: 15.5px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 10px 18px 7px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--navy);
}

.tab[aria-selected="true"] {
  color: var(--navy);
  border-bottom-color: var(--gold);
}

.tab:focus-visible,
.filter:focus-visible,
.retry:focus-visible,
.identity:focus-visible,
.footer a:focus-visible {
  outline: 3px solid rgba(184, 150, 62, 0.65);
  outline-offset: 2px;
}

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy) 60%, var(--navy-soft) 100%);
  color: #fff;
  padding: 64px 0 104px;
}

.hero::after {
  content: "";
  position: absolute;
  inset-block: -40px;
  inset-inline-end: -60px;
  width: 520px;
  background: url("logo.png") center / contain no-repeat;
  opacity: 0.07;
  pointer-events: none;
}

.hero .container {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(26px, 4.4vw, 40px);
  font-weight: 800;
  line-height: 1.55;
  max-width: 760px;
}

.hero p {
  margin-top: 16px;
  max-width: 680px;
  color: #d3dde8;
  font-size: 17px;
  line-height: 2;
}

.page-title {
  background: var(--navy);
  color: #fff;
  padding: 28px 0;
}

.page-title h2 {
  font-size: 24px;
  font-weight: 800;
}

.page-title p {
  color: #c5d1de;
  font-size: 14.5px;
}

.panel {
  padding: 32px 0 64px;
}

.panel[data-panel="about"] {
  padding-top: 0;
}

.section-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--navy);
  margin: 44px 0 16px;
  padding-inline-start: 14px;
  border-inline-start: 4px solid var(--gold);
  line-height: 1.5;
}

.stats {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: -52px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(9, 29, 51, 0.08);
}

.stat {
  padding: 22px 16px;
  text-align: center;
  border-inline-start: 1px solid var(--line);
}

.stat:first-child {
  border-inline-start: 0;
}

.stat strong {
  display: block;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--navy);
}

.stat span {
  color: var(--muted);
  font-size: 14px;
}

.lead {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  font-size: 16.5px;
  line-height: 2.15;
  text-align: justify;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.filter {
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-inline-start: 1px solid var(--line);
  padding: 7px 20px;
  cursor: pointer;
}

.filter:first-child {
  border-inline-start: 0;
}

.filter:hover {
  color: var(--navy);
}

.filter[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
}

.updated {
  color: var(--muted);
  font-size: 13.5px;
}

.state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.retry {
  display: block;
  margin: 14px auto 0;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: 6px;
  padding: 7px 24px;
  cursor: pointer;
}

.stations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
  align-items: start;
}

.station {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.station-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}

.station-head h3 {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--navy);
}

.station-head small {
  color: var(--muted);
  font-size: 12.5px;
}

.station-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
}

.station-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tone-rain {
  color: var(--rain);
  background: #e6eefa;
}

.tone-water {
  color: var(--water);
  background: #e0f1ef;
}

.tone-air {
  color: var(--air);
  background: #ede7f8;
}

.tone-alert {
  color: var(--alert);
  background: #f9e9df;
}

.readings {
  list-style: none;
  margin: 0;
  padding: 4px 16px;
}

.reading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf0f3;
}

.reading:last-child {
  border-bottom: 0;
}

.reading-label {
  font-size: 14.5px;
  min-width: 0;
}

.reading-label small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.reading-label.technical {
  font-weight: 700;
}

.reading-label.technical small {
  font-weight: 400;
}

.reading-value {
  direction: ltr;
  white-space: nowrap;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}

.reading-value small {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  margin-inline-start: 4px;
}

.level {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-inline-end: 6px;
}

.empty {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 14px;
}

.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.dot,
.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
}

.dot {
  width: 26px;
  height: 26px;
}

.dot svg,
.pin svg {
  width: 58%;
  height: 58%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map {
  height: min(72vh, 640px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #e3e8ee;
}

.pin {
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(9, 29, 51, 0.45);
  transition: transform 0.15s;
}

.pin:hover {
  transform: scale(1.12);
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
}

.leaflet-popup-content {
  direction: rtl;
  text-align: right;
  margin: 14px 16px;
  min-width: 210px;
}

.popup h3 {
  font-size: 15px;
  line-height: 1.6;
  color: var(--navy);
}

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

.popup .readings {
  padding: 4px 0 0;
}

.popup .reading {
  padding: 5px 0;
}

.popup .reading-value {
  font-size: 15px;
}

.footer {
  background: var(--navy-deep);
  color: #c5d1de;
  font-size: 14.5px;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  padding-block: 36px;
}

.footer-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-identity img {
  width: auto;
  height: 64px;
  padding: 6px 8px;
  background: #fff;
  border-radius: 6px;
}

.footer-identity strong {
  display: block;
  color: #fff;
  font-size: 17px;
}

.footer h4 {
  margin: 0 0 6px;
  color: #e7d3a0;
  font-size: 14px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer a {
  color: #fff;
  text-decoration: none;
  direction: ltr;
  text-align: right;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-bottom a {
  color: inherit;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-block: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #9fb0c2;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat:nth-child(3) {
    border-inline-start: 0;
  }

  .stat:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .hero::after {
    display: none;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }

  .masthead-inner {
    gap: 0;
  }

  .identity img {
    height: 48px;
  }

  .tabs {
    width: 100%;
    border-top: 1px solid var(--line);
  }

  .tab {
    flex: 1;
    padding-inline: 6px;
  }

  .hero {
    padding: 40px 0 88px;
  }

  .filters {
    display: flex;
    width: 100%;
  }

  .filter {
    flex: 1;
    padding-inline: 6px;
  }

  .stations {
    grid-template-columns: 1fr;
  }

  .lead {
    padding: 18px;
    text-align: start;
  }
}
