:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #182230;
  --muted: #667085;
  --line: #d7dee8;
  --blue: #175cd3;
  --blue-2: #d8e7ff;
  --teal: #087b78;
  --amber: #b86b00;
  --red: #b42318;
  --green: #067647;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
  --radius: 8px;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 92, 211, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(8, 123, 120, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #101828;
  color: white;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #175cd3, #087b78);
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  margin: 5px 0 0;
  color: #c7d7ee;
  font-size: 12px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #d0d5dd;
  font-size: 12px;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.55;
}

.sidebar .input {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.input:focus,
.select:focus,
.textarea:focus,
button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.icon-button,
.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 0 13px;
}

.icon-button {
  padding: 0;
  display: grid;
  place-items: center;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.button.ghost {
  background: transparent;
}

.button.warn {
  border-color: #f2c997;
  background: #fff4e5;
  color: #8a4b00;
}

.sidebar .icon-button {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.nav-tabs {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.nav-tab {
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
  color: #d0d5dd;
  min-height: 38px;
  padding: 0 12px;
  text-align: left;
}

.nav-tab:hover,
.nav-tab.active {
  border-left-color: #7dd3c7;
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.health-box {
  margin-top: 26px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  color: #d0d5dd;
  font-size: 12px;
  line-height: 1.55;
}

.back-home {
  display: block;
  margin-top: 14px;
  color: #d0d5dd;
  font-size: 12.5px;
  text-decoration: none;
}

.back-home:hover {
  color: #ffffff;
  text-decoration: underline;
}

.workspace {
  min-width: 0;
  padding: 26px 30px 42px;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace h2 {
  margin: 0;
  font-size: 28px;
}

.status-bar {
  max-width: 420px;
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel.unframed {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  margin: 0;
  font-size: 17px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stats-note {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #b9d7d4;
  border-radius: var(--radius);
  background: #effaf8;
  color: #345b59;
  font-size: 13px;
  line-height: 1.6;
}

.stats-note strong {
  flex: 0 0 auto;
  color: var(--teal);
}

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

.channel-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.channel-card.llm { border-top-color: var(--teal); }

.channel-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
}

.channel-card-header strong {
  display: block;
  margin-top: 5px;
  font-size: 38px;
  line-height: 1;
}

.channel-card-header small,
.channel-kicker,
.channel-metrics span,
.latest-run span {
  color: var(--muted);
  font-size: 12px;
}

.channel-kicker {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.selection-rate {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--blue-2);
  color: #174ea6;
  font-size: 12px;
  font-weight: 700;
}

.channel-card.llm .selection-rate {
  background: #d9f3ef;
  color: var(--teal);
}

.channel-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.channel-metrics div {
  padding: 13px 14px;
  border-right: 1px solid var(--line);
}

.channel-metrics div:last-child { border-right: 0; }
.channel-metrics strong { display: block; margin-top: 4px; font-size: 20px; }

.latest-run {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: 13px 18px 16px;
  font-size: 12px;
}

.latest-run strong { grid-row: 1 / span 2; }

.metric-footnote {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 160px) minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.source-health {
  min-width: 180px;
  color: var(--muted);
  font-size: 12px;
}

.source-health small,
.source-health span {
  display: block;
  margin-top: 6px;
  line-height: 1.45;
}

.source-health span {
  color: #b45309;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

/* 自动编校结果表：列多，防止标题列被挤压成竖条 */
.review-table {
  min-width: 1500px;
}

.review-table td:nth-child(3) {
  min-width: 240px;
  word-break: break-word;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f4f8;
  color: #344054;
  font-weight: 700;
}

td .input,
td .select,
td .textarea {
  min-width: 120px;
  padding: 7px 8px;
  font-size: 13px;
}

td .textarea {
  min-width: 240px;
  min-height: 62px;
}

.url-cell {
  max-width: 260px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-2);
  color: #174ea6;
  font-size: 12px;
  font-weight: 700;
}

.pill.green {
  background: #dcfae6;
  color: var(--green);
}

.pill.red {
  background: #fee4e2;
  color: var(--red);
}

.pill.amber {
  background: #fef0c7;
  color: var(--amber);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  text-align: center;
}

.progress-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  color: #344054;
  line-height: 1.55;
  font-size: 13px;
}

.progress-box[data-status="running"] {
  border-color: #9cc3ff;
  background: #f0f6ff;
}

.progress-box[data-status="failed"] {
  border-color: #fecdca;
  background: #fff5f5;
}

.progress-box[data-status="stale"] {
  border-color: #fedf89;
  background: #fffbeb;
}

.progress-box[data-status="success"] {
  border-color: #abefc6;
  background: #f6fef9;
}

.readonly {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 14px;
  color: #344054;
  line-height: 1.6;
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.admin-logout {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  color: #c7d7ee;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
}

.admin-logout:hover { color: #fff; border-color: rgba(255, 255, 255, 0.38); }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(8, 123, 120, 0.14), transparent 34%),
    radial-gradient(circle at 85% 85%, rgba(23, 92, 211, 0.12), transparent 32%),
    #f3f6fa;
}

.login-card {
  width: min(440px, 100%);
  padding: 38px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.login-brand .brand-mark { color: #fff; }
.login-brand strong { display: block; font-size: 16px; }
.login-brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.login-card h1 { margin: 0; font-size: 30px; }
.login-copy { margin: 10px 0 26px; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 5px; color: #344054; font-size: 12px; font-weight: 700; }
.login-form input {
  width: 100%; height: 44px; padding: 0 13px;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 92, 211, .12); }
.login-form button {
  height: 44px; margin-top: 8px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--teal));
  border: 0; border-radius: 8px; font-weight: 700;
}
.login-form button:disabled { opacity: .65; cursor: wait; }
.login-error { min-height: 21px; margin: 2px 0 0; color: var(--red); font-size: 12px; }
.login-home { display: inline-block; margin-top: 24px; color: var(--muted); font-size: 12px; }
.login-home:hover { color: var(--blue); }

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 20px 16px 34px;
  }

  .metric-grid,
  .channel-grid,
  .split-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    display: grid;
  }

  .login-card { padding: 30px 24px; }
}
