/* ==========================================================================
   qr_generator.css — 二维码生成器看板（自包含：自有 reset / tokens）
   视觉语言延续 accounts.css / check_pc.css：浅色主题 · 中性灰 + 单一强调色
   #2563eb · 8px 间距刻度
   ========================================================================== */

:root {
  /* 色彩 */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #d5dde8;
  --text: #1e293b;
  --text-soft: #475569;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-ring: rgba(37, 99, 235, 0.18);

  --success: #15803d;
  --success-hover: #166534;
  --success-soft: #ecfdf3;
  --success-border: #bbf7d0;

  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  /* 间距（8px 刻度） */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 40px;

  /* 圆角 / 阴影 */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.09);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ── reset ───────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p {
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* ── 页面骨架 ────────────────────────────────────────────────────────────── */
.page {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--sp-4);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-2);
  padding-bottom: var(--sp-3);
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.2;
}

.page-sub {
  margin-top: var(--sp-1);
  font-size: 13px;
  color: var(--muted);
}

.page-head__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.whoami-label {
  color: var(--muted-2);
}

.whoami-name {
  font-weight: 600;
  color: var(--text-soft);
}

.whoami-user {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}

/* ── 卡片 ───────────────────────────────────────────────────────────────── */
.panel {
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.panel-head__main {
  min-width: 0;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}

.panel-desc {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── 按钮 ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--ghost {
  color: var(--text-soft);
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: #bcc9da;
}

.btn--lg {
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn--template {
  color: var(--accent);
  border-color: #bfdbfe;
  background: var(--accent-soft);
}

.btn--template:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* ── 导入区 ─────────────────────────────────────────────────────────────── */
.compose {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr);
  gap: var(--sp-3);
  align-items: stretch;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 236px;
  padding: var(--sp-4) var(--sp-3);
  text-align: center;
  background: var(--surface-soft);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.dropzone:hover {
  border-color: #bcc9da;
  background: #fbfcfe;
}

.dropzone.is-drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.dropzone__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
}

.dropzone__icon svg {
  width: 26px;
  height: 26px;
}

.dropzone__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.dropzone__hint {
  font-size: 12.5px;
  color: var(--muted);
}

.dropzone__link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dropzone__badge {
  margin-top: 2px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--muted);
  background: var(--surface-muted);
  border-radius: 999px;
}

.compose__side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.file-chip__icon {
  flex: 0 0 auto;
  padding: 3px 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
}

.file-chip__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.file-chip__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip__size {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.file-chip__remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.file-chip__remove:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}

.file-chip__remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── 排版选择 ───────────────────────────────────────────────────────────── */
.field-label {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--muted);
}

.layout-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-1);
}

.layout-option {
  display: block;
  min-width: 0;
  cursor: pointer;
}

.layout-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.layout-card {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.layout-option:hover .layout-card {
  border-color: #bcc9da;
  background: var(--surface-soft);
}

.layout-option input:checked + .layout-card {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.layout-option input:focus-visible + .layout-card {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.layout-card__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.layout-card__text strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.layout-card__text small {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 迷你排版示意 */
.layout-preview {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 46px;
  height: 46px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.layout-preview--vertical {
  flex-direction: column;
}

.layout-preview--horizontal {
  flex-direction: row;
}

.layout-preview__qr {
  width: 17px;
  height: 17px;
  background:
    linear-gradient(90deg, var(--text-soft) 40%, transparent 40% 60%, var(--text-soft) 60%),
    linear-gradient(var(--text-soft) 40%, transparent 40% 60%, var(--text-soft) 60%);
  background-size: 5px 5px;
  border: 1px solid var(--text-soft);
  border-radius: 1px;
}

.layout-preview__lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.layout-preview__line {
  display: block;
  width: 15px;
  height: 2px;
  background: var(--muted-2);
  border-radius: 2px;
}

.layout-preview__line--short {
  width: 10px;
}

.layout-preview--vertical .layout-preview__line {
  width: 24px;
}

.layout-preview--vertical .layout-preview__line--short {
  width: 16px;
}

.layout-option input:checked + .layout-card .layout-preview {
  border-color: #bfdbfe;
}

/* ── 操作 ───────────────────────────────────────────────────────────────── */
.compose__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-top: auto;
}

.compose__actions .btn {
  flex: 1 1 0;
}

.compose__note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.compose__note.is-ready {
  color: var(--success);
}

/* ── 汇总卡片 ───────────────────────────────────────────────────────────── */
.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
}

.summary-card__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--muted);
}

.summary-card__value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.summary-card--valid {
  border-left-color: var(--success);
}

.summary-card--valid .summary-card__value {
  color: var(--success);
}

.summary-card--error {
  border-left-color: var(--danger);
}

.summary-card--error .summary-card__value {
  color: var(--danger);
}

/* ── 生成结果横幅 ───────────────────────────────────────────────────────── */
.result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 14px 18px;
  margin-bottom: var(--sp-2);
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-lg);
}

