/*
  gbchecker UI system, no build step.

  Keep this file after app.css in base.html. It defines design tokens and
  component classes while preserving legacy class names used by older pages.
*/

:root {
  color-scheme: light;

  --ui-bg: #f5f7fb;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f8fafc;
  --ui-surface-raised: #ffffff;
  --ui-border: #d8dee8;
  --ui-border-soft: #e7ebf2;

  --ui-text: #172033;
  --ui-text-muted: #667085;
  --ui-text-subtle: #98a2b3;

  --ui-primary: #2558d7;
  --ui-primary-strong: #1d46ad;
  --ui-primary-soft: #e8efff;
  --ui-accent: #0f766e;
  --ui-accent-soft: #e7f6f3;
  --ui-warn: #b7791f;
  --ui-warn-soft: #fff4db;
  --ui-danger: #c24138;
  --ui-danger-soft: #ffe7e5;
  --ui-success: #15803d;
  --ui-success-soft: #e7f7ed;

  --ui-radius-sm: 4px;
  --ui-radius: 6px;
  --ui-radius-lg: 8px;
  --ui-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --ui-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);

  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;

  --ui-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", system-ui, sans-serif;
  --ui-mono: "SF Mono", "Cascadia Code", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ui-bg);
}

body {
  max-width: none;
  margin: 0;
  padding: 0;
  color: var(--ui-text);
  background:
    linear-gradient(180deg, #eef3ff 0, rgba(238, 243, 255, 0) 220px),
    var(--ui-bg);
  font-family: var(--ui-font);
  font-size: 14px;
  line-height: 1.55;
}

a {
  color: var(--ui-primary);
}

a:hover {
  color: var(--ui-primary-strong);
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--ui-space-4);
  min-height: 58px;
  padding: 0 var(--ui-space-6);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--ui-border-soft);
  backdrop-filter: blur(14px);
}

.app-brand {
  display: flex;
  align-items: baseline;
  gap: var(--ui-space-2);
  flex: 0 0 auto;
  text-decoration: none;
}

.brand {
  color: var(--ui-text);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0;
}

.sub {
  color: var(--ui-text-muted);
  font-size: 12px;
}

.top {
  border: 0;
  margin: 0;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ui-radius);
  color: var(--ui-text-muted);
  font-size: 13px;
  text-decoration: none;
}

.topnav a:hover,
.topnav a.active {
  color: var(--ui-primary-strong);
  background: var(--ui-primary-soft);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  margin-left: auto;
  color: var(--ui-text-muted);
  font-size: 13px;
}

.user-bar .link {
  border: 0;
  background: transparent;
  color: var(--ui-primary);
  cursor: pointer;
  font: inherit;
}

.app-main,
main {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: var(--ui-space-6) 0 var(--ui-space-8);
}

.hide-chrome .app-main,
.hide-chrome main {
  width: 100%;
  padding: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-space-4);
  margin-bottom: var(--ui-space-4);
}

.page-title {
  margin: 0;
  color: var(--ui-text);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 760;
  letter-spacing: 0;
}

.page-kicker,
.page-meta,
.muted {
  color: var(--ui-text-muted);
  font-size: 12px;
}

.page-actions,
.action-row,
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
  gap: var(--ui-space-4);
  align-items: start;
}

.panel,
.card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border-soft);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-sm);
  padding: var(--ui-space-5);
  margin-bottom: var(--ui-space-4);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-3);
  margin-bottom: var(--ui-space-4);
}

.panel-title,
.card h2,
.card h3 {
  margin: 0;
  color: var(--ui-text);
  font-size: 16px;
  font-weight: 700;
}

.panel-subtitle {
  margin-top: 2px;
  color: var(--ui-text-muted);
  font-size: 12px;
}

.section-note {
  margin: var(--ui-space-3) 0 0;
  color: var(--ui-text-muted);
  font-size: 12px;
}

.form-subheader {
  margin-top: 18px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.field-action {
  margin-left: 6px;
}

.compact-pre {
  max-height: 80px;
  overflow: auto;
}

.btn,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--ui-shadow-sm);
}

.btn:hover,
button:hover {
  border-color: var(--ui-primary);
  color: var(--ui-primary-strong);
}

.btn.primary,
.btn-primary,
button.primary,
.primary {
  background: var(--ui-primary);
  border-color: var(--ui-primary);
  color: #fff;
}

.btn.primary:hover,
button.primary:hover,
.primary:hover {
  background: var(--ui-primary-strong);
  border-color: var(--ui-primary-strong);
  color: #fff;
}

.btn.small,
.btn-sm {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn.danger {
  background: var(--ui-danger);
  border-color: var(--ui-danger);
  color: #fff;
}

.btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.user-bar .link {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ui-primary);
  box-shadow: none;
  font-weight: 500;
}

.field,
.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--ui-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.field-form,
.upload-form,
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ui-space-4);
}

