:root {
  --bg: #070b14;
  --bg-elevated: #0d1424;
  --line: rgba(120, 160, 220, 0.14);
  --text: #e8eefc;
  --muted: #93a0bd;
  --accent: #00e5a8;
  --accent-2: #4f8cff;
  --danger: #ff6b8a;
  --warn: #ffc857;
  --font: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

button,
input {
  font: inherit;
}

.bg-grid,
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.bg-grid {
  background-image:
    linear-gradient(rgba(79, 140, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 140, 255, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 30%, black, transparent 72%);
  animation: grid-drift 28s linear infinite;
}

.bg-glow {
  background:
    radial-gradient(circle at 18% 12%, rgba(0, 229, 168, 0.16), transparent 30%),
    radial-gradient(circle at 82% 8%, rgba(79, 140, 255, 0.18), transparent 32%),
    radial-gradient(circle at 50% 88%, rgba(0, 229, 168, 0.07), transparent 36%);
}

@keyframes grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 48px, 48px 48px; }
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 0;
}

.ecosystem {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: color 0.2s ease;
}

.ecosystem:hover {
  color: var(--text);
}

.top__nav {
  display: flex;
  gap: 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.top__nav a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
}

.top__nav a:hover,
.top__nav a[aria-current="page"] {
  color: var(--accent);
}

.top__nav a[aria-current="page"] {
  font-weight: 600;
}

.stage {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 4.5rem) 0 4rem;
}

