@font-face {
  font-family: IranYekan;
  src: url("fonts/IRANYekanRegular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: IranYekan;
  src: url("fonts/IRANYekanMedium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: IranYekan;
  src: url("fonts/IRANYekanBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
}
@font-face {
  font-family: IranYekan;
  src: url("fonts/IRANYekanExtraBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root {
  --ink: #1b293d;
  --muted: #75849a;
  --teal: #238fd3;
  --teal-dark: #1469a8;
  --teal-pale: #eaf5fc;
  --cream: #f5f7fa;
  --line: #e1e8f0;
  --white: #fff;
  --amber: #9e6722;
  --amber-pale: #fff4dc;
  --red: #a64c45;
  --red-pale: #fff0ed;
  --shadow: 0 10px 30px rgba(29, 61, 99, .045);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: IranYekan, Tahoma, sans-serif; line-height: 1.65; }
button, input, select { font: inherit; }
a { color: var(--teal-dark); text-decoration: none; }
a:hover { color: var(--teal); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .table-scroll:focus-visible { outline: 3px solid #62b9ef; outline-offset: 2px; }
.skip-link { position: absolute; top: -100px; right: 1rem; z-index: 50; padding: .5rem 1rem; background: var(--ink); color: #fff; }
.skip-link:focus { top: .5rem; }

.site-header { position: relative; z-index: 10; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); }
.header-inner { max-width: 1680px; min-height: 68px; margin: auto; padding: 0 2.4rem; display: flex; align-items: center; gap: 3rem; }
.brand { display: flex; align-items: center; gap: .8rem; color: var(--ink); white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(140deg, #59b9ea, #187dcb); color: #fff; font-size: 2rem; line-height: 1; transform: rotate(-18deg); }
.brand strong { display: block; font-size: 1.13rem; line-height: 1.15; }
.brand small { display: block; margin-top: .2rem; font-size: .69rem; color: var(--muted); }
.site-nav { display: flex; align-items: stretch; gap: 1.7rem; height: 68px; }
.site-nav a { display: flex; align-items: center; padding: 0 .1rem; border-bottom: 3px solid transparent; color: var(--muted); font-size: .91rem; font-weight: 700; white-space: nowrap; }
.site-nav a.active, .site-nav a:hover { color: var(--teal-dark); border-bottom-color: var(--teal); }

.page-shell { max-width: 1680px; margin: auto; padding: 1.9rem 2.4rem 4rem; }
.page-intro { position: relative; margin-bottom: 1.15rem; }
.eyebrow { display: block; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: 0; text-align: right; }
.title-row { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .15rem; font-size: clamp(1.6rem, 2.1vw, 2.25rem); line-height: 1.35; letter-spacing: -.025em; }
.page-intro p { max-width: 850px; margin-bottom: 0; color: var(--muted); font-size: .96rem; }
.date-emblem { min-width: 160px; padding: .6rem 1rem; border: 1px solid #d6eaf8; border-radius: 12px; background: #eaf5fc; text-align: center; }
.date-emblem small { display: block; color: var(--muted); font-size: .75rem; }
.date-emblem strong { display: block; color: var(--teal-dark); font-size: 1.25rem; letter-spacing: .05em; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: var(--shadow); }

.filter-panel { padding: 1rem 1.2rem; margin-bottom: 1rem; }
.filter-grid { display: grid; grid-template-columns: minmax(145px, .8fr) minmax(175px, 1fr) minmax(125px, .7fr) minmax(255px, 1.5fr) auto auto; gap: .9rem; align-items: end; }
.filter-grid label, .health-filter label { display: flex; flex-direction: column; gap: .4rem; color: var(--muted); font-size: .75rem; font-weight: 800; }
.filter-grid input:not([type=checkbox]), .filter-grid select, .health-filter select { width: 100%; min-height: 42px; padding: .45rem .7rem; border: 1px solid #d9e1ea; border-radius: 8px; background: #fff; color: var(--ink); font-size: .88rem; }
.filter-grid input::placeholder { color: #a4b2b5; }
.date-field { min-width: 0; }
.date-field > label { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .75rem; font-weight: 800; }
.date-input-wrap { position: relative; }
.date-input-wrap > input { direction: ltr; text-align: center; padding-left: 2.5rem !important; }
.calendar-picker > summary { position: absolute; top: 5px; left: 5px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: #edf6fd; color: var(--teal-dark); font-size: 1.25rem; line-height: 1; list-style: none; cursor: pointer; }
.calendar-picker > summary::-webkit-details-marker { display: none; }
.calendar-popup { position: absolute; top: 47px; right: 0; z-index: 20; width: min(315px, calc(100vw - 1.6rem)); padding: .8rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 16px 36px rgba(29, 61, 99, .18); }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .65rem; }
.calendar-nav strong { font-size: .84rem; }
.calendar-nav a { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: #edf6fd; font-size: 1.2rem; line-height: 1; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.calendar-grid > a, .calendar-grid > span { display: grid; place-items: center; min-height: 32px; border-radius: 6px; color: var(--ink); font-size: .72rem; }
.calendar-grid > .weekday { color: var(--muted); font-weight: 800; }
.calendar-grid > a:hover, .calendar-grid > a.selected { background: var(--teal); color: #fff; }
.checkbox-field { min-height: 43px; flex-direction: row !important; align-items: center; gap: .55rem !important; white-space: nowrap; color: var(--ink) !important; font-size: .78rem !important; }
.checkbox-field input { width: 17px; height: 17px; accent-color: var(--teal); }
.primary-button { min-height: 42px; padding: .5rem 1.1rem; border: 0; border-radius: 8px; background: var(--teal); color: #fff; font-size: .83rem; font-weight: 800; cursor: pointer; white-space: nowrap; }
.primary-button:hover { background: var(--teal-dark); }
.quick-dates { display: flex; align-items: center; flex-wrap: wrap; gap: .48rem; margin-top: .75rem; padding-top: .7rem; border-top: 1px solid #edf1f5; color: var(--muted); font-size: .75rem; }
.quick-dates a { padding: .2rem .55rem; border-radius: 7px; background: #f0f4f8; color: var(--muted); font-family: inherit; font-weight: 700; }
.quick-dates a.selected { background: var(--teal-pale); color: var(--teal-dark); }

.summary-row { display: grid; grid-template-columns: .8fr 1.15fr 1fr; gap: .85rem; margin-bottom: 1rem; }
.summary-card { min-height: 95px; padding: .85rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.summary-card > span { display: block; color: var(--muted); font-size: .73rem; font-weight: 700; }
.summary-card > strong { display: block; margin: .2rem 0 .12rem; color: var(--ink); font-size: 1.65rem; line-height: 1.3; }
.summary-card > strong.summary-name { padding-top: .22rem; font-size: 1.03rem; }
.summary-card small { display: block; color: var(--muted); font-size: .69rem; }
.summary-card .status-text { font-size: 1.3rem; }
.download-card { border-color: #a9daf4; background: linear-gradient(125deg, #eff9ff, #e6f4fd); }
.download-card > strong { color: var(--teal-dark); font-size: 1.16rem; }
.download-card:hover { background: #dff1fc; }
.status-success { color: var(--teal-dark) !important; }
.status-partial, .status-skipped { color: var(--amber) !important; }
.status-failed, .status-not_fetched { color: var(--red) !important; }

.matrix-panel, .issues-panel, .detail-panel { overflow: hidden; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; padding: 1rem 1.2rem .85rem; }
.section-heading h2 { margin: 0; font-size: 1.17rem; line-height: 1.4; }
.section-heading p { margin: 0; color: var(--muted); font-size: .79rem; }
.unit-chip { margin-inline-start: .3rem; padding: .15rem .4rem; border-radius: 5px; background: #ebf5fc; color: var(--teal-dark); font-size: .65rem; vertical-align: middle; }
.table-scroll { max-width: 100%; overflow: auto; overscroll-behavior-inline: contain; border-top: 1px solid var(--line); }
.forecast-table, .issues-table { width: 100%; border-spacing: 0; border-collapse: separate; text-align: right; }
.forecast-table { table-layout: fixed; }
/* The daily matrix fits desktop viewports; smaller screens can still pan the data. */
.forecast-table.mode-24 { width: 100%; min-width: 1180px; }
.forecast-table.mode-6 { width: 2277px; }
.forecast-table.mode-1 { width: 3117px; }
.forecast-table th, .forecast-table td { border-bottom: 1px solid #e8edf3; border-left: 1px solid #edf1f6; }
.forecast-table thead th { position: sticky; top: 0; z-index: 3; height: 51px; padding: .36rem .2rem; background: #eef5fa; color: #607184; font-size: .69rem; text-align: center; white-space: nowrap; }
.forecast-table .station-column { position: sticky; right: 0; z-index: 2; min-width: 180px; width: 180px; max-width: 180px; padding: .65rem .7rem; background: #fff; box-shadow: -5px 0 12px rgba(30, 75, 117, .035); }
.forecast-table thead .station-column { z-index: 5; background: #eaf3fa; text-align: right; }
.forecast-table tbody tr:hover .station-column { background: #f7fbff; }
.forecast-table.mode-24 td { width: auto; min-width: 0; }
.forecast-table.mode-6 td { width: 148px; min-width: 148px; }
.forecast-table.mode-1 td { width: 208px; min-width: 208px; }
.header-date { display: block; color: #91a0af; font-size: .58rem; font-weight: 500; }
/* Gecko can fail to paint sticky table cells inside an RTL scroll region. */
@supports (-moz-appearance: none) {
  .forecast-table thead th, .forecast-table .station-column { position: static; }
}
.station-name { display: block; color: var(--ink); font-size: .82rem; font-weight: 800; line-height: 1.45; }
.station-name:hover { color: var(--teal); }
.station-id, .station-coords { display: block; color: var(--muted); font-size: .62rem; text-align: right; }
.station-id { margin-top: .15rem; font-weight: 800; letter-spacing: .03em; }
.station-coords { margin-top: .05rem; }
.station-tags, .station-badges { display: flex; flex-wrap: wrap; gap: .22rem; margin-top: .35rem; }
.tag { display: inline-flex; align-items: center; padding: .1rem .35rem; border-radius: 999px; background: #eef2f6; color: #697c8d; font-size: .57rem; font-style: normal; font-weight: 750; white-space: nowrap; }
.tag.synoptic { background: var(--teal-pale); color: var(--teal-dark); }
.tag.status-success { background: #e5f6ee; }
.tag.status-partial, .tag.status-skipped, .tag.warning { background: var(--amber-pale); }
.tag.status-failed, .tag.status-not_fetched { background: var(--red-pale); }
.forecast-cell { padding: 0; text-align: center; vertical-align: middle; }
.forecast-cell.is-missing { background: #fbfcfe; }
.forecast-cell.is-partial { background: #fffaf0; }
.cell-link { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 74px; padding: .42rem .2rem; color: var(--ink); }
.cell-link:hover { background: #eaf5fd; color: var(--ink); }
.cell-date { display: block; margin-bottom: .28rem; color: var(--muted); font-size: .63rem; letter-spacing: .02em; }
.day-amount { display: block; color: var(--ink); font-size: 1.05rem; font-weight: 900; line-height: 1.3; direction: ltr; }
.day-amount small { margin-left: .15rem; color: var(--muted); font-size: .58rem; font-weight: 600; }
.is-missing .day-amount { color: #aeb9ba; }
.cell-note { display: block; margin-top: .18rem; color: var(--amber); font-size: .6rem; }
.quality-mark { position: absolute; top: 5px; left: 6px; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--amber-pale); color: var(--amber); font-family: sans-serif; font-size: .65rem; font-weight: 900; }
.mini-values { display: grid; width: 100%; direction: ltr; }
.six-values { grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 0 .18rem; }
.hourly-values { grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 0 .1rem; }
.mini-value { min-width: 0; padding: .11rem .02rem; border-radius: 4px; background: #e8f4fc; color: #2a668e; font-size: .58rem; font-weight: 750; line-height: 1.25; overflow: hidden; text-overflow: clip; }
.mini-value.zero { color: #859da0; background: #f2f5f4; }
.mini-value.empty { color: #b2bfc0; background: #f4f5f4; }
.empty-row { padding: 2rem !important; color: var(--muted); text-align: center !important; font-size: .9rem; }

.breadcrumb { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.45rem; color: var(--muted); font-size: .82rem; }
.breadcrumb a { font-weight: 800; }
.station-intro .title-row { align-items: center; }
.station-meta { min-width: 170px; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 13px; background: #fff; text-align: center; }
.station-meta span, .station-meta small { display: block; }
.station-meta span { font-size: .9rem; font-weight: 850; }
.station-meta small { color: var(--muted); font-size: .72rem; }
.station-badges { margin-top: .8rem; }
.station-filters { grid-template-columns: minmax(200px, 310px) minmax(140px, 210px) auto; justify-content: start; }
.run-date { display: block; font-size: 1.08rem; font-weight: 900; text-align: right; }
.history-table .station-column { min-width: 165px; width: 165px; max-width: 165px; }

.detail-intro p strong { white-space: nowrap; }
.detail-facts { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.2rem; }
.detail-facts > span { padding: .48rem .75rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); font-size: .77rem; }
.detail-facts strong { margin-right: .28rem; color: var(--ink); }
.daily-feature { display: flex; justify-content: space-between; align-items: center; padding: 1.35rem 1.5rem; margin-bottom: 1.1rem; border-color: #cce9f9; background: linear-gradient(110deg, #eaf6fd, #fff 62%); }
.daily-feature h2 { margin: .15rem 0 0; font-size: 1.27rem; }
.daily-feature p { margin: 0; color: var(--muted); font-size: .78rem; }
.feature-amount { display: flex; align-items: baseline; gap: .45rem; color: var(--teal-dark); }
.feature-amount strong { font-size: 2.5rem; line-height: 1; }
.feature-amount span { color: var(--muted); font-size: .77rem; }
.feature-amount.is-missing strong { color: #aeb9ba; }
.notice { margin-bottom: 1.25rem; padding: .8rem 1rem; border: 1px solid #ecd8aa; border-radius: 11px; background: var(--amber-pale); color: #6f521f; font-size: .77rem; }
.detail-panel { margin-bottom: 1.1rem; }
.bucket-grid { display: grid; gap: .8rem; padding: 0 1.65rem 1.65rem; }
.six-grid { grid-template-columns: repeat(4, 1fr); }
.hour-grid { grid-template-columns: repeat(6, 1fr); }
.bucket-card { display: flex; flex-direction: column; min-height: 100px; padding: .75rem .8rem; border: 1px solid #e1eaf2; border-radius: 10px; background: #f8fbfe; }
.bucket-card > span { color: var(--muted); font-size: .69rem; text-align: right; }
.bucket-card strong { color: var(--teal-dark); font-size: 1.3rem; line-height: 1.35; }
.bucket-card small { color: var(--muted); font-size: .64rem; }
.bucket-card em { margin-top: auto; padding-top: .3rem; color: var(--muted); font-size: .58rem; font-style: normal; }
.bucket-card.is-missing { border-color: #e5e9e8; background: #f7f7f6; }
.bucket-card.is-missing strong { color: #aeb9ba; }
.method-note { color: var(--muted); font-size: .75rem; }

.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.35rem; }
.health-card { padding: 1.2rem 1.3rem .9rem; }
.health-card-head { display: flex; justify-content: space-between; align-items: start; gap: .6rem; }
.health-card h2 { margin: .15rem 0 1rem; font-size: 1.12rem; }
.health-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem .5rem; margin: 0; }
.health-metrics > div { padding-top: .45rem; border-top: 1px solid #e8edf2; }
.health-metrics dt { color: var(--muted); font-size: .68rem; }
.health-metrics dd { margin: .1rem 0 0; color: var(--ink); font-size: .95rem; font-weight: 850; text-align: right; }
.health-foot { margin: .9rem 0 0; color: var(--muted); font-size: .67rem; }
.health-filter select { min-width: 180px; }
.issues-table { min-width: 850px; }
.issues-table th { padding: .7rem .8rem; background: #eef5fa; color: #607184; font-size: .74rem; white-space: nowrap; }
.issues-table td { padding: .72rem .8rem; border-bottom: 1px solid #e8edf3; color: #43566a; font-size: .73rem; vertical-align: top; }
.issues-table td small { display: block; color: var(--muted); }
.issues-table .error-cell { max-width: 280px; overflow-wrap: anywhere; }
.lead-pill { display: inline-flex; justify-content: center; min-width: 23px; margin: 1px; padding: .05rem .25rem; border-radius: 5px; background: var(--amber-pale); color: var(--amber); font-size: .66rem; font-weight: 800; }

@media (max-width: 1200px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-field { grid-column: span 2; }
  .summary-row { grid-template-columns: repeat(3, 1fr); }
  .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .header-inner { flex-wrap: wrap; gap: .4rem 1rem; min-height: 70px; padding: .7rem 1rem 0; }
  .brand-mark { width: 36px; height: 36px; font-size: 1.7rem; }
  .site-nav { order: 3; width: 100%; height: 42px; gap: 1.3rem; }
  .page-shell { padding: 1.5rem .8rem 3rem; }
  .title-row { align-items: start; flex-direction: column; gap: 1rem; }
  .date-emblem { min-width: 0; padding: .5rem .8rem; text-align: right; }
  .date-emblem strong { font-size: 1rem; }
  .filter-panel { padding: .9rem; }
  .filter-grid, .station-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .search-field { grid-column: 1 / -1; }
  .checkbox-field { grid-column: 1 / -1; min-height: 27px; }
  .primary-button { grid-column: 1 / -1; }
  .summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .download-card { grid-column: 1 / -1; }
  .summary-card { min-height: 96px; padding: .75rem .8rem; }
  .summary-card > strong { font-size: 1.25rem; }
  .summary-card small { font-size: .63rem; }
  .section-heading { align-items: start; flex-direction: column; gap: .4rem; padding: 1rem; }
  .forecast-table .station-column { min-width: 165px; width: 165px; max-width: 165px; padding: .6rem; }
  .history-table .station-column { min-width: 165px; width: 165px; max-width: 165px; }
  .station-meta { padding: .55rem .7rem; }
  .detail-facts { gap: .4rem; }
  .detail-facts > span { padding: .35rem .5rem; }
  .daily-feature { padding: 1rem; }
  .feature-amount strong { font-size: 1.8rem; }
  .bucket-grid { gap: .5rem; padding: 0 .9rem .9rem; }
  .six-grid { grid-template-columns: repeat(2, 1fr); }
  .hour-grid { grid-template-columns: repeat(3, 1fr); }
  .bucket-card { min-height: 100px; padding: .55rem; }
  .health-grid { grid-template-columns: 1fr; }
}
