:root {
  --bg: #08070c;
  --bg-elevated: #121018;
  --bg-card: #16131f;
  --border: #262233;
  --border-soft: #1d1a27;
  --text: #f2f0f7;
  --text-dim: #948fa3;
  --text-faint: #625c72;

  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --violet-dim: #6d28d9;
  --violet-glow: rgba(139, 92, 246, 0.35);

  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;

  --radius: 14px;
  --radius-sm: 9px;
  font-family: "Inter", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 700px;
  background: radial-gradient(ellipse at center,
      var(--violet-glow) 0%,
      rgba(139, 92, 246, 0) 65%);
  pointer-events: none;
  z-index: 0;
  filter: blur(10px);
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px;
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand strong {
  font-weight: 800;
  color: var(--violet-2);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 12px 2px var(--violet-glow);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dim) 100%);
  color: white;
  box-shadow: 0 4px 20px -6px var(--violet-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px -4px var(--violet-glow);
}

.btn-full {
  width: 100%;
  padding: 12px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-danger-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn-danger-ghost:hover {
  background: rgba(248, 113, 113, 0.08);
  border-color: var(--red);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}

.stat-card {
  background: linear-gradient(160deg,
      var(--bg-card) 0%,
      var(--bg-elevated) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat-up .stat-value {
  color: var(--green);
}

.stat-down .stat-value {
  color: var(--red);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Servers grid */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
  position: relative;
}

.server-card:hover {
  border-color: var(--violet-dim);
  transform: translateY(-2px);
}

.server-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.server-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 3px;
}

.server-url {
  font-size: 12px;
  color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
  word-break: break-all;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-up {
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
}

.status-up::before {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.status-down {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

.status-down::before {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.status-unknown {
  background: rgba(148, 143, 163, 0.12);
  color: var(--text-dim);
}

.status-unknown::before {
  background: var(--text-dim);
}

.server-card-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.server-card-meta b {
  color: var(--text);
  font-weight: 600;
}

.server-card-actions {
  position: absolute;
  top: 14px;
  right: 14px;
}

.empty-state {
  color: var(--text-faint);
  padding: 40px;
  text-align: center;
  grid-column: 1 / -1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 8, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 420px;
  max-width: 92vw;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(139, 92, 246, 0.06);
}

.modal-wide {
  width: 640px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-body label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.modal-body label span {
  display: block;
  margin-bottom: 6px;
}

.modal-body input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.12s ease;
}

.modal-body input:focus {
  border-color: var(--violet);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  color: var(--red);
  font-size: 13px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 14px;
}

.form-error.hidden {
  display: none;
}

/* Detail modal */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.detail-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px;
}

.detail-stat .stat-label {
  font-size: 11px;
}

.detail-stat .stat-value {
  font-size: 19px;
}

.history-title {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}

.history-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  height: 34px;
  align-items: flex-end;
}

.history-bar-item {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-width: 3px;
}

.history-bar-item.success {
  background: var(--green);
}

.history-bar-item.error {
  background: var(--red);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
}

.history-row .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-row .dot.success {
  background: var(--green);
}

.history-row .dot.error {
  background: var(--red);
}

.history-row .h-time {
  color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
}

.history-row .h-code {
  margin-left: auto;
  color: var(--text-dim);
  font-family: "JetBrains Mono", monospace;
}

.history-row .h-msg {
  color: var(--text-faint);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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