:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #d8dee9;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --code: #0f172a;
}

* { box-sizing: border-box; }

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

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

button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 36px;
}

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

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

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

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

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

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

.login-card {
  width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
}

.login-title {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-subtitle, .muted {
  color: var(--muted);
}

.warning-box {
  border: 1px solid #fecaca;
  background: var(--red-bg);
  color: #991b1b;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 18px 0;
}

.field {
  margin: 14px 0;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--red);
  margin-top: 10px;
}

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

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 18px;
}

.env-badge {
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
}

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

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: #111827;
  color: #d1d5db;
  padding: 16px 12px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d1d5db;
  border-color: transparent;
  margin-bottom: 6px;
}

.nav-item.active {
  background: #243244;
  color: #fff;
}

.content {
  padding: 24px;
  overflow: auto;
}

.page-title {
  margin: 0;
  font-size: 24px;
}

.page-subtitle {
  color: var(--muted);
  margin: 6px 0 18px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}

.toolbar input {
  max-width: 640px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 14px 0;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  font-weight: 700;
}

.panel-body {
  padding: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

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

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

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: #e5e7eb;
}

.wx-cell {
  display: flex;
  gap: 10px;
  min-width: 230px;
}

.truncate {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
}

.badge.on {
  border-color: #bbf7d0;
  color: #166534;
  background: #f0fdf4;
}

.badge.info {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
}

.badge.strong {
  border-color: var(--green);
  color: #166534;
  background: #f0fdf4;
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.25);
}

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

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

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

.kv dd {
  margin: 0;
  word-break: break-word;
}

.sensitive {
  color: #991b1b;
  background: var(--red-bg);
  border-radius: 4px;
  padding: 2px 5px;
}

pre {
  background: var(--code);
  color: #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
  max-height: 360px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  display: grid;
  place-items: center;
  z-index: 30;
}

.modal {
  width: min(860px, calc(100vw - 48px));
  max-height: 80vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal .panel-header {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--panel);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  z-index: 40;
}

.toast.error {
  background: var(--red);
}

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

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 1100px) {
  .detail-grid, .split {
    grid-template-columns: 1fr;
  }
}
