@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ─── CSS Variables (dark theme) ─── */
:root {
  --blue:       #4a7fd4;
  --blue-mid:   #3a6bbf;
  --blue-light: rgba(74,127,212,0.12);
  --teal:       #2dc4ae;
  --teal-light: rgba(45,196,174,0.12);
  --warm:       #f07040;
  --stable:     #2dc4ae;

  --bg-page:    #0b0f1a;
  --bg-nav:     #080d18;
  --bg-card:    #131929;
  --bg-card-sel:#1a2340;
  --bg-metric:  #111726;
  --bg-input:   #1a2035;

  --border:     rgba(255,255,255,0.07);
  --border-sel: #4a7fd4;
  --border-inp: rgba(255,255,255,0.12);

  --text-1:     #e8edf8;
  --text-2:     #7a87a8;
  --text-3:     #4a5570;

  --chip-bg:    rgba(74,127,212,0.15);
  --chip-text:  #4a7fd4;
  --grid:       #1a2035;

  --radius:     10px;
  --radius-sm:  7px;
  --shadow:     0 1px 4px rgba(0,0,0,0.3);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg-page);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.25s, color 0.25s;
}
a { color: var(--blue); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ─── Layout ─── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ─── Navbar ─── */
.nav {
  background: var(--bg-nav);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.nav-left  { display: flex; align-items: center; gap: 10px; }
.nav-right { display: flex; align-items: center; gap: 12px; }

.nav-logo {
  display: flex; align-items: center; gap: 8px;
}
.nav-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--teal);
  display: flex; align-items: center; justify-content: center;
}
.nav-dot-inner { width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.nav-brand {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px; font-weight: 700;
  color: #fff; letter-spacing: 0;
}
.nav-brand-mark {
  color: var(--teal);
}
.nav-links { display: flex; gap: 18px; margin-left: 20px; }
.nav-link {
  font-size: 12px; color: rgba(255,255,255,0.45);
  cursor: pointer; padding: 4px 0; font-weight: 400;
  border-bottom: 1.5px solid transparent;
  transition: color 0.2s;
}
.nav-link:hover { color: rgba(255,255,255,0.75); }
.nav-link.active { color: #fff; border-bottom-color: var(--teal); }
.nav-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(45,196,174,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: var(--teal);
  font-family: 'IBM Plex Sans', sans-serif;
}
.nav-username { font-size: 12px; color: rgba(255,255,255,0.55); }


/* ─── Page body ─── */
.page {
  padding: 1.75rem 2rem;
  flex: 1;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.section-label {
  font-size: 10px; font-weight: 600;
  color: var(--text-3); letter-spacing: 0.1em;
  text-transform: uppercase; margin-bottom: 10px;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: background 0.25s, border-color 0.2s;
}
.card.selected { border-color: var(--border-sel); background: var(--bg-card-sel); }

/* ─── Stations grid ─── */
.stations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}

.station-card {
  display: flex;
  align-items: stretch;
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  overflow: hidden;
}
.station-card:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(0,59,142,0.08);
}
.station-card.sel {
  border-color: var(--blue);
  background: var(--bg-card-sel);
  box-shadow: 0 2px 10px rgba(0,59,142,0.12);
}
.station-group { cursor: default; }
.station-group:hover { border-color: var(--border); box-shadow: none; }
.station-group.sel { border-color: var(--blue); background: var(--bg-card-sel); }

.sc-indicator {
  width: 3px;
  flex-shrink: 0;
  border-radius: 3px 0 0 3px;
}
.sc-body {
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  width: 100%;
}
.sc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-loc {
  font-size: 11px;
  color: var(--text-3);
}
.sc-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-2);
  margin-top: 6px;
}

/* ─── Group sub-station buttons ─── */
.sc-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}
.sc-sub {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  border: 0.5px solid var(--border);
  background: var(--bg-metric);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.sc-sub:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
}
.sc-sub.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ─── Dashboard main layout ─── */
.dash-main {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 16px;
}

/* ─── Responsive: desktop breakpoints ─── */

