:root {
  color-scheme: dark;
  --bg: #0b1115;
  --panel: #111a20;
  --panel-2: #162129;
  --line: #283640;
  --text: #e8eef2;
  --muted: #9fb0bc;
  --accent: #49a078;
  --accent-strong: #5dc18f;
  --danger: #ffb3b3;
  --focus: #7dd3fc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.stack { display: grid; gap: 24px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 17, 21, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 24px;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  flex: 1;
  gap: 8px;
}

nav a, .link {
  border-radius: 6px;
  color: var(--muted);
  padding: 8px 10px;
  text-decoration: none;
}

nav a:hover, .link:hover {
  background: var(--panel-2);
  color: var(--text);
}

nav a.active, nav a[aria-current="page"] {
  background: var(--panel-2);
  color: var(--text);
}

.subnav-wrap {
  border-bottom: 1px solid var(--line);
  background: #0d151a;
}

.subnav {
  min-height: 46px;
  align-items: center;
  flex: none;
}

main { padding: 32px 0 56px; }

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.15;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.1rem;
}

.hero {
  display: grid;
  gap: 18px;
  max-width: 760px;
  padding: 68px 0 32px;
}

.hero h1 {
  font-size: 3.5rem;
  letter-spacing: 0;
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted, .empty { color: var(--muted); }
.strong { font-weight: 650; }
.mono, pre, .token { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.break { overflow-wrap: anywhere; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat, .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat {
  display: grid;
  gap: 8px;
  padding: 20px;
}

.stat span { color: var(--muted); }
.stat strong { font-size: 2.25rem; line-height: 1; }

.panel { padding: 22px; }

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.peering-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.peering-form .endpoint-field,
.peering-form .key-field,
.peering-form .import-key-field,
.peering-form .label-field {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field-group {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.field-group legend {
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 0.38fr);
  gap: 10px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d151a;
  color: var(--text);
  font: inherit;
  padding: 10px 11px;
}

textarea { resize: vertical; }

.field-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  align-self: end;
}

.checkbox input { width: auto; }

.protected-field { align-self: center; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  padding: 9px 14px;
  text-decoration: none;
}

.button.primary {
  border-color: #3b805f;
  background: var(--accent);
  color: #06110b;
}

.button.subtle { color: var(--muted); }
.button:hover { filter: brightness(1.08); }
.wide { grid-column: 1 / -1; }

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

  .peering-form .endpoint-field,
  .peering-form .key-field,
  .peering-form .import-key-field,
  .peering-form .label-field {
    grid-column: 1;
  }
}
.logout { margin: 0; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 10px;
  white-space: nowrap;
}

.region {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 18px 0 28px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 9px;
  white-space: nowrap;
}

.badge.good {
  border-color: #34724f;
  background: #123323;
  color: #8ee7b0;
}

.badge.bad {
  border-color: #8b4141;
  background: #341719;
  color: var(--danger);
}

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

.flash {
  border: 1px solid #8b4141;
  border-radius: 8px;
  background: #341719;
  padding: 12px 14px;
}

.error { color: var(--danger); }

.details {
  display: grid;
  grid-template-columns: minmax(110px, 0.42fr) 1fr;
  gap: 10px 16px;
  margin: 0;
}

.details dt { color: var(--muted); }
.details dd { margin: 0; }

.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.section-title h2 { margin-bottom: 18px; }

.status-panel[data-refresh-failed="1"] {
  border-color: #5f4a2a;
}

.token, pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d151a;
  padding: 14px;
}

pre { margin: 0; }

@media (max-width: 720px) {
  .topbar-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0;
  }

  nav { flex-wrap: wrap; }
  .role-badge { align-self: flex-start; }
  .logout { align-self: flex-start; }
  .hero h1 { font-size: 2.5rem; }
  .page-title { align-items: start; flex-direction: column; }
  .details { grid-template-columns: 1fr; }
  .inline-fields { grid-template-columns: 1fr; }
}