input[type="text"],
input[type="number"],
input[type="file"],
input[type="password"],
input[type="email"],
select,
textarea,
.upload-form input[type="file"],
.upload-form input[type="number"],
.upload-form select {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: #fff;
  color: var(--ui-text);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

select[multiple] {
  min-height: 140px;
  padding: 6px;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(37, 88, 215, 0.18);
  border-color: var(--ui-primary);
}

.check-row,
.upload-form label.check-row {
  flex-direction: row;
  align-items: flex-start;
  gap: var(--ui-space-2);
  color: var(--ui-text);
  font-weight: 500;
}

.data-table,
.review-table,
.fields-table,
.ds-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--ui-border-soft);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  font-size: 13px;
}

.data-table th,
.data-table td,
.review-table th,
.review-table td,
.fields-table th,
.fields-table td,
.ds-table th,
.ds-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border-soft);
  text-align: left;
  vertical-align: top;
}

.data-table th,
.review-table th,
.fields-table th,
.ds-table th {
  background: var(--ui-surface-soft);
  color: var(--ui-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.data-table tr:last-child td,
.review-table tr:last-child td,
.fields-table tr:last-child td,
.ds-table tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover,
.review-table tbody tr:hover,
.fields-table tbody tr:hover,
.ds-table tbody tr:hover {
  background: #fbfdff;
}

.table-wrap {
  overflow-x: auto;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ui-text);
  font-family: var(--ui-mono);
  font-size: 12px;
}

code {
  background: #eef2f7;
  color: #283548;
  border-radius: var(--ui-radius-sm);
  padding: 1px 6px;
  font-family: var(--ui-mono);
  font-size: 12px;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  background: #eef2f7;
  color: #344054;
}

.status-queued,
.status-pending {
  background: #edf2ff;
  color: #3146a0;
}

.status-running {
  background: var(--ui-warn-soft);
  color: var(--ui-warn);
}

.status-done,
.status-ok {
  background: var(--ui-success-soft);
  color: var(--ui-success);
}

.status-failed,
.status-error {
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.warn,
.alert {
  border: 1px solid #f4d08b;
  border-radius: var(--ui-radius);
  background: var(--ui-warn-soft);
  color: #81530f;
  padding: 10px 12px;
  font-size: 13px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  border: 1px dashed var(--ui-border);
  border-radius: var(--ui-radius-lg);
  color: var(--ui-text-muted);
  background: var(--ui-surface-soft);
  text-align: center;
}

.review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-space-4);
}

.phases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: var(--ui-space-3);
}

.phase {
  position: relative;
  min-height: 96px;
  border: 1px solid var(--ui-border-soft);
  border-radius: var(--ui-radius-lg);
  padding: 12px;
  background: var(--ui-surface-soft);
}

.phase::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ui-text-subtle);
}

.phase-label {
  padding-left: 16px;
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 700;
}

.phase-status {
  margin-top: 8px;
  color: var(--ui-text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.phase-progress {
  margin-top: 6px;
  color: var(--ui-primary);
  font-size: 20px;
  font-weight: 760;
}

.phase-running {
  border-color: #e9b949;
  background: var(--ui-warn-soft);
}

.phase-running::before {
  background: var(--ui-warn);
}

.phase-done {
  border-color: #9bd6b2;
  background: var(--ui-success-soft);
}

.phase-done::before {
  background: var(--ui-success);
}

.phase-failed {
  border-color: #f0aaa4;
  background: var(--ui-danger-soft);
}

.phase-failed::before {
  background: var(--ui-danger);
}

.phase-skipped {
  opacity: 0.7;
  border-style: dashed;
}

.log-tail {
  border: 1px solid #202a3a;
  background: #111827;
  color: #d5dbe8;
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-sm);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--ui-space-3);
}

.meta-item {
  padding: 10px 12px;
  border: 1px solid var(--ui-border-soft);
  border-radius: var(--ui-radius);
  background: var(--ui-surface-soft);
}

.meta-label {
  color: var(--ui-text-muted);
  font-size: 11px;
}

.meta-value {
  margin-top: 2px;
  color: var(--ui-text);
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-header,
  .page-header,
  .review-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav {
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .app-main,
  main {
    width: min(100% - 24px, 1280px);
    padding-top: var(--ui-space-4);
  }

  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Lifecycle 状态机 canvas legend ---- */
.lc-legend-current,
.lc-legend-visited,
.lc-legend-future,
.lc-legend-edge-traversed,
.lc-legend-edge-future {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}
.lc-legend-current { width: 10px; height: 10px; background: #10b981; border-radius: 2px; }
.lc-legend-visited { width: 10px; height: 10px; background: #dbeafe; border: 1px solid #3b82f6; border-radius: 2px; }
.lc-legend-future  { width: 10px; height: 10px; background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 2px; }
.lc-legend-edge-traversed { width: 18px; border-top: 2px solid #1f2937; }
.lc-legend-edge-future { width: 18px; border-top: 1px dashed #cbd5e1; }