/* Large monitors (1600px+): more breathing room */
@media (min-width: 1600px) {
  .page { padding: 2rem 3rem; }
  .dash-main { grid-template-columns: 1fr 240px; gap: 20px; }
  .stations-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .stat-val { font-size: 24px; }
}

/* Standard desktop (1280–1599px): default styles apply well */

/* Small desktop / large laptop (1024–1279px) */
@media (max-width: 1279px) {
  .page { padding: 1.25rem 1.5rem; }
  .dash-main { grid-template-columns: 1fr 200px; gap: 12px; }
  .stat-val { font-size: 19px; }
  .stat-val--md { font-size: 16px; }
  .nav-username { display: none; }
}

/* Compact laptop (1024–1100px) */
@media (max-width: 1100px) {
  .page { padding: 1rem 1.25rem; }
  .dash-main { grid-template-columns: 1fr 190px; gap: 10px; }
  .stations-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .nav { padding: 0 1rem; }
  .nav-links { gap: 12px; margin-left: 12px; }
  .theme-btn { display: none; }
  .stat-val { font-size: 17px; }
  .stat-val--md { font-size: 15px; }
  .stat-item { padding: 0 10px; }
}

/* ─── Chart card ─── */
.chart-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 12px;
  gap: 10px; flex-wrap: wrap;
}
.chart-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--text-1);
}
.chart-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.chart-legend { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-line { width: 16px; height: 2px; border-radius: 1px; }
.legend-dashed { border-top: 2px dashed var(--teal); width: 16px; }
.legend-text { font-size: 10px; color: var(--text-3); }
.chip {
  font-size: 10px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  background: var(--chip-bg); color: var(--chip-text);
  font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.04em;
}

/* ─── Year selector ─── */
.year-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.year-tab {
  font-size: 11px; font-weight: 500;
  padding: 4px 12px; border-radius: 20px;
  border: 0.5px solid var(--border);
  background: var(--bg-card); color: var(--text-2);
  transition: all 0.2s;
}
.year-tab:hover { border-color: var(--blue); color: var(--blue); }
.year-tab.active {
  background: var(--blue); color: #fff; border-color: var(--blue);
}
.year-tab { position: relative; }
.tab-dot {
  display: inline-block; width: 4px; height: 4px;
  background: var(--teal); border-radius: 50%;
  position: absolute; top: 3px; right: 4px;
}

/* ─── Chart card stat strip ─── */
.chart-card { padding: 16px; }

.stat-strip {
  display: flex;
  border-top: 0.5px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
  gap: 0;
}
.stat-item {
  flex: 1;
  padding: 0 16px;
  border-right: 0.5px solid var(--border);
  min-width: 0;
}
.stat-item:first-child { padding-left: 0; }
.stat-item:last-child  { border-right: none; }
.stat-label {
  font-size: 9px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.09em; margin-bottom: 4px;
}
.stat-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px; font-weight: 400;
  color: var(--text-1); line-height: 1;
}
.stat-val--md { font-size: 18px; }
.stat-unit {
  font-size: 10px; color: var(--text-3);
  margin-top: 3px; word-break: break-all;
}

/* ─── Download column ─── */
.dl-col { min-width: 0; }
.dl-col .dl-panel { height: 100%; box-sizing: border-box; }
.metric-label {
  font-size: 9px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 4px;
  overflow-wrap: break-word;
}
.metric-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 26px; font-weight: 400;
  color: var(--text-1); line-height: 1;
}
.metric-unit { font-size: 10px; color: var(--text-3); margin-top: 3px; overflow-wrap: break-word; }
.metric-delta { font-size: 10px; font-weight: 500; margin-top: 5px; }
.delta-up   { color: var(--warm); }
.delta-down { color: var(--teal); }
.delta-flat { color: var(--text-3); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: var(--radius-sm);
  font-family: 'IBM Plex Sans', sans-serif; font-weight: 600;
  font-size: 12px; letter-spacing: 0.03em;
  cursor: pointer; transition: opacity 0.2s;
  padding: 9px 16px; width: 100%;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text-2);
  border: 0.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-sm { padding: 6px 12px; font-size: 11px; width: auto; }

