:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #101c2e;
  --panel-2: #142235;
  --line: #24364d;
  --text: #edf5ff;
  --muted: #8fa4bb;
  --accent: #1dd6a3;
  --accent-2: #5d8cff;
  --warn: #ffb545;
  --danger: #ff5b7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #1a2a42;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  background: #0c1829;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent-2);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #0e1728;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand strong {
  display: block;
}

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

.logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
}

.nav-item.active {
  color: var(--accent);
  background: #0d2a38;
  border-color: #0d2a38;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.app {
  min-width: 0;
}

.topbar {
  min-height: 70px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: #142033;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-row {
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(170px, 240px) auto;
  gap: 10px;
}

.message {
  margin: 18px 28px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101c2e;
  color: var(--accent);
}

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

.hidden,
.view {
  display: none;
}

.view.active {
  display: block;
  padding: 24px 28px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric,
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin: 8px 0 3px;
  font-size: 28px;
  color: var(--accent);
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  min-height: 58px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  margin: 0;
  font-size: 16px;
}

.table-wrap {
  overflow: auto;
  min-height: 220px;
}

.table-wrap.compact {
  min-height: 0;
  max-height: 320px;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #1e2d42;
  text-align: left;
  color: #c9d8e8;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

pre {
  margin: 0;
  padding: 18px;
  min-height: 80px;
  color: #c9d8e8;
  white-space: pre-wrap;
}

.ok {
  color: var(--accent);
}

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

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar,
  .auth-row,
  .grid.two,
  .metrics {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
