:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f6f8fb;
  --bg-alt: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f1f4f9;

  /* Borders */
  --border: #e3e8ef;
  --border-strong: #cdd5df;

  /* Text */
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;

  /* Brand */
  --primary: #0d6e6a;
  --primary-hover: #0a5853;
  --primary-strong: #064e49;
  --primary-soft: #d6f0ed;
  --primary-soft-strong: #b8e2dd;

  /* Semantic */
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  /* Radii */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 3px rgba(13, 110, 106, 0.18);

  /* Motion */
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 280ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

::selection {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(246, 248, 251, 0.85);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(13, 110, 106, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Page */
.page {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

/* Hero */
.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
}

.hero-copy h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero-copy p,
.section-note,
.muted {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Stats */
.stats-grid,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  position: relative;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-base) var(--ease);
}

.stat:hover {
  border-color: var(--border-strong);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel + .panel {
  margin-top: 16px;
}

.panel-soft {
  background: var(--surface-soft);
  box-shadow: none;
}

.stack {
  display: grid;
  gap: 14px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* Forms */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.55;
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}

/* Code-style input for the redeem code field */
#code-input {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#code-input::placeholder {
  letter-spacing: 0;
  text-transform: none;
}

/* Buttons */
.toolbar,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button,
.link-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
  font-size: 13px;
  line-height: 1;
  user-select: none;
  transition: background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.button:focus-visible,
.link-button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

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

.button-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(13, 110, 106, 0.3);
}

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

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-alt);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  padding: 0 10px;
}

.button-ghost:hover:not(:disabled) {
  background: var(--primary-soft);
}

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

.button-danger:hover:not(:disabled) {
  background: #991b1b;
  border-color: #991b1b;
}

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

.button.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.button.is-loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: #fff;
  animation: spin 600ms linear infinite;
}

.button-secondary.is-loading::after,
.button-ghost.is-loading::after {
  color: var(--primary);
}

