:root {
  --bg: #eef4f8;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #637089;
  --line: #d9e3ef;
  --accent: #287d70;
  --accent-2: #3b82f6;
  --danger: #dc2626;
  --soft: #f5f9fc;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at top left, #e4f0ef, var(--bg) 42%, #f7fbff); min-height: 100vh; }
a { color: inherit; }

.public-shell, .admin-shell { min-height: 100vh; display: grid; place-items: start center; padding: 28px 18px; }
.public-card, .admin-card, .admin-login { width: min(100%, 980px); background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 80px rgba(31,54,78,.12); padding: 24px; }
.public-head, .admin-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.brand-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--accent), #4f46e5); font-weight: 800; margin-bottom: 12px; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.04em; }
h2 { margin: 0 0 10px; }
p { color: var(--muted); line-height: 1.6; }
.small-link { border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; text-decoration: none; color: var(--accent); background: #fff; white-space: nowrap; }

.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 22px; }
.step { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px 14px 44px; background: #fff; color: var(--muted); font-weight: 700; }
.step::before { content: attr(data-step-dot); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #dbeafe; color: #2563eb; font-size: 13px; }
.step.active { border-color: rgba(40,125,112,.35); color: var(--accent); background: #f3fbf9; }

.guide-panel, .panel-box, .status-panel, .result-panel { border: 1px solid var(--line); border-radius: 18px; background: var(--soft); padding: 18px; margin-bottom: 18px; }
.guide-row { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.guide-row:first-of-type { border-top: 0; }
.guide-num { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #e0f2fe; color: #0369a1; font-weight: 800; }

.form-stack { display: grid; gap: 16px; }
label span, .email-grid label { font-weight: 700; color: #263952; }
input, textarea, select { width: 100%; border: 1px solid #cfdae8; border-radius: 13px; padding: 13px 14px; font: inherit; background: #fff; color: var(--ink); outline: none; }
textarea { resize: vertical; font-family: Consolas, "Microsoft YaHei", monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(40,125,112,.12); }
.btn { border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px; font-weight: 800; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.secondary { color: #17324c; }
.btn.wide { width: 100%; padding: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.query-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-bottom: 18px; }
.status-top { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.badge { display: inline-flex; padding: 7px 12px; border-radius: 999px; background: #e0f2fe; color: #0369a1; font-weight: 800; }
.badge.success { background: #dcfce7; color: #047857; }
.badge.manual { background: #fee2e2; color: #b91c1c; }
.progress-list { display: grid; gap: 10px; list-style: none; padding: 0; margin: 18px 0; }
.progress-list li { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; color: var(--muted); }
.progress-list li.active { border-color: var(--accent); color: var(--accent); font-weight: 800; background: #f0fdfa; }
.invoice-box { border-top: 1px solid var(--line); padding-top: 16px; }

.admin-shell { place-items: start center; }
.admin-card, .admin-login { width: min(100%, 1180px); }
.admin-actions, .tabs, .toolbar, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tabs { border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-bottom: 12px; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 18px; font-weight: 800; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats-grid div { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 18px; }
.stats-grid span { color: #4a5d77; font-weight: 700; }
.stats-grid strong { display: block; font-size: 34px; margin-top: 10px; }
.toolbar { margin-bottom: 14px; }
.toolbar input { flex: 1 1 360px; }
.toolbar select { width: 160px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #e8eef5; vertical-align: top; }
th { color: #465977; font-size: 13px; background: #fbfdff; }
td { font-size: 14px; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-weight: 800; background: #edf5f2; color: #047857; }
.status-pill.pending { background: #fef3c7; color: #a16207; }
.status-pill.processing { background: #dbeafe; color: #1d4ed8; }
.status-pill.failed, .status-pill.session_expired { background: #fee2e2; color: #b91c1c; }
.cell-actions { display: grid; gap: 8px; }
.mini { padding: 7px 10px; font-size: 13px; }
.email-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; }
.email-grid label { display: grid; gap: 8px; }
.email-grid label:first-child, .email-grid label:nth-last-child(2), .email-grid .form-actions { grid-column: 1 / -1; }
.login-form { display: flex; gap: 10px; margin-top: 20px; }
.login-form input { max-width: 360px; }
.import-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }

@media (max-width: 760px) {
  .public-card, .admin-card, .admin-login { padding: 18px; border-radius: 18px; }
  .public-head, .admin-head, .guide-row, .query-row, .login-form, .import-form { grid-template-columns: 1fr; display: grid; }
  .stepper, .stats-grid, .email-grid { grid-template-columns: 1fr; }
}
