:root {
  --bg: #f3f5f8;
  --panel: #fff;
  --line: #e2e7ef;
  --text: #263241;
  --muted: #788596;
  --blue: #1683ff;
  --blue-dark: #0669d8;
  --green: #17a66a;
  --red: #e45a5a;
  --sidebar: #202632;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 188px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

button, input, select { font: inherit; }

button, .top-actions a {
  border: 0;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  padding: 9px 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover, .top-actions a:hover { background: var(--blue-dark); }

.danger {
  background: var(--red);
}

.danger:hover {
  background: #c84343;
}

.ghost {
  border: 1px solid #d5dbe5;
  background: #fff;
  color: #4f5c70;
}

.ghost:hover { background: #f8fafc; }

.sidebar {
  background: var(--sidebar);
  color: #c9d2df;
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

nav {
  display: grid;
  gap: 3px;
  padding: 14px 0;
}

.code-switcher {
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.code-switcher button {
  width: 100%;
  padding: 8px 10px;
  background: var(--green);
}

.code-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.code-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 4px;
  color: #dbe3ee;
  background: rgba(255,255,255,.03);
  cursor: pointer;
}

.code-item.active,
.code-item:hover {
  border-color: rgba(255,255,255,.24);
  background: #2b3342;
}

.code-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.code-item small {
  color: #93a1b4;
  font-size: 12px;
}

nav a {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  color: #c9d2df;
  text-decoration: none;
}

nav a.active, nav a:hover {
  color: #fff;
  background: #2b3342;
}

html {
  scroll-behavior: smooth;
}

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

.topbar, .panel-head, .top-actions, .inline-actions {
  display: flex;
  align-items: center;
}

.topbar, .panel-head {
  justify-content: space-between;
  gap: 16px;
}

.top-actions, .inline-actions { gap: 10px; }

h1 {
  margin: 0 0 7px;
  font-size: 25px;
}

p {
  margin: 0;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

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

.metric {
  padding: 18px 20px;
}

.metric span, .metric small {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0;
  font-size: 26px;
  font-weight: 500;
}

.panel {
  margin-bottom: 16px;
  scroll-margin-top: 18px;
}

.panel-head {
  min-height: 54px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

#entryText {
  color: var(--muted);
  font-size: 13px;
}

.config-grid, .dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
}

.live-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
  padding: 16px;
}

.live-body .config-grid {
  padding: 0;
}

.entry-qr {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfe;
  text-align: center;
}

.entry-qr img {
  width: 168px;
  height: 168px;
  object-fit: contain;
  border: 1px solid #d7dfe9;
  border-radius: 4px;
  background: #fff;
}

.entry-qr small {
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: grid;
  gap: 7px;
  color: #526073;
}

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

input, select {
  width: 100%;
  height: 36px;
  border: 1px solid #cfd7e3;
  border-radius: 4px;
  padding: 0 10px;
  color: var(--text);
  outline: none;
  background: #fff;
}

input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 131, 255, .12);
}

.config-grid button {
  width: max-content;
}

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

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  text-align: center;
}

th {
  height: 44px;
  background: #fafbfc;
  color: #596678;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}

td {
  height: 60px;
  border-bottom: 1px solid var(--line);
}

.qr-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 1px solid #d7dfe9;
  border-radius: 3px;
  vertical-align: middle;
}

.status { color: var(--green); }
.status.off { color: var(--red); }

.ops button {
  padding: 0 3px;
  color: var(--blue);
  background: transparent;
}

.ops button:hover {
  color: var(--blue-dark);
  background: transparent;
}

.ops span { color: #c8d0db; }

.pager {
  padding: 13px 16px;
  color: var(--muted);
  text-align: right;
}

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

.records {
  display: grid;
  padding: 8px 16px 16px;
}

.record {
  display: grid;
  grid-template-columns: 92px 1fr 150px;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: #526073;
  font-size: 13px;
}

.empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.charts {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 58px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

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

dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 5px;
  box-shadow: 0 20px 70px rgba(20, 30, 45, .25);
}

dialog::backdrop { background: rgba(24, 31, 42, .38); }

dialog header, dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

dialog footer {
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.close {
  width: 30px;
  height: 30px;
  padding: 0;
  color: #7b8797;
  background: #fff;
  font-size: 22px;
}

.close:hover { background: #f6f8fb; }

@media (max-width: 980px) {
  body { grid-template-columns: 160px minmax(0, 1fr); }
  .sidebar { display: block; }
  nav a { padding: 0 14px; }
  .brand { padding: 0 14px; }
  .brand strong { font-size: 13px; }
  .topbar, .panel-head { align-items: flex-start; flex-direction: column; }
  .metrics, .split, .config-grid, .dialog-grid, .live-body { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .inline-actions { flex-wrap: wrap; }
}
