:root {
  color-scheme: dark;
  --bg: #070a10;
  --bg-soft: #0a0f18;
  --panel: rgba(15, 22, 33, .86);
  --panel-strong: #111a27;
  --text: #f3f7fb;
  --muted: #94a3b7;
  --dim: #5e6d80;
  --line: #202d3c;
  --line-bright: #30445c;
  --blue: #4b93ff;
  --blue-strong: #2679f2;
  --green: #37d39a;
  --amber: #efb35b;
  --danger: #ff7377;
  --sans: Inter, "SF Pro Display", "HarmonyOS Sans SC", "PingFang SC", system-ui, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 80% -10%, rgba(38, 121, 242, .12), transparent 28rem),
    radial-gradient(circle at 0% 100%, rgba(55, 211, 154, .07), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .13;
  pointer-events: none;
}
.ambient-one { top: -130px; right: 18%; background: var(--blue); }
.ambient-two { bottom: -160px; left: 5%; background: var(--green); }

.dot-amber { background: var(--amber); }
.relay-nav-button {
  width: 100%;
  height: 44px;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.relay-nav-button:hover { color: var(--text); background: rgba(239, 179, 91, .06); border-color: rgba(239, 179, 91, .2); }
.relay-nav-button .dot { width: 7px; height: 7px; border-radius: 50%; }
.relay-nav-button b { color: var(--amber); font: 700 9px/1 var(--mono); }

.relay-panel { scroll-margin-top: 28px; }
.relay-heading { align-items: center; }
.relay-freshness {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.relay-freshness i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.relay-freshness.live i { background: var(--green); box-shadow: 0 0 0 5px rgba(55, 211, 154, .08); }
.relay-freshness.stale i { background: var(--danger); }
.relay-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 24px -24px 0;
  border-block: 1px solid var(--line);
  background: var(--line);
}
.relay-metric-grid article { min-width: 0; padding: 20px 24px; background: rgba(8, 13, 21, .74); }
.relay-metric-grid span, .relay-metric-grid small { display: block; color: var(--muted); font-size: 11px; }
.relay-metric-grid strong { display: block; margin: 8px 0 5px; font: 700 clamp(24px, 3vw, 34px)/1 var(--mono); }
.relay-body, .relay-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, .8fr);
  gap: 22px;
  padding-top: 24px;
}
.relay-lower { margin-top: 24px; border-top: 1px solid var(--line); }
.relay-chart-card, .relay-pressure, .relay-lower > div {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 11, 18, .45);
}
.relay-subheading { min-height: 32px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.relay-subheading span { display: block; font-size: 13px; font-weight: 700; }
.relay-subheading small { display: block; margin-top: 5px; color: var(--dim); font-size: 10px; }
.line-amber { background: var(--amber) !important; }
.relay-chart-wrap { height: 230px; margin-top: 12px; }
.relay-pressure dl { margin: 15px 0 0; }
.relay-pressure dl > div, .relay-facts > div {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(32, 45, 60, .72);
}
.relay-pressure dt, .relay-facts span { color: var(--muted); font-size: 11px; }
.relay-pressure dd, .relay-facts strong { margin: 0; font: 700 12px/1 var(--mono); }
.relay-facts { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; margin-top: 15px; }
.relay-location-list { margin-top: 12px; }

@media (max-width: 900px) {
  .relay-metric-grid { grid-template-columns: 1fr 1fr; }
  .relay-body, .relay-lower { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .relay-metric-grid { margin-inline: -16px; }
  .relay-metric-grid article { padding: 16px; }
  .relay-chart-card, .relay-pressure, .relay-lower > div { padding: 14px; }
  .relay-facts { grid-template-columns: 1fr; }
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 750;
}
.brand-lockup > span:last-child > span { color: var(--blue); }
.brand-lockup strong { color: var(--green); }
.brand-mark {
  width: 28px;
  height: 28px;
  position: relative;
  display: block;
  border: 2px solid var(--blue);
  border-radius: 9px;
  box-shadow: 0 0 0 4px rgba(75, 147, 255, .06);
}
.brand-mark i, .brand-mark b {
  position: absolute;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
}
.brand-mark i { width: 9px; top: 8px; left: 6px; }
.brand-mark b { width: 6px; top: 15px; left: 10px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font: 700 10px/1 var(--mono);
  letter-spacing: .15em;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-card {
  width: min(100%, 460px);
  padding: 38px;
  border: 1px solid rgba(48, 68, 92, .86);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(16, 24, 36, .97), rgba(9, 14, 23, .97));
  box-shadow: 0 32px 100px rgba(0, 0, 0, .44);
}
.login-card .brand-lockup { margin-bottom: 52px; }
.login-card h1 {
  margin: 0;
  font-size: clamp(36px, 8vw, 52px);
  line-height: 1.08;
  letter-spacing: -.03em;
}
.login-lead { margin: 18px 0 32px; color: var(--muted); line-height: 1.7; }
.login-card form { display: grid; gap: 16px; }
.login-card label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.login-card input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  outline: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 9, 15, .72);
  color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(75, 147, 255, .1); }
