:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d8dee6;
  --text: #1f2933;
  --muted: #667085;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --warn: #b54708;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar strong {
  font-size: 20px;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button,
nav a {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

button:hover,
button.active,
nav a:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.primary-action,
form button,
.section-title button {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

.intro h1,
.admin-head h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

p {
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.stack-form {
  display: grid;
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 14px;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.wide,
.grid-form button {
  grid-column: 1 / -1;
}

.message {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 18px;
  background: #ecfdf3;
  color: #027a48;
  border: 1px solid #abefc6;
}

.message.error {
  background: #fef3f2;
  color: var(--danger);
  border-color: #fecdca;
}

.result code {
  display: block;
  overflow-wrap: anywhere;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin: 6px 0 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.result-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.result-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.admin-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-login,
#admin-key-form {
  display: flex;
  gap: 8px;
  min-width: min(420px, 100%);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.compact-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.network-map {
  width: 100%;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f6;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: -1px;
}

.legend-dot.sending {
  background: #079455;
}

.legend-dot.enabled {
  background: #dc6803;
}

.legend-dot.disabled {
  background: #98a2b3;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.danger {
  color: var(--danger);
  border-color: #fecdca;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar,
  .admin-head,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-form,
  .split,
  .result-grid,
  .compact-stats,
  .stats {
    grid-template-columns: 1fr;
  }

  .admin-login,
  #admin-key-form {
    flex-direction: column;
  }
}