.brand {
  font-size: clamp(2.4rem, 6.5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.95;
  background: linear-gradient(120deg, #fff 20%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  transform: translateY(16px);
  animation: rise 0.65s ease forwards;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.75rem;
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.65s ease 0.1s forwards;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 999px;
  transition: color 0.2s ease, background 0.2s ease;
}

.tab:hover,
.tab.is-active {
  color: var(--accent);
}

.tab.is-active {
  font-weight: 600;
}

.panel[hidden] {
  display: none;
}

.panel {
  margin-top: 1.75rem;
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.65s ease 0.18s forwards;
}

.headline {
  max-width: 20ch;
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.lead {
  margin-top: 0.7rem;
  max-width: 42ch;
  color: var(--muted);
  font-size: 1.02rem;
}

.empty {
  margin-top: 2.5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
}

.empty__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.empty__text {
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.gate {
  margin-top: 2rem;
  max-width: 420px;
}

.gate__label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.gate__row {
  display: flex;
  gap: 0.6rem;
}

.gate__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(13, 20, 36, 0.85);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.gate__input:focus {
  border-color: rgba(0, 229, 168, 0.55);
}

.gate__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid rgba(0, 229, 168, 0.35);
  background: rgba(0, 229, 168, 0.12);
  color: var(--accent);
  border-radius: 10px;
  padding: 0.75rem 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.gate__btn:hover {
  background: rgba(0, 229, 168, 0.2);
  border-color: rgba(0, 229, 168, 0.55);
}

.gate__error {
  margin-top: 0.65rem;
  color: var(--danger);
  font-size: 0.88rem;
}

.monitor-head {
  margin-bottom: 0;
}

.add-form {
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 0.6rem;
}

.hint {
  margin-top: 0.75rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.net-list {
  margin-top: 1.75rem;
  border-top: 1px solid var(--line);
}

.net {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) minmax(8rem, 14rem) auto minmax(220px, 1fr) auto;
  gap: 0.85rem 1rem;
  align-items: center;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}

.net--readonly {
  grid-template-columns: minmax(7rem, 11rem) minmax(8rem, 14rem) auto minmax(220px, 1fr);
}

.net__name {
  display: block;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.net__cidr {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.net__alive-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  min-width: 7.5rem;
}

.net__alive {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 6ch;
  text-align: right;
}

.net__alive.is-wait {
  color: var(--muted);
}

.net__alive.is-err {
  color: var(--danger);
}

.net__missing {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
  max-height: 7.5rem;
  overflow: auto;
}

.net__missing.is-empty {
  min-height: 0;
}

.net__miss {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.net__miss--ok {
  color: #3dba7a;
}

.net__miss--warn {
  color: #d4a017;
}

.net__miss--crit {
  color: var(--danger);
}

.net__deltas {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.25;
  color: var(--muted);
}

.net__delta.is-up {
  color: var(--accent);
}

.net__delta.is-down {
  color: var(--danger);
}

.net__delta.is-flat,
.net__delta.is-na {
  color: var(--muted);
}

.net__chart {
  width: 100%;
  min-width: 280px;
  height: 44px;
  display: block;
}

.net__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.net__move {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  transition: color 0.2s ease;
}

.net__move:hover:not(:disabled) {
  color: var(--text);
}

.net__move:disabled {
  opacity: 0.25;
  cursor: default;
}

.net__del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.35rem 0.4rem;
  transition: color 0.2s ease;
}

.net__del:hover {
  color: var(--danger);
}

.net--sortable {
  cursor: grab;
}

.net--sortable.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.net--sortable.is-drop-target {
  border-top-color: var(--accent);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 720px) {
  .add-form {
    grid-template-columns: 1fr;
  }

  .net,
  .net--readonly {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id actions"
      "missing missing"
      "alive chart";
    gap: 0.55rem 1rem;
  }

  .net__id { grid-area: id; }
  .net__missing {
    grid-area: missing;
    max-height: 6rem;
  }
  .net__alive-wrap {
    grid-area: alive;
    align-items: flex-start;
  }
  .net__alive { text-align: left; }
  .net__deltas { align-items: flex-start; }
  .net__chart {
    grid-area: chart;
    justify-self: stretch;
    min-width: 0;
  }
  .net__actions {
    grid-area: actions;
    justify-self: end;
    flex-direction: row;
    align-items: center;
    gap: 0.1rem;
  }
  .net__del { justify-self: end; }
}

@media (max-width: 640px) {
  .top__nav {
    display: none;
  }

  .tab {
    flex: 1;
    padding-inline: 0.5rem;
    font-size: 0.88rem;
  }

  .gate__row {
    flex-direction: column;
  }
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

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

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 229, 168, 0.35);
  background: rgba(0, 229, 168, 0.12);
  color: var(--accent);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn:hover:not(:disabled) {
  background: rgba(0, 229, 168, 0.2);
  border-color: rgba(0, 229, 168, 0.55);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
  font-weight: 600;
}

.btn--ghost:hover:not(:disabled) {
  border-color: rgba(0, 229, 168, 0.35);
  background: rgba(0, 229, 168, 0.08);
}

.btn--sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

.btn--icon {
  min-width: 2rem;
  padding-inline: 0.45rem;
  font-family: var(--mono);
  line-height: 1.2;
}

.server-form {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.9fr auto;
  gap: 0.65rem;
  align-items: end;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field span {
  font-size: 0.8rem;
  color: var(--muted);
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(13, 20, 36, 0.85);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  outline: none;
}

.input:focus {
  border-color: rgba(0, 229, 168, 0.55);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.servers-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.server-row {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.server-row__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.server-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.server-row__order {
  display: inline-flex;
  gap: 0.15rem;
}

.server-row__title {
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.7rem;
}

.server-row__scan-time {
  font-weight: 500;
  font-size: 0.82rem;
  font-family: var(--mono);
  color: var(--muted);
}

.server-row__meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
  margin: 0.25rem 0 0;
}

.srv-ops {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.55rem;
}

@media (max-width: 900px) {
  .srv-ops {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .server-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .srv-ops {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .server-form {
    grid-template-columns: 1fr;
  }
}

.srv-op {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  background: #10182a;
}

.srv-op--ok {
  border-color: rgba(0, 229, 168, 0.45);
}

.srv-op--fail {
  border-color: rgba(255, 107, 138, 0.4);
}

.srv-op__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.srv-op__top strong {
  font-size: 0.88rem;
  color: #f2f6ff;
}

.srv-op__badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.12rem 0.4rem;
  color: #041018;
  background: var(--accent);
}

.srv-op--fail .srv-op__badge {
  color: #fff;
  background: var(--danger);
}

.srv-op__ping {
  color: #b7c3de;
  font-size: 0.8rem;
  font-family: var(--mono);
}

.servers-log {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}