.form-error { min-height: 18px; margin: -3px 0 0; color: var(--danger); font-size: 12px; }
.primary-button {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-strong), #4b93ff);
  color: white;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(38, 121, 242, .22);
}
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.privacy-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px;
  line-height: 1.55;
}
.privacy-note i { width: 6px; height: 6px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--green); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 238px;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 22px;
  border-right: 1px solid rgba(32, 45, 60, .88);
  background: rgba(7, 10, 16, .84);
  backdrop-filter: blur(20px);
}
.brand-lockup.compact { padding: 0 10px 30px; font-size: 15px; }
.brand-lockup.compact .brand-mark { width: 25px; height: 25px; border-radius: 8px; }
.sidebar nav { margin-top: 20px; }
.sidebar nav > p, .sidebar-status > p {
  margin: 0 10px 10px;
  color: var(--dim);
  font: 650 10px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.site-button {
  width: 100%;
  height: 45px;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.site-button:hover { color: var(--text); background: rgba(18, 28, 42, .62); }
.site-button.active { border-color: rgba(75, 147, 255, .2); background: rgba(38, 121, 242, .11); color: white; }
.site-button b { color: var(--dim); font: 600 10px/1 var(--mono); }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-all { background: linear-gradient(135deg, var(--blue) 50%, var(--green) 50%); }
.dot-blue { background: var(--blue); }
.dot-green { background: var(--green); }
.sidebar-status { margin-top: auto; padding: 18px 0; border-top: 1px solid var(--line); }
.sidebar-status > div { display: flex; align-items: center; gap: 9px; padding: 5px 10px; color: var(--muted); font-size: 12px; }
.sidebar-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(239, 179, 91, .08); }
.sidebar-status i.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(55, 211, 154, .08); }
.sidebar-status i.bad { background: var(--danger); }
.logout-button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}
.logout-button:hover { border-color: var(--line-bright); color: var(--text); }

