:root {
  --bg: #0f141b;
  --card: #18212c;
  --card-2: #1f2c3a;
  --text: #e7f0fb;
  --muted: #9ab0c8;
  --ok: #3ecf8e;
  --warn: #f7b955;
  --bad: #f47174;
  --accent: #7ac7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, #1d2a39, #0f141b 55%);
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 16px;
}

.panel {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid #314459;
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
}

.sub,
#manaLabel {
  color: var(--muted);
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #35506c;
  border-radius: 12px;
  padding: 12px;
  background: rgba(10, 18, 26, 0.5);
}

.card-category {
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  min-height: calc(1.25em * 2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.status {
  font-weight: 600;
  min-height: 28px;
  display: flex;
  align-items: center;
}

.status.running {
  color: var(--ok);
}

.status.stopped {
  color: var(--warn);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

form {
  display: grid;
  gap: 10px;
}

textarea,
button {
  border-radius: 10px;
  border: 1px solid #486789;
  padding: 10px;
  font-size: 14px;
}

textarea {
  background: #0f1721;
  color: var(--text);
}

button {
  cursor: pointer;
  background: #295a87;
  color: white;
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

button.is-loading {
  position: relative;
  padding-right: 36px;
}

button.is-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.9s linear infinite;
}

button.secondary {
  background: #2a3644;
}

button.action {
  width: 100%;
  margin-top: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.badge.online {
  background: #123d2a;
  color: #66efb0;
}

.badge.offline {
  background: #3d1517;
  color: #ff9598;
}

.error {
  color: var(--bad);
  margin-top: 8px;
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 12, 0.72);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid #3b5674;
  border-radius: 14px;
  padding: 14px;
}

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

.modal-header h3 {
  margin: 0;
}

.modal-body {
  display: grid;
  gap: 8px;
}

.modal-body h3,
.modal-body p {
  margin: 0;
}

.endpoint-list {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #38536e;
  background: rgba(9, 15, 23, 0.45);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.actions-row button {
  flex: 1 1 220px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .container {
    margin-top: 12px;
  }

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

  .modal {
    padding: 8px;
  }

  .modal-card {
    max-height: calc(100vh - 16px);
  }
}
