:root {
  --color-text: #222;
  --color-text-muted: #555;
  --color-text-light: #888;
  --color-text-null: #bbb;
  --color-bg: #f5f5f5;
  --color-bg-white: #fff;
  --color-bg-row-even: #f4f7fb;
  --color-bg-hover: #dde4f0;
  --color-primary: #153264;
  --color-accent: #f3ba05;
  --color-border: #eee;
  --color-border-btn: #d0d0d0;
  --color-shadow: rgba(0, 0, 0, 0.1);
  --color-muted-ui: #666;
  --color-wind-arrow: #444;
  --color-zra-hod: var(--color-primary);
  --color-indicator-green: #34a853;
  --color-indicator-orange: #f9ab00;
  --color-indicator-red: #ea4335;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'IBM Plex Sans Condensed', system-ui, sans-serif;
  font-optical-sizing: auto;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

header nav {
  padding: 8px 1rem;
  background: var(--color-primary);
  text-align: center;
}

header nav img {
  width: 224px;
  height: 48px;
}

header nav a {
  color: var(--color-bg-white);
  text-decoration: none;
  font-weight: bold;
  font-size: 1.5rem;
  display: block;
  width: fit-content;
  margin: 0 auto;
}

header nav a img {
  display: block;
}

header nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  padding: 0;
  margin: 0;
}

.nav-links a {
  color: var(--color-bg-white);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 2px 4px;
  display: inline-block;
  width: auto;
  margin: 0;
}

.nav-links a:hover {
  text-decoration: underline;
}

@media (min-width: 524px) {
  header nav a {
    margin: 4px auto;
  }
}

@media (min-width: 768px) {
  header nav a {
    margin: 8px auto;
  }
}

