:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-soft: #fbfbfc;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --accent: #111827;
  --accent-soft: #f3f4f6;
  --danger: #dc2626;
  --success: #047857;
  --warning: #b45309;
  --focus: #2563eb;
}

* {
  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;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-weight: 650;
  font-size: 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #111827;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 750;
}

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

.nav button {
  height: 38px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button.active,
.nav button:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.content {
  padding: 28px;
  min-width: 0;
}

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

.title {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 720;
}

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

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.panel-pad {
  padding: 18px;
}

.metric {
  display: grid;
  gap: 8px;
}

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

.metric-value {
  font-size: 28px;
  font-weight: 760;
}

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

.section-title {
  font-weight: 680;
  font-size: 15px;
}

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

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stack {
  display: grid;
  gap: 10px;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.input {
  height: 40px;
  padding: 0 11px;
}

.textarea {
  min-height: 110px;
  padding: 11px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.button {
  height: 38px;
  border-radius: 7px;
  padding: 0 12px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.button.ghost {
  background: transparent;
  color: var(--muted-strong);
}

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

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

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

td.wrap {
  white-space: normal;
  word-break: break-all;
}

.badge {
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  display: inline-flex;
  align-items: center;
  background: var(--accent-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
}

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

.badge.off {
  background: #f3f4f6;
  color: var(--muted);
}

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

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

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

.login-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 60px rgb(17 24 39 / 0.08);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  border-radius: 7px;
  box-shadow: 0 16px 50px rgb(17 24 39 / 0.18);
  z-index: 20;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(17 24 39 / 0.38);
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 10;
}

.modal {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
}

.hidden {
  display: none !important;
}

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

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

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

  .nav button {
    justify-content: center;
    text-align: center;
  }

  .content {
    padding: 18px;
  }

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

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
