:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #19212a;
  --muted: #687384;
  --line: #d9dee7;
  --accent: #116a5c;
  --accent-2: #1f5d9c;
  --warn: #a85f00;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #17202b;
  color: #f7fafc;
  padding: 22px 18px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 28px;
}

.main-nav,
.sub-nav {
  display: flex;
  gap: 8px;
}

.main-nav {
  flex-direction: column;
}

.sub-nav {
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.nav-link,
.sub-link {
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

.nav-link {
  padding: 10px 12px;
}

.nav-link.is-active {
  background: #244057;
}

.sub-link {
  background: #e7ebf1;
  color: #26313e;
  padding: 8px 10px;
}

.sub-link.is-active {
  background: var(--accent);
  color: #fff;
}

.content {
  padding: 28px;
  min-width: 0;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 4px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.group-form {
  align-items: end;
  display: grid;
  grid-template-columns: auto 150px auto;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
}

/* 登录 / 创建管理员页：整屏居中的白卡片 */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 34px rgba(25, 33, 42, 0.09);
  padding: 32px 30px;
  width: 100%;
  max-width: 380px;
  display: grid;
  gap: 16px;
}

.auth-panel .brand {
  margin-bottom: 0;
  color: var(--accent);
}

.auth-panel h1 {
  font-size: 22px;
}

.auth-panel > button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.text-link {
  color: var(--accent-2);
  font-size: 14px;
}

/* 记住我：复选框与文字同一行左对齐（flex，稳） */
label.remember {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}

label.remember input[type="checkbox"] {
  flex: none;
  min-height: auto;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 9px;
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  min-height: 36px;
  padding: 8px 14px;
}

.secondary-button,
.ghost-button {
  background: #eef2f6;
  color: #26313e;
}

.ghost-button {
  min-height: 32px;
  padding: 6px 10px;
}

.stack {
  display: grid;
  gap: 16px;
}

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.metric-grid,
.keyword-grid {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.keyword-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.metric span,
.muted {
  color: var(--muted);
}

.metric strong {
  font-size: 26px;
}

.panel-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-grid h2 {
  grid-column: 1 / -1;
}

.check-row,
.inline-check {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-row input {
  min-height: auto;
}

.compact-field {
  max-width: 240px;
  margin-bottom: 14px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.editable-table input,
.editable-table select {
  width: 100%;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.notice {
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.notice.is-success {
  background: #e7f5ef;
  color: #0f513c;
}

.notice.is-error {
  background: #fef0ee;
  color: var(--danger);
}

.tag-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.tag-chip,
.pill {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

.tag-chip {
  background: #e8f4ff;
  color: #123c69;
  min-height: 30px;
  padding: 5px 8px;
}

.pill {
  background: #fff4df;
  color: var(--warn);
  font-size: 12px;
  padding: 3px 6px;
}

.evidence-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.text-link {
  color: var(--accent-2);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
}

.log-output {
  background: #111821;
  border-radius: 6px;
  color: #eef6ff;
  margin: 0;
  max-height: 480px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .main-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .group-form,
  .form-grid,
  .metric-grid,
  .keyword-grid {
    grid-template-columns: 1fr;
  }
}
