:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #18242f;
  --muted: #667487;
  --line: #dfe6ee;
  --green: #07c160;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 50px rgba(24, 36, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 260px;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #3b4756;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #eaf7f0;
  color: #066f3d;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(7, 193, 96, 0.14);
}

.topbar-actions[data-tone="loading"] .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.14);
}

.topbar-actions[data-tone="error"] .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.14);
}

.section {
  display: none;
}

.section.active {
  display: block;
}

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 30px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel.wide {
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.primary-button,
.text-button {
  min-height: 34px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  border: 0;
  padding: 0 13px;
  background: var(--text);
  color: white;
}

.text-button {
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #f8fafc;
  color: #334155;
}

.inline-actions,
.row-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions .text-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.text-button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: #fbfdff;
}

.timeline-item p,
.policy p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.severity {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
}

.severity.high {
  background: var(--red);
}

.severity.medium {
  background: var(--amber);
}

.severity.ok {
  background: var(--green);
}

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

.boundary-list li {
  padding: 11px 0;
  border-bottom: 1px solid #edf1f5;
  color: #334155;
}

.boundary-list li:last-child {
  border-bottom: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.toolbar input {
  width: min(420px, 100%);
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  color: #273444;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #e8f7ef;
  color: #057a45;
}

.badge.warn {
  background: #fff4df;
  color: #9a5b00;
}

.badge.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.muted {
  background: #eef2f7;
  color: #536173;
}

.wallet {
  padding: 20px;
  border-radius: 8px;
  background: var(--surface-2);
}

.wallet strong,
.wallet span {
  display: block;
}

.wallet strong {
  font-size: 34px;
  line-height: 1;
}

.wallet span {
  margin-top: 10px;
  color: var(--muted);
}

.proxy-pool {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: #fbfdff;
}

.proxy-pool span {
  color: var(--muted);
}

.proxy-pool strong {
  max-width: 70%;
  overflow-wrap: anywhere;
  color: #263447;
}

.proxy-pool[data-tone="warn"] {
  background: #fffaf0;
}

.mini-bars {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 140px;
  margin-top: 18px;
}

.mini-bars span {
  flex: 1;
  min-width: 16px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #2b8aeb, #07c160);
}

.policy {
  padding: 14px 0;
  border-bottom: 1px solid #edf1f5;
}

.policy:last-child {
  border-bottom: 0;
}

.policy strong {
  display: block;
  margin-top: 9px;
}

.api-list {
  display: grid;
  gap: 10px;
}

.api-list code {
  display: block;
  padding: 12px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: #f8fafc;
  color: #263447;
  white-space: normal;
  word-break: break-word;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1020px) {
  .admin-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .toolbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .primary-button,
  .text-button {
    justify-content: center;
    width: 100%;
  }

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

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    overflow-x: auto;
  }

  table {
    min-width: 680px;
  }
}
