:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #68737f;
  --line: #d9dee4;
  --surface: #ffffff;
  --subtle: #f4f6f8;
  --accent: #176b56;
  --accent-strong: #0d5744;
  --danger: #a33a32;
  --warning: #8a5a12;
  --focus: #1269a8;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--subtle); font-size: 14px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { min-height: 34px; border: 1px solid var(--accent); border-radius: 4px; padding: 6px 12px; color: #fff; background: var(--accent); cursor: pointer; }
button:hover { background: var(--accent-strong); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button.quiet { color: var(--ink); border-color: var(--line); background: var(--surface); }
button.danger { border-color: var(--danger); background: var(--danger); }
input, select, textarea { min-height: 34px; width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; color: var(--ink); background: var(--surface); }
textarea { min-height: 78px; resize: vertical; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }

.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 20px; color: #fff; background: #202a34; }
.brand { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.brand strong { font-size: 20px; }
.brand span { color: #bfc9d2; }
.auth-form { display: flex; align-items: end; gap: 8px; }
.auth-form label { display: flex; align-items: center; gap: 8px; color: #dce3e8; }
.auth-form input { width: min(21vw, 250px); border-color: #59636c; background: #fff; }
.auth-form select { width: 92px; border-color: #59636c; background: #fff; }

.app-shell { min-height: calc(100vh - 58px); display: grid; grid-template-columns: 188px minmax(0, 1fr); }
.sidebar { padding: 14px 10px; border-right: 1px solid var(--line); background: var(--surface); }
.nav-item { width: 100%; min-height: 38px; margin: 1px 0; border: 0; border-left: 3px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--ink); background: transparent; text-align: left; }
.nav-item:hover { background: var(--subtle); }
.nav-item.is-active { border-left-color: var(--accent); color: var(--accent-strong); background: #edf6f3; font-weight: 600; }

.workspace { min-width: 0; padding: 20px 24px 36px; }
.workspace-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.workspace-head h1 { margin: 0; font-size: 24px; }
.workspace-head p { margin: 4px 0 0; color: var(--muted); }
.workspace-actions { display: flex; align-items: center; gap: 10px; }
.status { color: var(--muted); }
.status.ok { color: var(--accent-strong); }
.status.error { color: var(--danger); }

.view { display: none; }
.view.is-active { display: block; }
.toolbar { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); align-items: end; gap: 10px; margin-bottom: 14px; }
.action-toolbar { grid-template-columns: 2fr 1fr 90px 2fr auto; }
.metric-grid { display: grid; grid-template-columns: repeat(7, minmax(105px, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.metric-grid article { min-width: 0; padding: 14px 16px; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border-right: 0; }
.metric-grid span { display: block; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.metric-grid strong { display: block; margin-top: 5px; font-size: 22px; }
.admin-metrics { grid-template-columns: repeat(6, minmax(120px, 1fr)); }

.content-band { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.split-band { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.section-heading { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; color: #4c5965; background: #eef1f4; font-size: 12px; font-weight: 600; }
td.wrap { min-width: 260px; white-space: normal; overflow-wrap: anywhere; }
td.actions { display: flex; gap: 6px; }
td.actions button { min-height: 28px; padding: 3px 8px; font-size: 12px; }
tr.is-recommended td { background: #edf6f3; }
.verification-strip { display: flex; flex-wrap: wrap; gap: 18px; padding: 10px 0; color: var(--muted); }
.label-layout { display: grid; grid-template-columns: minmax(270px, 0.7fr) minmax(500px, 1.3fr); gap: 18px; }
.inline-form { display: grid; gap: 10px; align-content: start; }
.check { min-width: 0; display: flex; align-items: flex-start; gap: 8px; color: var(--ink); font-size: 13px; line-height: 1.45; cursor: pointer; overflow-wrap: anywhere; }
.check input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; flex: 0 0 16px; margin: 2px 0 0; border: 0; padding: 0; accent-color: var(--accent); }
.check-list { padding: 4px 0; color: var(--muted); }
.check-list p { margin: 8px 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { border: 1px solid var(--line); border-radius: 3px; padding: 2px 5px; color: #44515d; background: var(--subtle); font-size: 12px; }
.state-danger { color: var(--danger); font-weight: 600; }
.state-warning { color: var(--warning); font-weight: 600; }

dialog { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 6px; padding: 0; box-shadow: 0 16px 48px rgb(0 0 0 / 22%); }
dialog::backdrop { background: rgb(15 22 28 / 45%); }
#action-dialog-form { padding: 20px; }
#dialog-title { margin: 0 0 16px; font-size: 18px; }
.dialog-fields { display: grid; gap: 10px; margin-bottom: 12px; }
.choice-list { max-height: min(360px, 50vh); display: grid; gap: 0; overflow-y: auto; padding: 0 2px; }
.choice-list .check { min-height: 34px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.choice-list .check:last-child { border-bottom: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 38px; margin-top: 10px; }
.pager span { min-width: 72px; color: var(--muted); text-align: center; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 150px minmax(0, 1fr); }
  .toolbar, .action-toolbar { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .metric-grid, .admin-metrics { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
  .metric-grid article { border-bottom: 1px solid var(--line); }
}

@media (max-width: 700px) {
  .topbar { height: auto; align-items: stretch; flex-direction: column; padding: 12px; }
  .auth-form { align-items: stretch; flex-wrap: wrap; }
  .auth-form label { width: 100%; align-items: stretch; flex-direction: column; }
  .auth-form input { width: 100%; }
  .app-shell { display: block; }
  .sidebar { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  .nav-item { width: auto; flex: 0 0 auto; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item.is-active { border-bottom-color: var(--accent); }
  .workspace { padding: 16px 12px 28px; }
  .workspace-head { align-items: flex-start; flex-direction: column; }
  .toolbar, .action-toolbar, .split-band, .label-layout { grid-template-columns: 1fr; }
  .metric-grid, .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
