:root {
  --bg: #0b0f14;
  --surface: #121820;
  --border: #243041;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #5b9dff;
  --accent-dim: #3d6fb8;
  --up: #3dd68c;
  --down: #ff7b72;
  --radius: 12px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(91, 157, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 157, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, black, transparent);
  pointer-events: none;
}

.layout {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: -0.02em;
}

.brand-text {
  font-weight: 600;
  font-size: 1.05rem;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.9rem;
}

.topnav a {
  color: var(--muted);
  text-decoration: none;
}

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

.btn-ghost {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap: 2rem;
  align-items: start;
}

@media (max-width: 860px) {
  .main {
    grid-template-columns: 1fr;
  }

  .metrics {
    order: 2;
  }
}

.metrics {
  display: grid;
  gap: 1rem;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.metric-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.metric-value {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.metric-delta {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.metric-delta.up {
  color: var(--up);
}

.metric-delta.down {
  color: var(--down);
}

.metric-delta.neutral {
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem 1.75rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.panel-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(91, 157, 255, 0.12);
  border: 1px solid rgba(91, 157, 255, 0.25);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.65rem;
  font-weight: 700;
}

.lead {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-alert {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #ffb4ab;
  background: rgba(255, 123, 114, 0.1);
  border: 1px solid rgba(255, 123, 114, 0.35);
}

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

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form.is-error input {
  border-color: rgba(255, 123, 114, 0.55);
}

.login-form.shake {
  animation: shake 0.42s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.login-form input {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0a0e13;
  color: var(--text);
  font: inherit;
}

.login-form input:focus {
  outline: 2px solid rgba(91, 157, 255, 0.45);
  border-color: var(--accent-dim);
}

.btn-primary {
  margin-top: 0.25rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.75;
  cursor: wait;
}

.btn-primary.is-loading {
  position: relative;
}

.footer-links {
  margin: 1.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Modals */
.modal {
  position: relative;
  margin: auto;
  padding: 1.75rem 1.5rem 1.5rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.55);
}

.modal::backdrop {
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(4px);
}

.modal-wide {
  max-width: 520px;
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.modal h2 {
  margin: 0 2rem 0.35rem 0;
  font-size: 1.25rem;
}

.modal-lead {
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.modal-form input,
.modal-form textarea {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0a0e13;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.modal-form textarea {
  min-height: 4.5rem;
}

.modal-feedback {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.modal-feedback[hidden] {
  display: none;
}

.modal-feedback.is-error {
  color: #ffb4ab;
  background: rgba(255, 123, 114, 0.1);
  border: 1px solid rgba(255, 123, 114, 0.35);
}

.modal-feedback.is-success {
  color: #9ae6b0;
  background: rgba(61, 214, 140, 0.1);
  border: 1px solid rgba(61, 214, 140, 0.35);
}

.api-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.api-tab {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0a0e13;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.api-tab.is-active {
  color: var(--text);
  border-color: var(--accent-dim);
  background: rgba(91, 157, 255, 0.12);
}

.api-panel {
  display: none;
}

.api-panel.is-active {
  display: block;
}

.api-note,
.api-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.api-endpoints {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.api-endpoints li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: #0a0e13;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.method {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.method.get {
  color: #7ee8b2;
  background: rgba(61, 214, 140, 0.15);
}

.method.post {
  color: #9ec5ff;
  background: rgba(91, 157, 255, 0.15);
}

.api-endpoints code {
  font-family: var(--mono);
  font-size: 0.75rem;
  flex: 1;
  min-width: 8rem;
}

.btn-copy {
  margin-left: auto;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.btn-copy:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.mcp-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: #0a0e13;
  border: 1px solid var(--border);
}

.mcp-box code {
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
}

.api-bullets {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.api-bullets li {
  margin-bottom: 0.35rem;
}

.copy-toast {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--up);
}

.copy-toast[hidden] {
  display: none;
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.status-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.status-list li:last-child {
  border-bottom: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.ok {
  background: var(--up);
  box-shadow: 0 0 8px rgba(61, 214, 140, 0.5);
}

.status-dot.warn {
  background: #e3b341;
}

.status-list strong {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.foot {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.endpoint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: #0a0e13;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

@media (max-width: 600px) {
  .topnav a:not(.btn-ghost) {
    display: none;
  }
}
