:root {
  --bg: #f4f7f8;
  --bg-elev: #ffffff;
  --bg-soft: #eef3f5;
  --line: #d5dee3;
  --text: #1c2a32;
  --muted: #5f7380;
  --accent: #0f7f7a;
  --accent-dim: #0c6561;
  --warn: #b78100;
  --bad: #c44242;
  --ok: #2f9a55;
  --off: #9aabb5;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, #e8f0f2 0%, var(--bg) 220px);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3.5rem;
  position: relative;
  min-height: 100vh;
}

.app-footer {
  position: fixed;
  right: 0.9rem;
  bottom: 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.85;
  pointer-events: none;
  z-index: 20;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.brand strong {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: #14343a;
}
.brand span { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); }

nav { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
nav a, nav button.linkish {
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
nav a.active, nav a:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--bg-elev);
  text-decoration: none;
}

.cloud-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
  margin: 0 0.35rem 0 0.15rem;
  border: 1px solid color-mix(in srgb, currentColor 35%, white);
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 20%, transparent);
}
.cloud-dot.ok { background: var(--ok); color: var(--ok); }
.cloud-dot.bad { background: var(--bad); color: var(--bad); }
.cloud-dot.warn { background: var(--warn); color: var(--warn); }
.cloud-dot.off { background: #c5d0d6; color: #c5d0d6; }

.conn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.35rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none !important;
  border: 1px solid transparent;
  line-height: 1;
}
.conn-badge.ok {
  background: color-mix(in srgb, var(--ok) 16%, white);
  color: #1f7a3d;
  border-color: color-mix(in srgb, var(--ok) 45%, white);
}
.conn-badge.bad {
  background: color-mix(in srgb, var(--bad) 14%, white);
  color: #a33333;
  border-color: color-mix(in srgb, var(--bad) 40%, white);
}
.conn-badge.warn {
  background: color-mix(in srgb, var(--warn) 16%, white);
  color: #8a6200;
  border-color: color-mix(in srgb, var(--warn) 40%, white);
}
.conn-badge.off {
  background: #e8eef1;
  color: #7a8b95;
  border-color: #d5dee3;
}
.conn-badge:hover { filter: brightness(0.97); }

h1, h2, h3 { font-weight: 560; letter-spacing: 0.02em; margin: 0 0 0.75rem; }
h1 { font-size: 1.5rem; }
h2 {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, 1fr);
}
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
@media (max-width: 900px) {
  .col-2, .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 0 rgba(20, 40, 50, 0.03);
}

.section-stack { display: grid; gap: 1rem; }

.metric {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
}
.metric-label {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}
.metric-unit { color: var(--muted); font-size: 0.75rem; margin-left: 0.2rem; }
.metric-panel {
  padding: 0.7rem 0.85rem;
}
.metric-panel .metric-sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: var(--bg-soft);
}
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.86rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link:hover td { background: var(--bg-soft); }

.pager-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}
.pager-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.pager-label select {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 3px;
  padding: 0.3rem 0.45rem;
  font-family: var(--mono);
}
.pager-nav { display: flex; gap: 0.45rem; }

.btn, button.btn {
  appearance: none;
  border: 1px solid var(--accent-dim);
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 3px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dim); }
.capture-panel form { margin: 0; }
.btn-compact {
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  margin-top: 0.15rem;
}
.btn.secondary {
  border-color: var(--line);
  background: var(--bg-soft);
  color: var(--text);
}
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; }

label.field textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font: inherit;
  resize: vertical;
}
label.field textarea.mono { font-family: var(--mono); font-size: 0.82rem; }
.wg-details {
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.8rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  white-space: pre-wrap;
  font-size: 0.78rem;
  max-height: 180px;
  overflow: auto;
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}
input[type="text"], input[type="password"], input[type="number"], input[type="url"] {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.55rem 0.65rem;
  border-radius: 3px;
  font: inherit;
  font-family: var(--mono);
}
.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
  color: var(--text);
}
.flash {
  border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--line));
  background: color-mix(in srgb, var(--ok) 10%, white);
  color: #1f6b3a;
  padding: 0.65rem 0.8rem;
  margin-bottom: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  border-radius: 3px;
}
.error {
  border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line));
  background: color-mix(in srgb, var(--bad) 8%, white);
  color: var(--bad);
  padding: 0.65rem 0.8rem;
  margin-bottom: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  border-radius: 3px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, #e7f1f3, #f4f7f8);
}
.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  padding: 2rem 1.5rem;
  border-radius: 4px;
}
.login-panel .brand-mark {
  font-size: 1.8rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
  color: #14343a;
}
.login-panel .sub {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.8rem;
}
.thumb {
  border: 1px solid var(--line);
  background: #fff;
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 3px;
  overflow: hidden;
}
.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #dfe7eb;
}
.thumb .cap {
  padding: 0.5rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.obs-images {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}
@media (max-width: 900px) {
  .obs-images { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .obs-images { grid-template-columns: 1fr; }
}
.obs-images figure {
  margin: 0;
  border: 1px solid var(--line);
  background: #111;
  border-radius: 3px;
  overflow: hidden;
}
.obs-images img { width: 100%; display: block; }
.obs-images a { display: block; color: inherit; }
.obs-images a:hover img { opacity: 0.92; }
.obs-images figcaption {
  padding: 0.45rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: #fff;
}
.preview-box {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}
.preview-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}
.preview-thumb {
  display: block;
  max-width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: #111;
}
.preview-thumb img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}
.preview-empty {
  padding: 1.2rem;
  border: 1px dashed var(--line);
  border-radius: 3px;
  background: var(--bg-soft);
}
.preview-page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.preview-page-head h1 { margin: 0; }
.preview-page-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.preview-stage {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #0d1418;
  overflow: hidden;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 220px);
  object-fit: contain;
}
.preview-stage .preview-empty {
  margin: 1.5rem;
  background: transparent;
  border-color: rgba(255,255,255,0.15);
  color: #9aabb5;
}
.config-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 1rem 0 0.85rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
}
.config-tab {
  padding: 0.45rem 0.95rem;
  border-radius: 3px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.config-tab:hover {
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.7);
}
.config-tab.active {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(20, 52, 58, 0.04);
}
.chart-wrap { position: relative; height: 260px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.station-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.station-card {
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.85rem;
  color: inherit;
  text-decoration: none !important;
  box-shadow: 0 1px 0 rgba(20, 40, 50, 0.03);
}
.station-card:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.station-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.65rem;
}
.station-thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.station-thumb img,
.obs-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}
.station-thumb img { height: 100%; }
.station-thumb-empty { font-size: 0.85rem; }
.station-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.65rem;
  font-size: 0.75rem;
}
