:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #1d2430;
  --muted: #657083;
  --panel: #ffffff;
  --line: #d8dde6;
  --accent: #1565c0;
  --good: #1b7f3a;
  --bad: #b42318;
  --warn: #9a6700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 20px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 17px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

p, small {
  color: var(--muted);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

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

.grid,
.deviceGrid,
.settingsGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.stats strong {
  display: block;
  font-size: 24px;
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

input,
select {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
}

code {
  display: block;
  padding: 8px;
  margin-top: 6px;
  background: #f3f5f8;
  border-radius: 6px;
  word-break: break-all;
}

.compactForm {
  margin-top: 16px;
}

button {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button.secondary {
  background: #eef2f7;
  color: var(--ink);
}

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

button:hover {
  filter: brightness(0.95);
}

button:disabled {
  cursor: default;
  opacity: 0.65;
}

.hidden {
  display: none;
}

.device,
.job {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.device strong,
.device span,
.device small {
  display: block;
}

.device span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.device small {
  margin-top: 4px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf2ff;
  color: #2147a8;
  font-size: 13px;
}

.status.succeeded {
  background: #e8f5ec;
  color: var(--good);
}

.status.failed {
  background: #fff0ed;
  color: var(--bad);
}

.events {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.event {
  display: grid;
  grid-template-columns: 160px 90px 120px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #eef1f5;
  font-size: 13px;
}

.event.error {
  color: var(--bad);
}

.event.warn {
  color: var(--warn);
}

.updateLine {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #eef1f5;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
  word-break: break-all;
}

.kv {
  margin-bottom: 12px;
}

.kv span {
  color: var(--muted);
  font-size: 13px;
}

.inlineForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.inlineForm input {
  margin-top: 0;
}

.tokenBox {
  margin-top: 18px;
}

.tokenList {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.tokenItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.tokenItem.revoked {
  opacity: 0.62;
}

.tokenItem small {
  display: block;
  margin-top: 4px;
}

.routeControl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.routeControl select {
  margin-top: 0;
}

@media (max-width: 800px) {
  header {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding: 14px;
  }

  .grid,
  .deviceGrid,
  .settingsGrid,
  .stats {
    grid-template-columns: 1fr;
  }

  .event {
    grid-template-columns: 1fr;
  }

  .routeControl {
    grid-template-columns: 1fr;
  }

  .inlineForm,
  .tokenItem {
    grid-template-columns: 1fr;
  }
}
