:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #11151d;
  --panel-2: #151a24;
  --border: #252d3a;
  --text: #eef3f8;
  --muted: #93a0ae;
  --muted-2: #697584;
  --teal: #2dd4bf;
  --blue: #38bdf8;
  --amber: #f59e0b;
  --rose: #fb7185;
  --green: #34d399;
  --indigo: #818cf8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.08), transparent 320px),
    radial-gradient(circle at 78% 0%, rgba(45, 212, 191, 0.09), transparent 360px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.14), transparent 360px),
    rgba(9, 11, 16, 0.94);
  backdrop-filter: blur(10px);
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #11151d;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.login-panel h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1018;
  color: var(--text);
  padding: 0 12px;
  outline: 0;
}

.login-panel input:focus {
  border-color: var(--blue);
}

.login-error {
  min-height: 18px;
  color: var(--rose);
  font-size: 13px;
}

button,
select {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

button {
  min-height: 38px;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 8px;
  background: #102437;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

.app {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

h2 {
  font-size: 16px;
  line-height: 1.15;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill,
.select-wrap {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(17, 21, 29, 0.88);
  color: var(--muted);
  padding: 0 12px;
}

.status-pill.connected .dot {
  background: var(--green);
}

.status-pill.error .dot {
  background: var(--rose);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 20px currentColor;
}

select {
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
}

.select-wrap.compact {
  flex: 0 0 auto;
}

main {
  display: grid;
  gap: 14px;
}

.section-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  background: linear-gradient(180deg, rgba(9, 11, 16, 0.98), rgba(9, 11, 16, 0.72));
  backdrop-filter: blur(12px);
}

.section-nav button {
  min-width: max-content;
  border-color: var(--border);
  background: #11151d;
  color: var(--muted);
}

.health-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.health-strip div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(17, 21, 29, 0.88);
  padding: 13px 14px;
}

.health-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.health-strip strong {
  font-size: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(17, 21, 29, 0.88);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 118px;
  padding: 16px;
}

.metric span,
.muted,
small {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 10px 0;
  font-size: 30px;
  line-height: 1;
}

.bar {
  height: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #202632;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 0.3s ease;
}

.bar.warning i {
  background: linear-gradient(90deg, var(--amber), var(--rose));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: stretch;
}

.wide-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  gap: 14px;
  align-items: stretch;
}

.chart-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 160px),
    #151a24;
  padding: 14px;
}

.chart-card.wide {
  grid-row: span 2;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.chart-head strong {
  font-size: 14px;
}

.chart-head span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

#trendChart {
  display: block;
  width: 100%;
  min-height: 280px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    #0c1018;
  background-size: 1px 56px;
}

.chart-grid {
  stroke: rgba(147, 160, 174, 0.16);
  stroke-width: 1;
}

.chart-base {
  stroke: rgba(147, 160, 174, 0.26);
  stroke-width: 1;
}

.chart-axis,
.chart-legend text {
  fill: var(--muted);
  font-size: 11px;
}

.chart-x {
  text-anchor: middle;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line.mem {
  stroke: var(--teal);
}

.chart-line.disk {
  stroke: var(--amber);
}

.chart-line.load {
  stroke: var(--blue);
}

.legend-mem {
  fill: var(--teal);
}

.legend-disk {
  fill: var(--amber);
}

.legend-load {
  fill: var(--blue);
}

.chart-empty-text {
  fill: var(--muted);
  font-size: 15px;
  text-anchor: middle;
}

.usage-bars,
.busy-list {
  display: grid;
  gap: 10px;
}

.usage-row,
.busy-row {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 8px;
  background: rgba(12, 16, 24, 0.72);
  padding: 10px;
}

.usage-main {
  min-width: 0;
}

.usage-main strong,
.busy-row strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.usage-main span,
.busy-row span,
.usage-row small,
.busy-row small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.usage-track,
.busy-meter {
  height: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #252d3a;
}

.usage-track i,
.busy-meter i {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.busy-meter i {
  background: linear-gradient(90deg, var(--amber), var(--rose));
}

.map-panel {
  min-height: 620px;
}

.map-shell {
  height: 560px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #0c1018;
  background-size: 42px 42px;
  overflow: hidden;
}

#topology {
  width: 100%;
  height: 100%;
  display: block;
}

.alert-list,
.data-list,
.space-bars,
.port-grid,
.project-grid {
  display: grid;
  gap: 10px;
}

.alert {
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  background: #171c24;
  padding: 11px 12px;
}

.alert.danger {
  border-left-color: var(--rose);
}

.alert.info {
  border-left-color: var(--blue);
}

.alert strong,
.data-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.alert span,
.data-row span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.space-row {
  display: grid;
  grid-template-columns: minmax(130px, 220px) minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
}

.space-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.space-track {
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  background: #202632;
}

.space-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--indigo));
}

.space-value {
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.port-grid {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.port-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #151a24;
  padding: 10px;
}

.port-chip strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.port-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.port-chip.public {
  border-color: rgba(251, 113, 133, 0.46);
}

.project-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.project-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #151a24;
  padding: 14px;
}

.project-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.project-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.badge {
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 999px;
  color: var(--green);
  padding: 3px 8px;
  font-size: 12px;
}

.badge.warn {
  border-color: rgba(245, 158, 11, 0.46);
  color: var(--amber);
}

.kv {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.kv div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
}

.kv span:last-child {
  color: var(--text);
  overflow-wrap: anywhere;
}

.child-bars {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.child-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.child-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-mini {
  height: 6px;
  border-radius: 8px;
  background: #252d3a;
  overflow: hidden;
}

.child-mini i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.data-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #151a24;
  padding: 11px 12px;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 1080px) {
  .metrics-grid,
  .health-strip,
  .dashboard-grid,
  .wide-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .chart-card.wide {
    grid-row: auto;
  }

  .map-panel {
    min-height: 500px;
  }

  .map-shell {
    height: 460px;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100vw - 20px, 1500px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .actions button,
  .status-pill,
  .select-wrap {
    flex: 1 1 auto;
  }

  .panel-head {
    flex-direction: column;
  }

  .select-wrap.compact {
    width: 100%;
    justify-content: space-between;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .space-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .space-value {
    text-align: left;
  }
}
