:root {
  --bg: #070a10;
  --surface: #0d1320;
  --surface-2: #111a2b;
  --line: #263650;
  --line-soft: rgba(148, 163, 184, .18);
  --text: #f4f7fb;
  --muted: #9db0ca;
  --faint: #6f829e;
  --teal: #24d7c8;
  --blue: #58a8ff;
  --red: #fb7185;
}

* { box-sizing: border-box; }
html { font-size: 16px; }

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #080b12 0%, #070a10 58%, #05070c 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #090e1a;
  border-right: 1px solid var(--line-soft);
  padding: 28px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  font-weight: 850;
  font-size: 1.18rem;
  line-height: 1.18;
  margin-bottom: 38px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  display: grid;
  place-items: center;
  color: #041015;
  font-weight: 900;
}

.nav-link {
  color: #afc2dd;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 7px;
  font-size: 1rem;
  font-weight: 650;
}

.nav-link:hover,
.nav-link.active {
  background: #121c2f;
  color: var(--text);
}

.main {
  padding: 34px 38px 42px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.page-title {
  font-size: clamp(2rem, 2.4vw, 3rem);
  line-height: 1;
  margin: 0 0 8px;
  font-weight: 900;
}

.muted { color: var(--muted); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 16px;
}

.metric-card,
.section-block,
.chart-panel,
.panel,
.stat-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, .22);
}

.metric-card {
  min-height: 126px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label,
.stat-label {
  color: var(--muted);
  font-size: .95rem;
  font-weight: 700;
}

.metric-value,
.stat-value {
  color: var(--text);
  font-size: clamp(2rem, 2.4vw, 3.1rem);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.section-block { padding: 20px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0 0 5px;
  font-size: 1.35rem;
  font-weight: 850;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.status-chip,
.mini-pill {
  color: #031014;
  background: var(--teal);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: .76rem;
  font-weight: 900;
  white-space: nowrap;
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.station-mini {
  display: block;
  min-height: 218px;
  background: #0c1423;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 17px;
  overflow: hidden;
}

.station-mini:hover {
  border-color: rgba(36, 215, 200, .75);
  background: #101b2d;
}

.station-mini-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.station-name {
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1.18;
}

.station-sub,
.station-live-label {
  color: var(--faint);
  font-size: .86rem;
  font-weight: 650;
}

.station-live {
  margin-top: 14px;
  font-size: 3.15rem;
  line-height: .95;
  font-weight: 950;
}

.mini-chart-box {
  height: 82px;
  margin-top: 14px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-panel { padding: 18px; }

.chart-title {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 3px;
}

.chart-note {
  color: var(--faint);
  font-size: .88rem;
  font-weight: 650;
  margin-bottom: 12px;
}

.chart-box { height: 335px; }

.panel,
.stat-card { padding: 18px; }

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
}

.form-control,
.form-select {
  background: #0c1423;
  color: var(--text);
  border-color: var(--line);
}

.form-control:focus,
.form-select:focus {
  background: #0c1423;
  color: var(--text);
  border-color: var(--teal);
  box-shadow: 0 0 0 .2rem rgba(36, 215, 200, .13);
}

.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #021313;
  font-weight: 800;
}

.btn-outline-light {
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #19060a;
  font-weight: 800;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box,
.installer-hero,
.installer-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.login-box { width: min(430px, 100%); }

.installer-page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  padding: 28px;
}

.installer-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 24px;
  align-items: start;
}

.installer-hero { position: sticky; top: 28px; }

.installer-hero h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
  font-weight: 900;
  margin: 40px 0 18px;
}

.installer-hero p {
  color: var(--muted);
  font-size: 1.05rem;
}

.installer-checks {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.installer-checks div {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0c1423;
}

.world-map-placeholder {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1423;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0;
}

@media (max-width: 1500px) {
  .metrics-grid { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; padding: 20px; }
  .main { padding: 22px 16px 28px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .metrics-grid { grid-template-columns: 1fr; }
  .station-grid { grid-template-columns: 1fr; }
  .installer-shell { grid-template-columns: 1fr; }
  .installer-hero { position: static; }
}