/* ─── Forms / Login ─── */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-page); padding: 1.5rem;
}
.login-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 400px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-header {
  background: var(--bg-nav);
  padding: 2rem 2rem 1.75rem;
}
.login-logo-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.login-logo-text {
  font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.login-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 26px; font-weight: 700;
  color: #fff; line-height: 1.1;
}
.login-sub { font-size: 12px; color: rgba(255,255,255,0.4); margin-top: 6px; }
.login-body { padding: 2rem; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 10px; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em;
}
.field input {
  border: 0.5px solid var(--border-inp);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px; font-family: 'IBM Plex Sans', sans-serif;
  color: var(--text-1); background: var(--bg-input);
  transition: border-color 0.2s;
  outline: none;
}
.field input:focus { border-color: var(--blue); }
.login-error {
  font-size: 12px; color: var(--warm);
  background: rgba(200,81,10,0.08);
  border-radius: var(--radius-sm);
  padding: 8px 12px; display: none;
}
.login-footer {
  border-top: 0.5px solid var(--border);
  padding: 1rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
}
.login-footer-text { font-size: 11px; color: var(--text-3); }
.uv-badge { display: flex; align-items: center; gap: 6px; }
.uv-line { width: 14px; height: 1px; background: var(--border-inp); }
.uv-text {
  font-size: 10px; color: var(--text-3);
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* ─── Upload zone ─── */
.upload-zone {
  border: 1.5px dashed var(--border-inp);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-metric);
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--blue); background: var(--blue-light); }
.upload-zone-label { font-size: 13px; color: var(--text-2); }
.upload-zone-sub   { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ─── Table ─── */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; padding: 8px 10px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3);
  border-bottom: 0.5px solid var(--border);
}
.data-table td {
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--border);
  color: var(--text-1);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-metric); }

/* ─── Badge ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 600;
}
.badge-green { background: var(--teal-light); color: var(--teal); }
.badge-amber { background: rgba(200,81,10,0.1); color: var(--warm); }
.badge-gray  { background: var(--bg-metric); color: var(--text-3); }

/* ─── Download panel ─── */
.dl-panel {
  padding: 14px 14px 14px !important;
  background: var(--bg-metric) !important;
}
.dl-title {
  font-size: 10px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 10px;
}
.dl-fields {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 8px;
}
.dl-field {
  display: flex; flex-direction: column; gap: 3px;
}
.dl-label {
  font-size: 10px; color: var(--text-3);
}
.dl-input {
  width: 100%; box-sizing: border-box;
  border: 0.5px solid var(--border-inp);
  border-radius: 6px; padding: 6px 8px;
  background: var(--bg-input); color: var(--text-1);
  font-size: 12px; font-family: inherit;
  min-width: 0;
}
.dl-check {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-2);
  margin-bottom: 8px; cursor: pointer;
}
.dl-info {
  font-size: 11px; color: var(--text-3);
  margin-bottom: 6px; min-height: 14px;
  word-break: break-word;
}
.dl-hint {
  font-size: 10px; color: var(--text-3);
  margin-bottom: 8px; margin-top: -6px;
}
.dl-raw-divider {
  border: none; border-top: 1px solid var(--border);
  margin: 14px 0;
}
.raw-files-list { margin-top: 6px; }
.raw-year-grid {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 4px;
}
.raw-year-btn {
  padding: 3px 9px;
  font-size: 11px; font-family: 'IBM Plex Mono', monospace;
  border: 0.5px solid var(--border-inp);
  border-radius: 5px;
  background: var(--bg-input); color: var(--text-2);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.raw-year-btn:hover {
  background: var(--blue); color: #fff; border-color: var(--blue);
}

/* ─── Toast ─── */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--text-1); color: var(--bg-page);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  opacity: 0; transform: translateY(8px);
  transition: all 0.3s; pointer-events: none; z-index: 999;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ─── Loading ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Page content width limiter ─── */
.page-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 960px;
}
@media (min-width: 1600px) {
  .page-grid-2col { max-width: 1100px; gap: 20px; }
}
@media (max-width: 1100px) {
  .page-grid-2col { max-width: 100%; gap: 12px; }
}

/* ─── Empty state ─── */
.empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-3); font-size: 13px;
}