.button.is-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(21, 128, 61, 0.35);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Badge / Tag */
.badge,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag-primary {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.tag-success {
  background: var(--success-soft);
  color: var(--success);
}

.tag-warning {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Status banners */
.status {
  display: none;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  animation: status-in var(--t-base) var(--ease);
}

.status.is-visible {
  display: block;
}

.status-success {
  border-color: rgba(21, 128, 61, 0.25);
  background: var(--success-soft);
  color: #14532d;
}

.status-success .status-text {
  color: #166534;
}

.status-error {
  border-color: rgba(185, 28, 28, 0.25);
  background: var(--danger-soft);
  color: #7f1d1d;
}

.status-error .status-text {
  color: #991b1b;
}

.status-warning {
  border-color: rgba(180, 83, 9, 0.25);
  background: var(--accent-soft);
  color: #78350f;
}

.status-warning .status-text {
  color: #92400e;
}

.status-title {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 13px;
}

.status-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@keyframes status-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Empty state — calmer than the warning banner */
.empty-state {
  display: grid;
  gap: 6px;
  padding: 28px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
  /* WCAG AA: --muted on --surface-soft was 4.32:1.
     Use --text-soft to keep an accessible contrast. */
  color: var(--text-soft);
}

.empty-state-title {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.empty-state-text {
  font-size: 13px;
  line-height: 1.5;
}

/* Loading state for async views */
.loading-state {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13px;
}

.loading-state::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  animation: spin 800ms linear infinite;
}

/* Summary */
.summary {
  display: grid;
  gap: 12px;
}

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

.summary-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-key {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.summary-value {
  margin-top: 4px;
  font-weight: 600;
  word-break: break-word;
  font-size: 14px;
}

/* Stepper */
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-base) var(--ease);
}

.step-pill.is-current {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: 0 1px 2px rgba(13, 110, 106, 0.18);
}

.step-pill.is-done {
  border-color: rgba(21, 128, 61, 0.25);
  background: var(--success-soft);
  color: var(--success);
}

.step-index {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: all var(--t-base) var(--ease);
}

.step-pill.is-current .step-index {
  background: var(--primary);
  color: #fff;
}

.step-pill.is-done .step-index {
  background: var(--success);
  color: #fff;
}

/* Step card */
.step-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  animation: card-in var(--t-slow) var(--ease);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.step-body {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.step-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

/* Checkbox */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  padding: 4px 0;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* File list */
.file-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.file-row {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.file-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.file-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.file-name {
  font-weight: 600;
  word-break: break-word;
  font-size: 14px;
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Tables */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table th,
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.table th {
  font-size: 12px;
  font-weight: 500;
  /* WCAG AA: --muted on --surface-soft was 4.32:1 (under threshold).
     --text-soft (#334155) on the same background passes comfortably. */
  color: var(--text-soft);
  background: var(--surface-soft);
  letter-spacing: 0.02em;
  text-transform: none;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background-color var(--t-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-soft);
}

.table code,
.code-block {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.code-block {
  padding: 12px;
  background: var(--surface-soft);
  border-radius: var(--radius);
  white-space: pre-wrap;
  line-height: 1.55;
  border: 1px solid var(--border);
}

/* Tabs */
.tabbar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 16px 0;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  /* Inactive tab text on surface-soft container: use text-soft for AA contrast */
  color: var(--text-soft);
  min-height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
}

.tab:hover:not(.is-active) {
  background: var(--surface);
  color: var(--text);
}

.tab.is-active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.subtabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.subtab {
  border: 1px solid transparent;
  background: transparent;
  /* Inactive subtab text on surface-soft container: use text-soft for AA contrast */
  color: var(--text-soft);
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
}

.subtab:hover:not(.is-active) {
  background: var(--surface);
  color: var(--text);
}

.subtab.is-active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.dashboard-grid {
  display: grid;
  gap: 16px;
}

/* Auth */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 88px);
  padding: 24px 0;
  background: radial-gradient(
      80% 60% at 50% 0%,
      rgba(13, 110, 106, 0.06),
      transparent 60%
    ),
    radial-gradient(
      60% 40% at 100% 100%,
      rgba(180, 83, 9, 0.04),
      transparent 70%
    );
}

.auth-panel {
  width: min(100%, 440px);
  padding: 28px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

/* Helpers */
.helper-list {
  display: grid;
  gap: 6px;
  /* Helper text on surface-soft: use text-soft for AA-safe contrast */
  color: var(--text-soft);
  font-size: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.helper-item {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.link-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.link-button:hover {
  border-color: var(--border-strong);
  background: var(--bg-alt);
}

.compact-note {
  color: var(--muted);
  font-size: 12px;
}

details > summary.compact-note {
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 4px 0;
}

details > summary.compact-note::-webkit-details-marker {
  display: none;
}

details > summary.compact-note::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform var(--t-fast) var(--ease);
  color: var(--muted);
}

details[open] > summary.compact-note::before {
  transform: rotate(90deg);
}

/* Section blocks */
.section-block {
  padding-top: 14px;
}

.section-block + .section-block {
  border-top: 1px solid var(--border);
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* Result box (after batch generation/import) */
.result-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--primary-soft-strong);
  border-radius: var(--radius);
  background: linear-gradient(
    180deg,
    var(--primary-soft),
    rgba(214, 240, 237, 0.35)
  );
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-title {
  font-weight: 600;
  color: var(--primary-strong);
  font-size: 14px;
}

.result-text {
  color: var(--text-soft);
  font-size: 13px;
  word-break: break-word;
}

/* Responsive */
@media (max-width: 960px) {
  .layout,
  .stats-grid,
  .metrics-grid,
  .field-grid,
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .hero-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 12px 16px;
    gap: 10px;
  }
  .topbar,
  .hero-row,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .page {
    width: calc(100% - 20px);
    padding: 16px 0 28px;
  }
  .panel {
    padding: 16px;
    border-radius: var(--radius);
  }
  .stats-grid,
  .metrics-grid,
  .field-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .table {
    min-width: 580px;
  }
  .button {
    padding: 0 12px;
  }
  .tabbar,
  .subtabs {
    width: 100%;
  }
  .tab,
  .subtab {
    flex: 1;
    min-width: 0;
  }
}

/* === Round-2 polish === */

/* Multi-line preservation in body / status text */
.step-body,
.status-text,
.empty-state-text {
  white-space: pre-line;
}

/* Topbar scroll shadow */
.topbar.is-scrolled {
  border-bottom-color: var(--border-strong);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 6px 16px rgba(15, 23, 42, 0.06);
}

/* Tab content fade-in */
.dashboard-grid #tab-content > * {
  animation: fade-in var(--t-base) var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Empty cell inside tables */
.table-empty {
  text-align: center !important;
  padding: 36px 16px !important;
  color: var(--muted) !important;
  font-size: 13px;
}

.table-empty-title {
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Dropzone for file upload */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 28px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-base) var(--ease),
    background-color var(--t-base) var(--ease);
}

.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  border-style: solid;
}

.dropzone.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  font-size: 18px;
  line-height: 1;
}

.dropzone-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.dropzone-hint {
  font-size: 12px;
  color: var(--muted);
}

