:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #d9e2ec;
  --line-strong: #b8c7d6;
  --accent: #2563a8;
  --accent-dark: #174a7c;
  --accent-soft: #e6f0fb;
  --red: #b42318;
  --red-soft: #fde8e6;
  --amber: #a15c07;
  --amber-soft: #fff1d6;
  --green: #21724b;
  --green-soft: #e4f5eb;
  --shadow: 0 16px 40px rgba(31, 41, 51, 0.08);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.admin-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.admin-topbar,
.toolbar,
.admin-sidebar,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.topbar-title {
  min-width: 0;
}

.topbar-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  line-height: 1.2;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.35;
}

.version-pill {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: max-content;
  color: var(--muted);
  font-weight: 800;
}

.version-pill span {
  color: var(--accent-dark);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
}

.toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.token-field {
  flex: 1 1 280px;
}

.toolbar input,
.toolbar select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
}

.toolbar input:focus,
.toolbar select:focus,
.toolbar button:focus-visible,
.plain-link:focus-visible,
.nav-item:focus-visible {
  outline: 3px solid rgba(37, 99, 168, 0.22);
  outline-offset: 2px;
}

.check-row {
  display: inline-flex !important;
  align-items: center;
  grid-template-columns: auto 1fr;
  min-height: 40px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.toolbar button,
.plain-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.plain-link {
  border-color: var(--line);
  background: var(--surface);
  color: var(--accent);
}

.toolbar button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.admin-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.nav-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  width: 100%;
  min-height: 66px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.nav-item span {
  font-weight: 900;
}

.nav-item small {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.nav-item b {
  grid-row: 1 / span 2;
  align-self: center;
  min-width: 34px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 4px 8px;
  text-align: center;
  font-size: 0.76rem;
}

.nav-item.active {
  border-color: rgba(37, 99, 168, 0.28);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav-item.active b {
  background: var(--accent);
  color: #fff;
}

.nav-item.secondary {
  color: var(--muted);
}

.workspace-host {
  min-width: 0;
}

.workspace {
  display: none;
}

.workspace.active {
  display: block;
}

.workspace-title {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  margin-bottom: 14px;
}

.alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
}

.alert.warning {
  border-color: rgba(161, 92, 7, 0.32);
  background: var(--amber-soft);
  color: var(--amber);
}

.alert.critical {
  border-color: rgba(180, 35, 24, 0.32);
  background: var(--red-soft);
  color: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 13px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  font-size: 1.4rem;
  line-height: 1.1;
}

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

.panel {
  min-width: 0;
  padding: 14px;
}

.hero-panel {
  margin-bottom: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.span-2 {
  grid-column: span 2;
}

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

.panel-head > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: right;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.health-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.health-item strong {
  display: block;
  font-size: 1rem;
  line-height: 1.35;
}

.health-item span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.health-item.good {
  border-color: rgba(33, 114, 75, 0.28);
  background: var(--green-soft);
}

.health-item.warn {
  border-color: rgba(161, 92, 7, 0.28);
  background: var(--amber-soft);
}

.health-item.bad {
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--red-soft);
}

.split-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.feedback-table-wrap {
  max-height: min(62vh, 560px);
  overflow: auto;
}

.feedback-table-wrap table {
  min-width: 820px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

td {
  font-size: 0.9rem;
  line-height: 1.45;
}

.compact td,
.compact th {
  padding: 8px 6px;
}

.stat-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.stat-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.stat-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.stat-list dd {
  margin: 5px 0 0;
  font-size: 1.02rem;
  font-weight: 900;
}

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

.mini-list {
  display: grid;
  gap: 8px;
}

.session-list {
  margin-top: 12px;
}

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

.decision-item,
.mini-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.priority-panel .decision-item:first-child {
  border-color: rgba(37, 99, 168, 0.36);
  background: #f3f8ff;
}

.decision-priority {
  display: inline-flex;
  margin-bottom: 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 900;
}

.decision-item.high .decision-priority,
.decision-item.critical .decision-priority {
  background: var(--red-soft);
  color: var(--red);
}

.decision-item.medium .decision-priority {
  background: var(--amber-soft);
  color: var(--amber);
}

.decision-item strong,
.mini-item strong {
  display: block;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.35;
}

.decision-copy {
  display: grid;
  gap: 4px;
  margin-top: 9px;
}

.decision-copy small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.decision-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.decision-copy.action p {
  color: var(--accent-dark);
  font-weight: 900;
}

.mini-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.mini-item .mini-extra {
  max-height: 9.2em;
  overflow: auto;
  color: var(--ink);
}

.empty {
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .metric-grid,
  .health-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .admin-shell {
    padding: 10px;
  }

  .admin-topbar {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar-subtitle {
    font-size: 0.86rem;
  }

  .version-pill {
    justify-items: start;
  }

  .toolbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar button,
  .plain-link {
    width: 100%;
  }

  .admin-layout {
    display: block;
  }

  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 18;
    display: flex;
    gap: 8px;
    margin: 12px 0;
    overflow-x: auto;
    padding: 8px;
    scroll-snap-type: x mandatory;
  }

  .nav-item {
    align-items: center;
    flex: 0 0 118px;
    min-height: 52px;
    scroll-snap-align: start;
  }

  .nav-item small {
    display: none;
  }

  .nav-item b {
    grid-row: auto;
    min-width: 28px;
    padding: 3px 7px;
  }

  .metric-grid,
  .health-grid,
  .admin-grid,
  .split-lists,
  .stat-list,
  .server-list,
  .decision-list {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .panel-head {
    align-items: start;
    flex-direction: column;
  }

  .panel-head > span {
    text-align: left;
  }

  .feedback-table-wrap {
    max-height: 58vh;
  }

  table {
    min-width: 680px;
  }
}

@media (max-width: 520px) {
  .metric {
    min-height: 76px;
  }

  .metric strong {
    font-size: 1.24rem;
  }

  .nav-item {
    flex-basis: 112px;
  }
}