.dashboard { grid-column: 2; width: min(100%, 1480px); margin: 0 auto; padding: 34px 34px 52px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.topbar h1 { margin: 0; font-size: 31px; line-height: 1.15; letter-spacing: -.02em; }
.subline { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.period-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: rgba(11, 17, 26, .72); }
.period-switch button {
  min-width: 58px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--dim);
  font-size: 11px;
  cursor: pointer;
}
.period-switch button.active { background: var(--panel-strong); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.refresh-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(11, 17, 26, .72);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.refresh-button:hover { border-color: var(--line-bright); color: white; }
.refresh-button.loading { animation: rotate .8s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.metric-card, .panel {
  border: 1px solid rgba(32, 45, 60, .9);
  background: linear-gradient(145deg, rgba(16, 24, 36, .92), rgba(10, 16, 25, .9));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .12);
}
.metric-card { min-height: 137px; padding: 19px 20px; border-radius: 14px; }
.metric-card > div { display: flex; align-items: center; justify-content: space-between; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card i:not(.pulse) { width: 8px; height: 8px; border-radius: 2px; }
.metric-blue { background: var(--blue); }
.metric-green { background: var(--green); }
.metric-amber { background: var(--amber); }
.metric-card strong { display: block; margin-top: 14px; font: 750 29px/1.1 var(--mono); }
.metric-card p { margin: 6px 0 0; color: var(--dim); font: 10px/1 var(--mono); text-transform: uppercase; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(55, 211, 154, .08); animation: pulse 2s ease infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(55, 211, 154, 0); } }

.panel { border-radius: 16px; padding: 22px; }
.trend-panel { margin-bottom: 12px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-kicker { margin: 0 0 5px; color: var(--green); font: 650 9px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.panel h2 { margin: 0; font-size: 16px; font-weight: 700; }
.quiet { color: var(--dim); font: 9px/1 var(--mono); letter-spacing: .1em; }
.legend { display: flex; align-items: center; gap: 16px; color: var(--dim); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 2px; }
.line-blue { background: var(--blue); }
.line-green { background: var(--green); }
.chart-wrap { height: 260px; position: relative; margin-top: 20px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 12px; }
.trend-foot { display: flex; gap: 28px; padding-top: 14px; border-top: 1px solid rgba(32, 45, 60, .7); color: var(--dim); font-size: 11px; }
.trend-foot strong { margin-left: 6px; color: var(--muted); font-family: var(--mono); }

.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.wide-left { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); }
.list-panel { min-height: 318px; }
.rank-list, .table-list { display: grid; gap: 11px; margin-top: 22px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; }
.rank-copy { min-width: 0; }
.rank-title { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.rank-title span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.rank-title b { color: var(--dim); font: 10px/1 var(--mono); }
.rank-track { height: 4px; overflow: hidden; border-radius: 3px; background: rgba(48, 68, 92, .42); }
.rank-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #6aa7ff); }
.rank-row:nth-child(even) .rank-track i { background: linear-gradient(90deg, var(--green), #64e3b7); }
.table-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(32, 45, 60, .58);
}
.table-row:last-child { border-bottom: 0; }
.table-row > i { color: var(--dim); font: 9px/1 var(--mono); font-style: normal; }
.table-row span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.table-row strong { color: var(--text); font: 650 11px/1 var(--mono); }
.empty-row { min-height: 120px; display: grid; place-items: center; color: var(--dim); font-size: 12px; }

.health-panel { margin-bottom: 12px; }
.health-summary { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 11px; }
.health-summary i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.health-summary.ok { color: var(--green); }
.health-summary.ok i { background: var(--green); }
.health-summary.bad { color: var(--danger); }
.health-summary.bad i { background: var(--danger); }
.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 21px; }
.health-item {
  min-height: 76px;
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid rgba(32, 45, 60, .75);
  border-radius: 11px;
  background: rgba(7, 12, 20, .45);
}
.health-item > i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.health-item.bad > i { background: var(--danger); }
.health-item span { display: block; font-size: 12px; }
.health-item small { display: block; margin-top: 4px; color: var(--dim); font: 9px/1 var(--mono); }
.health-item strong { color: var(--muted); font: 650 10px/1 var(--mono); }
.resource-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-top: 22px; padding-top: 20px; border-top: 1px solid rgba(32, 45, 60, .72); }
.resource-grid span { color: var(--dim); font-size: 10px; }
.resource-grid strong { float: right; font: 650 11px/1 var(--mono); }
.resource-bar { height: 4px; overflow: hidden; margin-top: 10px; border-radius: 3px; background: rgba(48, 68, 92, .4); }
.resource-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .3s; }
.compact-panels .list-panel { min-height: 270px; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 25px 4px 0; color: var(--dim); font-size: 10px; }
footer span { color: var(--muted); font-family: var(--mono); }
footer p { margin: 0; text-align: right; }
.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 15px;
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  background: #111a27;
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr); }
  .sidebar { width: 200px; }
  .dashboard { padding: 28px 22px 44px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .wide-left { grid-template-columns: 1fr 1fr; }
  .resource-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    z-index: 20;
    top: 0;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 12px 15px;
  }
  .brand-lockup.compact { padding: 0; }
  .sidebar nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 4px;
    margin: 12px 0 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav > p, .sidebar-status, .logout-button { display: none; }
  .site-button { width: auto; min-width: max-content; height: 36px; padding: 0 10px; }
  .site-button b { display: none; }
  .dashboard { width: 100%; padding: 24px 15px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .period-switch { flex: 1; overflow-x: auto; }
  .period-switch button { flex: 1; }
  .two-column, .wide-left { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  footer { align-items: flex-start; flex-direction: column; }
  footer p { text-align: left; }
}

@media (max-width: 500px) {
  .login-card { padding: 28px 22px; border-radius: 18px; }
  .login-card .brand-lockup { margin-bottom: 42px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 120px; padding: 16px; }
  .metric-card strong { font-size: 24px; }
  .panel { padding: 18px 16px; }
  .chart-wrap { height: 220px; }
  .trend-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .trend-foot span:last-child { grid-column: 1 / -1; }
  .resource-grid { grid-template-columns: 1fr 1fr; gap: 18px 12px; }
  .legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
