﻿:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --surface: #f7f8fa;
  --surface-strong: #eef0f3;
  --line: #dfe3e8;
  --text: #1f2933;
  --muted: #687380;
  --soft: #8b96a3;
  --primary: #1769ff;
  --purple: #8b35e8;
  --green: #18794e;
  --orange: #ad5f00;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(31, 41, 51, .10);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(180deg, #f4f6f8 0%, var(--bg) 100%);
}
button, input, textarea, select { font: inherit; }
.shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 12px;
}
.panel {
  width: min(100%, 392px);
  min-height: calc(100vh - 24px);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px 16px 24px;
}
.admin-panel {
  width: min(100%, 980px);
}
.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}
h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}
.counter {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  min-width: 76px;
  justify-content: flex-end;
  color: #b7bdc5;
  font-weight: 700;
  font-size: 18px;
}
.counter span:first-child { color: #151b23; }
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 12px;
}
.field input {
  width: 100%;
  height: 40px;
  border: 1px solid #d9dee5;
  border-radius: 4px;
  padding: 0 12px;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 255, .12);
}
.gate-form {
  display: grid;
  gap: 12px;
}
.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 5px;
  padding: 0 14px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .12s ease;
}
.primary-button {
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
  font-weight: 650;
}
.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}
.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}
.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}
.empty-state {
  display: grid;
  gap: 6px;
  padding: 18px 14px;
  border: 1px dashed #d7dce3;
  border-radius: 6px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 13px;
}
.empty-state strong { color: var(--text); font-size: 15px; }
.groups { display: grid; gap: 14px; }
.group {
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: #fff;
}
.group-head {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: #fff;
  color: var(--text);
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  cursor: pointer;
  text-align: left;
}
.group-head:hover { background: #f8fafc; }
.group-title { font-weight: 650; font-size: 14px; }
.group-count { color: var(--muted); font-size: 12px; }
.chevron { color: var(--soft); transition: transform .16s ease; }
.group.collapsed .chevron { transform: rotate(-90deg); }
.group-body {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  padding: 12px;
  background: #fbfcfd;
  border-top: 1px solid var(--line);
}
.record {
  border: 1px solid #e1e5ea;
  border-radius: 5px;
  background: var(--surface-strong);
  overflow: hidden;
}
.record-main {
  position: relative;
  width: 100%;
  min-height: 94px;
  border: 0;
  padding: 14px 42px 12px 12px;
  background: transparent;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(58px, .8fr) minmax(68px, 1fr) minmax(76px, .9fr);
  grid-template-rows: auto auto;
  gap: 8px 10px;
  text-align: left;
}
.record-main:hover { background: rgba(255, 255, 255, .45); }
.record.expanded .record-main {
  grid-template-columns: 1fr;
  min-height: auto;
  gap: 10px;
}
.record-cn {
  grid-column: 1 / 4;
  min-width: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.record-menu {
  position: absolute;
  top: 12px;
  right: 14px;
  color: #5f6873;
  letter-spacing: 1px;
  font-weight: 700;
}
.meta {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--text);
  font-size: 13px;
}
.meta b {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}
.meta span:not(.pill) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record.expanded .record-cn,
.record.expanded .meta {
  grid-column: 1 / -1;
}
.record.expanded .meta span:not(.pill) {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.pill {
  width: fit-content;
  max-width: 82px;
  border: 1px solid #d5dbe3;
  border-radius: 999px;
  padding: 2px 9px;
  background: #f7f8fa;
  color: #4b5563;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.pill.run { color: var(--danger); border-color: rgba(180, 35, 24, .24); background: #fff3f1; }
.pill.xia { color: #6d28d9; border-color: rgba(139, 53, 232, .26); background: #f6efff; }
.pill.wei { color: var(--green); border-color: rgba(24, 121, 78, .24); background: #eefaf3; }
.record-extra {
  padding: 0 12px 12px;
  background: var(--surface-strong);
}
dl {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid #dce1e7;
  display: grid;
  gap: 8px;
}
dl div { display: grid; grid-template-columns: 46px 1fr; gap: 8px; }
dt { color: var(--muted); font-size: 12px; }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.hidden { display: none; }
.notice {
  margin-bottom: 14px;
  border: 1px solid #f0d7aa;
  border-radius: 5px;
  background: #fff9ee;
  color: #805100;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}
.admin-actions {
  display: grid;
  grid-template-columns: 1fr repeat(3, auto);
  gap: 8px;
  margin-bottom: 10px;
}
.admin-actions input,
.admin-row input,
.admin-row textarea,
.admin-row select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #d9dee5;
  border-radius: 4px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.admin-row textarea {
  resize: vertical;
  line-height: 1.45;
}
.admin-actions input:focus,
.admin-row input:focus,
.admin-row textarea:focus,
.admin-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 255, .10);
}
.admin-status {
  min-height: 20px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}
.admin-rows {
  display: grid;
  gap: 10px;
}
.admin-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfd;
}
.admin-row-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin-row-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}
.delete-row {
  min-height: 32px;
  border: 1px solid rgba(180, 35, 24, .25);
  border-radius: 5px;
  color: var(--danger);
  background: #fff6f5;
  padding: 0 10px;
  cursor: pointer;
}
.admin-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

@media (min-width: 760px) {
  .shell { padding: 24px; }
  .panel { width: 430px; min-height: auto; }
  .admin-panel { width: min(100%, 980px); }
}

@media (max-width: 760px) {
  .admin-actions {
    grid-template-columns: 1fr 1fr;
  }
  .admin-actions input {
    grid-column: 1 / -1;
  }
  .admin-row {
    grid-template-columns: 1fr;
  }
}
