:root {
  color-scheme: light;
  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #17202b;
  --muted: #637083;
  --line: #d7dde5;
  --line-strong: #b9c2cf;
  --accent: #176b51;
  --accent-dark: #0e513c;
  --accent-soft: #e5f3ed;
  --warning: #8a5200;
  --warning-soft: #fff2d6;
  --danger: #a52b3a;
  --danger-soft: #fde8eb;
  --focus: #2679c9;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select { font: inherit; }

button,
a,
input,
select { outline: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 3px rgb(38 121 201 / 24%);
  border-color: var(--focus);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.brand-block,
.topbar-actions,
.toolbar,
.toolbar-fields,
.toolbar-actions,
.pagination,
.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand-block { gap: 14px; }

h1,
h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 19px; line-height: 1.3; }
h2 { font-size: 17px; line-height: 1.35; }

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.topbar-actions { gap: 10px; }
.user-name { color: var(--muted); white-space: nowrap; }

.text-link {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.quiet { background: #fff; color: #334155; }
.button.quiet:hover { border-color: #8c98a8; background: var(--surface-muted); }

.login-shell {
  display: grid;
  min-height: calc(100dvh - 64px);
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgb(50 68 88 / 9%);
}

.login-panel h2 { margin-bottom: 20px; }
.login-button { width: 100%; margin-top: 6px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { color: #3f4b5c; font-size: 12px; font-weight: 700; }

.field input,
.field select,
.pagination select {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
}

.field input::placeholder { color: #7d8795; }
.form-error { min-height: 20px; margin: 0 0 8px; color: var(--danger); font-size: 12px; }

.workspace {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 14px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-item { min-width: 0; padding: 12px 14px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item span,
.summary-item small { display: block; color: var(--muted); }
.summary-item span { font-size: 12px; font-weight: 700; }
.summary-item strong { display: block; margin: 4px 0 2px; font-size: 22px; line-height: 1.1; }
.summary-item small { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  margin-top: 14px;
  border-bottom: 1px solid var(--line-strong);
}

.tab {
  min-width: 112px;
  min-height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover { color: var(--ink); }
.tab.active { border-bottom-color: var(--accent); color: var(--accent-dark); }

.data-section {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--surface);
}

.toolbar {
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.toolbar-fields { gap: 10px; min-width: 0; }
.toolbar-actions { gap: 8px; align-self: end; }
.field.compact { min-width: 190px; margin: 0; }
.field.compact:first-child { width: min(36vw, 420px); }

.inline-status {
  min-height: 0;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.inline-status:not(:empty) { min-height: 38px; padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.inline-status.error { color: var(--danger); background: var(--danger-soft); }

.table-frame {
  max-height: calc(100dvh - 310px);
  min-height: 360px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

th,
td {
  max-width: 360px;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef2f5;
  color: #354052;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:hover td { background: #f8fbfa; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.strong { color: var(--ink); font-weight: 700; }

.badge {
  display: inline-block;
  min-height: 22px;
  border-radius: 4px;
  padding: 2px 7px;
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 700;
  white-space: nowrap;
}

.badge.success { background: var(--accent-soft); color: var(--accent-dark); }
.badge.failure { background: var(--danger-soft); color: var(--danger); }

details { min-width: 240px; }
details summary { color: var(--accent-dark); font-weight: 700; cursor: pointer; }
details p { margin: 7px 0 0; white-space: normal; }
.source-links { display: grid; gap: 4px; margin-top: 5px; }
.source-links a { color: var(--focus); text-decoration: none; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.pagination { gap: 8px; }
.pagination select { min-height: 34px; padding: 5px 8px; }

.skeleton {
  display: block;
  width: 100%;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(90deg, #e7ebef 25%, #f6f8fa 45%, #e7ebef 65%);
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer { to { background-position: -220% 0; } }

.empty-cell { height: 260px; color: var(--muted); text-align: center; vertical-align: middle; }

dialog {
  width: min(92vw, 440px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 60px rgb(25 39 55 / 24%);
}

dialog::backdrop { background: rgb(23 32 43 / 42%); }
.dialog-form { padding: 18px; }
.dialog-heading { justify-content: space-between; margin-bottom: 16px; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 8px; }
.icon-button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid #75ab96;
  border-radius: 6px;
  padding: 11px 14px;
  background: #f0faf5;
  color: var(--accent-dark);
  box-shadow: 0 10px 26px rgb(38 64 52 / 15%);
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .button:active { transform: none; }
}

@media (max-width: 1040px) {
  .summary-strip { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .summary-item { border-bottom: 1px solid var(--line); }
  .summary-item:nth-child(3) { border-right: 0; }
  .summary-item:nth-child(n+4) { border-bottom: 0; }
  .toolbar { align-items: flex-end; }
  .toolbar-fields { flex: 1; flex-wrap: wrap; }
  .field.compact:first-child { width: 100%; }
  .table-frame { max-height: calc(100dvh - 380px); }
}

@media (max-width: 700px) {
  .topbar { position: static; align-items: flex-start; padding: 12px; }
  .brand-block { align-items: flex-start; flex-direction: column; gap: 4px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .user-name { width: 100%; text-align: right; }
  .workspace { padding: 8px; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-item:nth-child(2n) { border-right: 0; }
  .summary-item:nth-child(3) { border-right: 1px solid var(--line); }
  .summary-item:nth-child(n+4) { border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-fields { display: grid; grid-template-columns: 1fr; }
  .field.compact,
  .field.compact:first-child { width: 100%; min-width: 0; }
  .toolbar-actions { align-self: stretch; }
  .toolbar-actions .button { flex: 1; }
  .table-frame { max-height: none; min-height: 420px; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .pagination { width: 100%; flex-wrap: wrap; }
  .login-shell { min-height: calc(100dvh - 96px); padding: 14px; }
  .login-panel { padding: 18px; }
}
