:root {
  color-scheme: light;
  --navy: #15294d;
  --ink: #172a45;
  --muted: #53637a;
  --background: #eef2f7;
  --border: #dce4ee;
  --mati: #ad6500;
  --szczecin: #264b88;
  --online: #17664e;
  --silent: #8a4d03;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
.shell { width: min(100% - 3rem, 80rem); margin-inline: auto; }

.masthead { background: var(--navy); color: white; border-top: 4px solid #d6a146; }
.masthead-inner {
  min-height: 9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.5rem;
}
.eyebrow { color: #f4c773; font-size: .73rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1, .stat-value { font-family: "PT Serif", Georgia, serif; }
h1 { font-size: clamp(1.75rem, 3.4vw, 2.75rem); margin-block: .28rem .45rem; line-height: 1.1; }
.locations, .connection p { color: #d6e1f1; font-size: .87rem; }
.locations span { margin-inline: .38rem; color: #efbd6e; }
.connection { text-align: right; flex-shrink: 0; }
.connection p { margin-top: .6rem; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: .43rem;
  padding: .28rem .68rem;
  border-radius: 2rem;
  background: #e8eef7;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 700;
}
.badge::before, .stream-state::before {
  content: "";
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.badge.live { background: #dcf3e7; color: var(--online); }
.badge.demo, .badge.problem { background: #fff0d1; color: var(--silent); }

main.shell { padding-block: 1.35rem 1rem; }
.summary, .monitoring { display: grid; gap: .9rem; }
.summary { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: .9rem; }
.monitoring { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.card { background: white; border: 1px solid var(--border); border-radius: .75rem; }
.stat { padding: .85rem 1.05rem; }
.stat h2 { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-value { margin-block: .25rem; font-size: clamp(1.4rem, 2.5vw, 1.95rem); line-height: 1.25; font-weight: 700; }
.stat > p:last-child, .panel-header p, .legend, .footer { color: var(--muted); font-size: .79rem; }
.delay-values { margin-block: .25rem; }
.delay-values p {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .85rem;
}
.delay-values strong { font-variant-numeric: tabular-nums; }
.panel { padding: 1rem 1.1rem; min-width: 0; }
.panel h2 { font-size: 1rem; line-height: 1.3; }
.panel-header p { margin-top: .22rem; }
.chart { position: relative; height: 16rem; margin-top: .8rem; }
.chart canvas { display: block; width: 100%; height: 100%; }
.chart p {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  background: #f8fafc;
  border-radius: .45rem;
}
[hidden] { display: none !important; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; list-style: none; padding: 0; margin: .55rem 0 0; }
.legend li { display: flex; align-items: center; gap: .38rem; }
.swatch { width: .8rem; height: .24rem; border-radius: .2rem; background: var(--city); }
.mati { --city: var(--mati); }
.szczecin { --city: var(--szczecin); }

.sensor-groups { margin-top: .85rem; }
.sensor-group + .sensor-group { margin-top: .65rem; }
.sensor-group h3 { font-size: .88rem; color: var(--city); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.sensor-group ul { list-style: none; margin: 0; padding: 0; }
.stream {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .15rem .65rem;
  align-items: baseline;
  padding-block: .35rem;
  border-bottom: 1px solid #edf1f6;
  font-size: .83rem;
}
.stream:last-child { border-bottom: 0; }
.stream-value, .stream-time { text-align: right; font-variant-numeric: tabular-nums; }
.stream-time, .stream-state { font-size: .72rem; color: var(--muted); }
.stream-state { display: inline-flex; align-items: center; gap: .35rem; }
.stream-state::before { width: .4rem; height: .4rem; }
.stream-state.online { color: var(--online); }
.stream-state.silent { color: var(--silent); }

.alerts { margin-top: .9rem; }
.alert-empty { margin-top: .8rem; border-top: 1px solid var(--border); padding-top: .7rem; color: var(--muted); font-size: .82rem; }
.notice { margin-bottom: .9rem; background: #fff3db; border: 1px solid #edce90; border-radius: .55rem; padding: .55rem .8rem; color: #704208; font-size: .85rem; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .4rem 1rem; padding: .85rem .1rem .3rem; }

@media (max-width: 55rem) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitoring { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 36rem) {
  .shell { width: calc(100% - 1.5rem); }
  .masthead-inner { flex-direction: column; align-items: flex-start; gap: .85rem; }
  .connection { text-align: left; }
  .stat { padding: .7rem .75rem; }
  .panel { padding: .85rem; }
}
