:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --primary: #1f6feb;
  --primary-weak: #eaf2ff;
  --ok: #16875d;
  --warn: #b7791f;
  --bad: #c24141;
  --ink: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.ghost {
  background: var(--primary-weak);
  border-color: #b7d2ff;
  color: #0b54c5;
}

button.danger {
  border-color: #f0b8b8;
  color: var(--bad);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

textarea {
  min-height: 92px;
  resize: vertical;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(20, 31, 56, 0.08);
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-box p {
  margin: 0 0 24px;
  color: var(--muted);
}

.alert {
  border: 1px solid #f0b8b8;
  background: #fff1f1;
  color: var(--bad);
  border-radius: 6px;
  padding: 9px 10px;
  margin-bottom: 14px;
  font-size: 13px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

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

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.check input,
.field input[type="checkbox"] {
  width: auto;
}

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.side {
  background: #111827;
  color: #e5e7eb;
  padding: 20px 14px;
}

.brand {
  padding: 0 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  margin-top: 6px;
  color: #a7b0c0;
  font-size: 12px;
}

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

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group > span {
  padding: 6px 10px 2px;
  color: #8ea0b8;
  font-size: 12px;
  font-weight: 650;
}

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #cbd5e1;
  padding: 10px;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 22px;
}

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

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

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

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.metric {
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

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

.mt {
  margin-top: 12px;
}

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

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

.toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar.compact {
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
}

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

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

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

th {
  color: var(--muted);
  background: #fafbfc;
  font-weight: 600;
  white-space: nowrap;
}

td .title {
  font-weight: 650;
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f7;
  color: #334155;
  white-space: nowrap;
}

.badge.ok {
  background: #e9f8f2;
  color: var(--ok);
}

.badge.bad {
  background: #fff1f1;
  color: var(--bad);
}

.badge.warn {
  background: #fff8e8;
  color: var(--warn);
}

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

.switch-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #b7d2ff;
  border-radius: 6px;
  background: var(--primary-weak);
  color: #0b54c5;
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.bars {
  display: grid;
  gap: 9px;
}

.bar {
  display: grid;
  grid-template-columns: 92px 1fr 34px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.track {
  height: 8px;
  border-radius: 99px;
  background: #edf1f7;
  overflow: hidden;
}

.fill {
  height: 100%;
  background: var(--primary);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  display: grid;
  justify-items: end;
  z-index: 20;
}

.drawer {
  width: min(720px, 100%);
  height: 100vh;
  overflow: auto;
  border-radius: 0;
  border-right: 0;
  padding: 20px;
}

.drawer h2 {
  margin: 0;
}

.section-title {
  margin-top: 20px !important;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

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

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

.detail-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 14px;
  font-size: 14px;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
}

.raw-text {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  max-height: 280px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

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

  .side {
    position: sticky;
    top: 0;
    z-index: 10;
  }

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

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

@media (max-width: 620px) {
  .main {
    padding: 14px;
  }

  .metrics,
  .grid,
  .toolbar,
  .toolbar.compact,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