.dropzone.has-files .dropzone-title {
  color: var(--primary-strong);
}

/* Input with affix (e.g. password show/hide) */
.input-affix {
  position: relative;
}

.input-affix .input {
  padding-right: 64px;
}

.affix-button {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.affix-button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

/* Code block scroll */
.code-block {
  max-height: 220px;
  overflow: auto;
}

/* Result box with code-block scroll companion */
.result-box .code-block {
  max-height: 180px;
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--primary-soft-strong);
}

/* Shortage list (formatted error details) */
.detail-list {
  margin: 6px 0 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 2px;
  color: inherit;
  font-size: 13px;
  line-height: 1.5;
}

.detail-list li {
  list-style: disc;
}

/* Stepper connector lines (only on wider screens) */
@media (min-width: 600px) {
  .stepper {
    gap: 0;
  }
  .stepper .step-pill + .step-pill {
    margin-left: -1px;
  }
  .stepper .step-pill {
    border-radius: 0;
  }
  .stepper .step-pill:first-child {
    border-top-left-radius: var(--radius-pill);
    border-bottom-left-radius: var(--radius-pill);
  }
  .stepper .step-pill:last-child {
    border-top-right-radius: var(--radius-pill);
    border-bottom-right-radius: var(--radius-pill);
  }
}

/* Auth panel input alignment */
.auth-panel .field {
  gap: 8px;
}

/* Compact note inside expanded details */
details[open] {
  padding-bottom: 4px;
}

/* Subtle table cell spacing for action columns */
.table .actions-cell {
  width: 1%;
  white-space: nowrap;
}

/* === Round-3 polish === */

/* Public layout: equal-height columns and consistent inner spacing */
.layout {
  align-items: stretch;
}

/* Panels in the layout become flex columns so children can fill height. */
.layout > .panel {
  display: flex !important;
  flex-direction: column;
  gap: 14px;
  align-self: stretch;
  min-height: 0;
}

/* Cancel the global `.panel + .panel` vertical spacing inside the grid layout
   — adjacent panels here sit in side-by-side cells, not stacked. */
.layout > .panel + .panel {
  margin-top: 0;
}

/* The legacy `.stack` grid inside these panels would otherwise fight the
   flex layout. Drop its grid behavior here. */
.layout > .panel.stack {
  display: flex !important;
}

/* Status banner inside the right panel only takes space when visible */
#session-panel > #status-banner:not(.is-visible) {
  display: none;
}

#session-body {
  flex: 1 1 auto;
  display: flex !important;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

#session-body > .empty-state,
#session-body > .step-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#session-body > .step-card .step-form {
  margin-top: auto;
  padding-top: 14px;
}

/* Push the helper-list to the bottom of the form */
#redeem-form > .helper-list {
  margin-top: auto;
}

/* Mode segmented control — colored to stand out */
#redeem-mode-tabs {
  background: var(--surface-soft);
  border-color: var(--border);
}

#redeem-mode-tabs .subtab {
  color: var(--text-soft);
}

#redeem-mode-tabs .subtab.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(13, 110, 106, 0.3);
}

#redeem-mode-tabs .subtab.is-active:hover {
  color: #fff;
}

/* Stock chip in topbar */
.badge.is-info {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: transparent;
  font-weight: 500;
}

.badge.is-warn {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  font-weight: 500;
}

.badge[hidden] {
  display: none !important;
}

/* Mobile: stop forcing equal heights so panels don't leave empty space */
@media (max-width: 960px) {
  .layout > .panel {
    align-self: auto;
  }
  #redeem-form > .helper-list {
    margin-top: 0;
  }
  #session-body > .empty-state,
  #session-body > .step-card {
    flex: 0 0 auto;
  }
}

/* === Lookup result row actions: compact horizontal triple === */

.button-compact {
  min-height: 28px;
  min-width: 56px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
  transition: background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* The "操作" column should hug its content, not stretch */
.table .row-actions {
  width: max-content;
  margin-left: auto;
}

/* In the lookup table the actions column was wrapping to two rows due to
   limited width. Give it room and right-align. */
.table th:last-child,
.table td:last-child {
  white-space: nowrap;
}

/* Compact buttons in dense rows: don't visibly translate on press / loading,
   and don't let the success state widen the cell when text changes. */
.button-compact:active:not(:disabled) {
  transform: none;
}

.row-actions .button {
  transform: none !important;
}

/* Lock the success-flash button to the same color/shape — only text changes. */
.button-compact.is-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(21, 128, 61, 0.35);
}