@media (max-width: 767px) {
  .station-row.station-header {
    display: none;
  }
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* --- climate section ------------------------------------------------------- */

.climate-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.climate-header {
  padding: 0.75rem 0.75rem 0;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.climate-header-text {
  flex: 1;
  min-width: 0;
}

.climate-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

@media (min-width: 524px) {
  .climate-header h1 {
    font-size: 2rem;
  }
}

.station-minimap {
  flex-shrink: 0;
  width: 120px;
  height: 62px;
  border-radius: 4px;
}

@media (min-width: 400px) {
  .station-minimap {
    width: 160px;
    height: 82px;
  }
}

@media (min-width: 768px) {
  .station-minimap {
    width: 200px;
    height: 103px;
  }
}

.last-updated {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.no-data {
  color: var(--color-text-light);
  font-style: italic;
  padding: 0 0.75rem;
}

.null {
  color: var(--color-text-null);
}

/* --- station list (mobile first) ------------------------------------------- */

.station-list {
  background: var(--color-bg-white);
  overflow: hidden;
}

.station-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.2rem 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 1rem;
  align-items: center;
}

.station-row:nth-child(odd) {
  background: var(--color-bg-row-even);
}

/* Mobile: row 1 — čas | stanica | teplota (každý fit-content, riadok 2 má vlastný layout) */
.sl-time {
  grid-column: 1;
  grid-row: 1;
  font-variant-numeric: tabular-nums;
  text-align: left;
  white-space: nowrap;
}

.station-row .sl-time {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.sl-name {
  grid-column: 2;
  grid-row: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sl-name a {
  color: var(--color-primary);
  text-decoration: none;
}

.sl-name a:hover {
  text-decoration: underline;
}

.sl-temp {
  grid-column: 3;
  grid-row: 1;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

/* Mobile: row 2 — wrapper s vlastným grid (nezávislé column sizes od row 1) */
.sl-row-2 {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 0 0.4rem;
  align-items: center;
  font-size: 0.875rem;
}

.sl-row-2 .sl-wind-h { order: 1; grid-column: 1; }
.sl-row-2 .sl-wind   { order: 2; grid-column: 2; display: flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
.sl-row-2 .sl-rain-h { order: 3; grid-column: 3; }
.sl-row-2 .sl-rain   { display: none; }  /* skryté na mobile */

/* sl-rain skrytá na mobile (zobrazujú sa len ikony grafu zrážok a info o vetre) */
.sl-rain,
.sl-pressure,
.sl-sun,
.sl-snow,
.sl-aqi {
  display: none;
}

/* --- wind arrow ------------------------------------------------------------ */

.wind-arrow {
  color: var(--color-wind-arrow);
}

/* --- sparkline ------------------------------------------------------------- */

.sparkline {
  vertical-align: middle;
}

.sun-pie {
  vertical-align: middle;
}

.sun-bar {
  display: block;
  border-radius: 2px;
}

/* --- wind sparkline cell -------------------------------------------------- */

.wind-spark-cell {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  gap: 0.3rem;
  white-space: nowrap;
}

.wind-minmax {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-light);
}

.rain-spark-cell {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

/* --- pressure cell --------------------------------------------------------- */

.pressure-cell {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.pressure-diff {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- station chart --------------------------------------------------------- */

.station-chart-wrap {
  background: var(--color-bg-white);
  padding: 0.5rem 0;
  height: 220px;
}

@media (min-width: 768px) {
  .station-chart-wrap {
    border-radius: 6px;
    box-shadow: 0 1px 4px var(--color-shadow);
    padding: 0.75rem 0.75rem;
    height: 280px;
  }
}

/* --- air quality ----------------------------------------------------------- */

.aqi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.aqi-row-detail {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0 0.75rem;
  margin: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.aqi-row-detail::-webkit-scrollbar { display: none; }

@media (min-width: 768px) {
  .aqi-row-detail {
    padding: 0;
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

.aqi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
}

.aqi-label {
  font-weight: 400;
  font-size: 0.8rem;
}

.aqi-badge-sm {
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
}

.aqi-badge-lg {
  padding: 0.35rem 0.85rem;
  font-size: 1.1rem;
}

.aqi-row-large {
  margin-top: 0.5rem;
}

/* --- ovzdusie list --------------------------------------------------------- */

.aq-region-h {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.75rem 0.75rem 0.25rem;
  color: var(--color-primary);
}

@media (min-width: 768px) {
  .aq-region-h {
    padding: 0.75rem 0 0.25rem;
  }
}

.aq-row-header,
.aq-row {
  grid-template-columns: 48px 1fr 60px;
  gap: 0.4rem;
}

.aq-name a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.aq-name a:hover { text-decoration: underline; }

.aq-emep {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  background: var(--color-bg-row-even);
  color: var(--color-text-muted);
  border-radius: 3px;
  margin-left: 0.3rem;
  vertical-align: 2px;
}

.aq-aqi { text-align: center; }

.aq-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.aq-row .aq-time { color: var(--color-text-muted); }

.aq-time-old {
  color: var(--color-indicator-red);
  font-weight: 600;
}

.aq-dominant,
.aq-pol {
  display: none;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  text-align: right;
}

@media (min-width: 768px) {
  .aq-row-header,
  .aq-row {
    grid-template-columns: 56px 2fr 70px 100px repeat(5, 56px);
  }
  .aq-dominant,
  .aq-pol {
    display: block;
  }
}

.aqi-pol {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.aqi-pol-name {
  font-weight: 600;
  color: var(--color-text);
}

/* --- back link ------------------------------------------------------------- */

.back-link {
  display: inline-block;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.back-link:hover {
  text-decoration: underline;
}

.station-meta {
  font-size: 0.875rem;
  color: var(--color-muted-ui);
  margin-top: 0.2rem;
}

/* --- day navigation -------------------------------------------------------- */

.day-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.4rem;
  padding: 0 0.75rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.day-nav::-webkit-scrollbar { display: none; }

@media (min-width: 768px) {
  .day-nav {
    flex-wrap: wrap;
    overflow-x: visible;
    justify-content: center;
    padding: 0;
  }
}

.day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--color-border-btn);
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.875rem;
  background: var(--color-bg-white);
}

.day-stat-line {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-top: 0.15rem;
  line-height: 1;
}

.ds-min { color: #4a90d9; font-weight: 600; }
.ds-max { color: #e05252; font-weight: 600; }
.ds-drop { color: #4a90d9; flex-shrink: 0; }
.ds-rain { color: #4a90d9; font-weight: 600; }

.day-btn:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.day-btn.active {
  background: var(--color-bg-white);
  color: var(--color-text);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}


/* --- detail page table (stanica_detail) ------------------------------------ */

.table-wrap {
  overflow-x: auto;
  box-shadow: 0 1px 4px var(--color-shadow);
}

@media (min-width: 768px) {
  .table-wrap {
    border-radius: 6px;
  }
}

.climate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--color-bg-white);
}

.climate-table thead th {
  background: var(--color-primary);
  color: var(--color-bg-white);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  text-align: left;
  white-space: nowrap;
  cursor: default;
}

.climate-table tbody tr.row-even {
  background: var(--color-bg-row-even);
}

.climate-table tbody tr:hover {
  background: var(--color-bg-hover);
}

.climate-table td {
  padding: 4px 12px;
  white-space: nowrap;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

.climate-table .null {
  color: var(--color-text-null);
}

.climate-table .station-id a {
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
}

.climate-table .station-id a:hover {
  text-decoration: underline;
}

.climate-table .time {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.climate-table .temp {
  font-weight: 600;
}

.climate-table .wind .wind-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.climate-table .sun,
.climate-table .sun-bar-cell {
  text-align: center;
}

/* --- expandable hour rows -------------------------------------------------- */

.hour-row.expandable {
  cursor: pointer;
}

.hour-row.expandable:hover {
  background: var(--color-bg-hover);
}

.expand-icon {
  display: inline-block;
  font-size: 0.6rem;
  margin-left: 0.4rem;
  transition: transform 0.15s;
  vertical-align: middle;
  color: var(--color-text-light);
}

.hour-row.open .expand-icon {
  transform: rotate(90deg);
}

.minute-row {
  background: var(--color-bg-row-even);
}

.minute-row.hidden {
  display: none;
}

.minute-time {
  padding-left: 1.5rem !important;
  color: var(--color-text-light);
}

.zra-hod {
  font-weight: 600;
  color: var(--color-zra-hod);
}

/* --- footer ---------------------------------------------------------------- */

footer {
  text-align: center;
  padding: 2rem;
  color: var(--color-muted-ui);
  font-size: 0.875rem;
}

/* --- desktop --------------------------------------------------------------- */

@media (min-width: 768px) {
  main {
    margin: 2rem auto;
    padding: 0 1rem;
  }

  .climate-header {
    padding: 0;
  }

  .station-list {
    border-radius: 6px;
    box-shadow: 0 1px 4px var(--color-shadow);
  }

  .station-row {
    grid-template-columns: 32px 1fr 68px 116px 80px 92px 128px 68px 68px;
    grid-template-rows: auto;
    padding: 4px 0.75rem;
  }

  .station-row.station-header {
    padding: 0.6rem 0.75rem;
  }

  .station-row:hover {
    background: var(--color-bg-hover);
  }

  .station-row.station-header,
  .station-row.station-header:nth-child(odd) {
    background: var(--color-primary);
    color: var(--color-bg-white);
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    cursor: default;
  }

  .station-row.station-header:hover {
    background: var(--color-primary);
  }

  .station-row.station-header .sl-time {
    color: var(--color-bg-white);
    font-size: 0.875rem;
  }

  .station-header .sl-pressure,
  .station-header .sl-wind-h,
  .station-header .sl-rain-h,
  .station-header .sl-sun,
  .station-header .sl-aqi {
    display: block !important;
  }

  /* Reset mobile grid positions — let auto-flow handle desktop */
  .sl-time,
  .sl-name,
  .sl-temp,
  .sl-wind,
  .sl-wind-h,
  .sl-rain-h {
    grid-column: auto;
    grid-row: auto;
  }

  /* Mobilný wrapper sl-row-2 nech nehrá rolu — deti idú priamo do parent gridu */
  .sl-row-2 {
    display: contents;
  }

  .sl-row-2 .sl-wind,
  .sl-row-2 .sl-wind-h,
  .sl-row-2 .sl-rain-h {
    order: 0;
    grid-column: auto;
    grid-row: auto;
  }

  .sl-wind {
    justify-content: flex-end;
  }

  .sl-time {
    text-align: left;
  }

  .sl-pressure,
  .sl-sun,
  .sl-aqi {
    display: flex;
    align-items: center;
  }

  .sl-rain,
  .sl-snow {
    display: none;
  }

  .sl-sun {
    justify-content: center;
  }

  .station-row {
    font-size: 1rem;
  }

}

/* Error page */
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-page h1 {
  font-size: 5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--color-muted, #888);
}

.error-page p {
  margin: 0 0 2rem;
}

.error-page a {
  color: inherit;
}
