:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e6e9f2;
  --brand: #1464f4;
  --brand-dark: #0f4fc4;
  --ok: #0f9f6e;
  --bad: #d92d20;
  --warn: #d68400;
  --soft: #eef4ff;
  --shadow: 0 16px 44px rgba(20, 35, 70, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.login-shell {
  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: var(--shadow);
}

.login-box h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

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

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

.sidebar {
  background: #111827;
  color: #fff;
  padding: 18px 14px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  padding: 10px 10px 20px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: #cfd6e4;
  background: transparent;
  padding: 11px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  text-align: left;
}

.nav-btn.active,
.nav-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

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

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

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

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

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

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 35, 70, .04);
}

.panel-pad {
  padding: 18px;
}

.stat {
  padding: 16px;
}

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

.stat strong {
  font-size: 28px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

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

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 13px;
  color: #344054;
}

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

.textarea {
  min-height: 118px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

.btn:hover {
  background: var(--brand-dark);
}

.btn.secondary {
  background: #eef2f8;
  color: #22304a;
}

.btn.secondary:hover {
  background: #e1e7f1;
}

.btn.danger {
  background: #fee4e2;
  color: #b42318;
}

.btn.small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 13px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

th {
  color: #475467;
  background: #f8fafd;
  font-weight: 700;
}

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

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  word-break: break-all;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f8;
  color: #475467;
}

.badge.ok {
  background: #dcfaec;
  color: #087443;
}

.badge.bad {
  background: #fee4e2;
  color: #b42318;
}

.badge.warn {
  background: #fff3d6;
  color: #9b5c00;
}

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

.qr-img {
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 20;
}

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

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    overflow-x: auto;
    gap: 6px;
  }
  .brand {
    white-space: nowrap;
    padding: 8px 10px;
  }
  .nav-btn {
    width: auto;
    white-space: nowrap;
    margin: 0;
  }
  .stats-grid,
  .two-grid,
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 14px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  th, td {
    padding: 9px;
  }
}