.result-banner__main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-width: 0;
}

.result-banner__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
}

.result-banner__counts {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.result-banner__note {
  font-size: 12px;
  color: var(--warn);
}

.result-banner.is-error {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  border-left-color: var(--danger);
}

.result-banner.is-error .result-banner__title {
  color: var(--danger);
}

/* ── 表格 ───────────────────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  max-height: 60vh;
  overflow: auto;
}

.data-table {
  min-width: 900px;
  font-size: 13.5px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 -1px 0 var(--border);
}

.data-table tbody td {
  padding: 10px 16px;
  color: var(--text-soft);
  vertical-align: middle;
  border-top: 1px solid #eef2f7;
}

.data-table tbody tr:first-child td {
  border-top: 0;
}

.data-table tbody tr:hover td {
  background: #f9fbfe;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-row {
  width: 62px;
}

.col-result {
  width: 300px;
}

.col-actions {
  width: 110px;
}

.cell-mono {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-qr {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

.cell-muted {
  color: var(--muted-2);
}

.cell-time {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 行状态着色：错误红 / 有效绿 / 续链浅绿 */
.data-table tbody tr.row--error td {
  background: var(--danger-soft);
  color: var(--text-soft);
}

.data-table tbody tr.row--error td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.data-table tbody tr.row--ok td {
  background: var(--success-soft);
}

.data-table tbody tr.row--ok td:first-child {
  box-shadow: inset 3px 0 0 var(--success);
}

.data-table tbody tr.row--relink td {
  background: #f4fbf7;
}

.data-table tbody tr.row--relink td:first-child {
  box-shadow: inset 3px 0 0 var(--success-border);
}

.data-table tbody tr.row--error:hover td {
  background: #fde8e8;
}

.data-table tbody tr.row--ok:hover td,
.data-table tbody tr.row--relink:hover td {
  background: #e6f9ee;
}

.result-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.result-ok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--success);
}

.result-ok__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.result-relink {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--warn);
}

.result-error {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.result-error__msg {
  font-size: 12.5px;
  color: var(--danger-hover);
}

.code-chip {
  flex: 0 0 auto;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--danger-hover);
  background: rgba(220, 38, 38, 0.09);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-sm);
}

.code-chip--relink {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: var(--warn-border);
}

/* 排版胶囊 */
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
}

.pill--vertical {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #bfdbfe;
}

.pill--horizontal {
  color: #6d28d9;
  background: #f5f3ff;
  border-color: #ddd6fe;
}

/* 行内操作 */
.link-btn {
  padding: 4px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.link-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.link-btn:disabled {
  color: var(--muted-2);
  background: transparent;
  cursor: not-allowed;
}

/* 空 / 错误状态 */
.state {
  padding: var(--sp-5) var(--sp-2);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.state--error {
  color: var(--danger);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  right: var(--sp-3);
  bottom: var(--sp-3);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-1);
  pointer-events: none;
}

.toast {
  max-width: 360px;
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-in {
  opacity: 1;
  transform: translateY(0);
}

.toast--error {
  border-left-color: var(--danger);
}

.toast--success {
  border-left-color: var(--success);
}

/* ── 响应式 ─────────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .page {
    padding: var(--sp-2);
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
    padding-bottom: var(--sp-2);
  }

  .page-title {
    font-size: 21px;
  }

  .compose {
    grid-template-columns: 1fr;
  }

  .dropzone {
    min-height: 180px;
  }

  .summary {
    gap: var(--sp-1);
  }
}

@media (max-width: 720px) {
  .panel {
    padding: var(--sp-2);
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card--error {
    grid-column: 1 / -1;
  }

  .result-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .layout-options {
    grid-template-columns: 1fr;
  }

  .toast-wrap {
    right: var(--sp-2);
    bottom: var(--sp-2);
    left: var(--sp-2);
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .compose__actions {
    flex-direction: column;
  }

  .compose__actions .btn {
    flex: 0 0 auto;
    width: 100%;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .summary-card--error {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
