:root {
  --paper: #f2efe7;
  --surface: #fffdf7;
  --ink: #172521;
  --muted: #6b756f;
  --line: #cfd4cc;
  --teal: #167f72;
  --teal-dark: #0f5e55;
  --lime: #cbe868;
  --coral: #ef684f;
  --amber: #e6ad3c;
  --blue: #316b9d;
  --shadow: 0 14px 40px rgba(29, 49, 42, .08);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.page-noise { position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .35; background-image: linear-gradient(rgba(23,37,33,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(23,37,33,.035) 1px, transparent 1px); background-size: 28px 28px; }
.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; }

.topbar { max-width: 1440px; margin: 0 auto; padding: 24px 32px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; background: var(--ink); color: var(--lime); font: 800 13px/1 var(--mono); border-radius: 4px 14px 4px 4px; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font: 10px/1.2 var(--mono); letter-spacing: .09em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.local-pill { border: 1px solid var(--line); background: rgba(255,253,247,.7); padding: 9px 12px; border-radius: 99px; color: var(--muted); font-size: 12px; }
.local-pill i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-right: 7px; box-shadow: 0 0 0 4px rgba(22,127,114,.12); }

main { max-width: 1440px; margin: 0 auto; padding: 16px 32px 72px; }
.hero { min-height: 390px; display: grid; grid-template-columns: 1.04fr .96fr; align-items: center; gap: 72px; padding: 42px 24px 64px; }
.eyebrow, .step-label { color: var(--teal); font: 700 11px/1.2 var(--mono); letter-spacing: .14em; }
.hero h1 { margin: 18px 0 20px; font-size: clamp(48px, 6vw, 86px); line-height: .94; letter-spacing: -.065em; font-weight: 760; }
.hero h1 em { color: var(--teal); font-style: normal; }
.lede { max-width: 650px; color: var(--muted); font-size: 17px; line-height: 1.8; }
.rule-ledger { background: var(--ink); color: #f8f5ed; padding: 12px 28px; border-radius: 6px 34px 6px 6px; box-shadow: 18px 18px 0 rgba(22,127,114,.14); }
.rule-line { min-height: 92px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.rule-line:last-child { border-bottom: 0; }
.rule-index { font: 12px/1 var(--mono); color: rgba(255,255,255,.5); }
.rule-line strong, .rule-line small { display: block; }
.rule-line strong { font-size: 15px; margin-bottom: 7px; }
.rule-line small { color: rgba(255,255,255,.56); font-size: 12px; }
.rule-line b { padding: 7px 9px; border-radius: 3px; font: 700 10px/1 var(--mono); letter-spacing: .08em; }
.refund-rule b { color: var(--ink); background: var(--lime); }
.banned-rule b { background: var(--coral); }
.clean-rule b { background: var(--teal); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .65fr); gap: 18px; align-items: stretch; }
.panel { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 5px 22px 5px 5px; }
.import-panel { padding: 28px; }
.settings-panel { padding: 28px; }
.panel-heading, .results-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.panel-heading h2, .results-heading h2 { margin: 6px 0 0; font-size: 25px; letter-spacing: -.035em; }
.parse-count { background: var(--ink); color: var(--lime); font: 700 11px/1 var(--mono); padding: 8px 10px; border-radius: 3px; }
.panel-help { color: var(--muted); line-height: 1.7; font-size: 13px; max-width: 820px; }
textarea { width: 100%; min-height: 330px; resize: vertical; border: 0; outline: 0; color: #d8eadf; background: #10201b; padding: 22px; border-radius: 4px 16px 4px 4px; font: 13px/1.75 var(--mono); caret-color: var(--lime); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
textarea::placeholder { color: #75877f; }
.input-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.privacy-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.privacy-note span { color: var(--teal); }
.text-button { border: 0; padding: 4px; background: transparent; color: var(--teal-dark); cursor: pointer; font-weight: 700; font-size: 12px; }

.field-label { display: block; margin: 17px 0 7px; color: var(--muted); font: 650 11px/1.2 var(--mono); letter-spacing: .05em; }
input, select { width: 100%; min-height: 43px; color: var(--ink); background: #f8f6ef; border: 1px solid var(--line); border-radius: 4px; padding: 9px 11px; outline: 0; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,127,114,.12); }
.setting-stack { margin-top: 8px; }
.field-grid { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.small-grid { grid-template-columns: 1fr 1fr; }
.check-row { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; margin: 18px 0; cursor: pointer; }
.check-row input { width: 16px; height: 16px; min-height: 0; margin: 1px 0 0; accent-color: var(--teal); }

.button { border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 14px; min-height: 46px; padding: 0 18px; border-radius: 4px; font-weight: 760; transition: transform .14s ease, opacity .14s ease, border-color .14s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { width: 100%; color: #fff; background: var(--teal); justify-content: space-between; padding-left: 20px; }
.button-primary b { display: grid; place-items: center; width: 28px; height: 28px; color: var(--ink); background: var(--lime); border-radius: 3px; }
.button-stop { width: 100%; color: var(--coral); background: rgba(239,104,79,.08); border: 1px solid rgba(239,104,79,.3); margin-top: 8px; }
.button-ghost { background: rgba(255,253,247,.65); border: 1px solid var(--line); }
.compact { min-height: 36px; padding: 0 12px; font-size: 12px; }
.danger-text { color: var(--coral); }
.upgrade-box { margin-top: 25px; padding-top: 21px; border-top: 1px dashed var(--line); }
.upgrade-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.upgrade-heading > span:last-child { color: var(--muted); font: 10px/1.2 var(--mono); }
.upgrade-box > strong { display: block; font-size: 14px; }
.upgrade-box > p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.upgrade-box input[type="file"] { padding: 8px; font-size: 11px; }
.upgrade-button { width: 100%; min-height: 40px; margin-top: 12px; justify-content: space-between; color: var(--teal-dark); }
.upgrade-button b { font-size: 18px; }
.upgrade-status { display: block; margin-top: 8px; color: var(--muted); font: 10px/1.45 var(--mono); }

.run-strip { margin: 18px 0 0; display: grid; grid-template-columns: 260px 1fr 54px; align-items: center; gap: 18px; color: white; background: var(--ink); border-radius: 4px; padding: 18px 22px; }
.run-copy strong, .run-copy span { display: block; }
.run-copy span { color: rgba(255,255,255,.58); font: 11px/1.3 var(--mono); margin-top: 5px; }
.progress-track { height: 7px; background: rgba(255,255,255,.12); overflow: hidden; border-radius: 99px; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--lime); transition: width .25s ease; }
.run-percent { color: var(--lime); font: 700 12px/1 var(--mono); text-align: right; }

.results-section { margin-top: 64px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stats-grid { display: grid; grid-template-columns: 1.15fr repeat(4, 1fr); gap: 10px; margin: 22px 0 14px; }
.stat-card { position: relative; min-height: 126px; overflow: hidden; text-align: left; cursor: pointer; padding: 18px; color: var(--ink); background: rgba(255,253,247,.65); border: 1px solid var(--line); border-radius: 4px 16px 4px 4px; }
.stat-card::after { content: ""; position: absolute; width: 60px; height: 60px; right: -25px; bottom: -25px; border: 10px solid var(--line); border-radius: 50%; opacity: .42; }
.stat-card.active { box-shadow: inset 0 -4px 0 var(--ink); background: var(--surface); }
.stat-card.refunded.active { box-shadow: inset 0 -4px 0 var(--teal); }
.stat-card.deactivated.active { box-shadow: inset 0 -4px 0 var(--coral); }
.stat-card.not-refunded.active { box-shadow: inset 0 -4px 0 var(--amber); }
.stat-card.failed.active { box-shadow: inset 0 -4px 0 var(--blue); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 9px 0; font-size: 34px; letter-spacing: -.05em; }
.stat-card small { color: #89928d; font: 9px/1 var(--mono); letter-spacing: .1em; }

.table-shell { min-height: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 20px 4px 4px; box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th { color: var(--muted); background: #ebe9e1; font: 650 10px/1.2 var(--mono); letter-spacing: .06em; text-align: left; padding: 13px 15px; }
td { border-top: 1px solid #e1e3dc; padding: 14px 15px; vertical-align: top; font-size: 12px; line-height: 1.5; }
tbody tr:hover { background: #faf8f1; }
.email-cell strong { display: block; max-width: 250px; word-break: break-all; font-size: 13px; }
.email-cell small, .muted-cell { color: var(--muted); font: 10px/1.4 var(--mono); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border-radius: 99px; padding: 6px 9px; font-weight: 750; font-size: 11px; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-已退款 { color: var(--teal-dark); background: rgba(22,127,114,.12); }
.status-已封号 { color: #c54c37; background: rgba(239,104,79,.12); }
.status-未退款 { color: #9b6b0b; background: rgba(230,173,60,.15); }
.status-读取失败 { color: var(--blue); background: rgba(49,107,157,.12); }
.amount-list { font-weight: 760; }
.subject-cell { max-width: 310px; color: #42514c; }
.scope-note { color: var(--muted); max-width: 210px; }
.limited-tag { display: inline-block; margin-top: 5px; color: #a46b00; font: 9px/1.2 var(--mono); }
.detail-button { min-width: 34px; height: 32px; border: 1px solid var(--line); background: transparent; border-radius: 3px; cursor: pointer; }
.empty-state { text-align: center; padding: 58px 20px; }
.empty-mark { display: grid; place-items: center; margin: 0 auto 14px; width: 50px; height: 50px; color: var(--teal); border: 1px dashed var(--teal); border-radius: 50%; font: 20px/1 var(--mono); }
.empty-state h3 { margin: 0 0 7px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

.detail-dialog { width: min(760px, calc(100vw - 32px)); max-height: min(820px, calc(100vh - 32px)); padding: 0; border: 0; color: var(--ink); background: var(--surface); border-radius: 5px 24px 5px 5px; box-shadow: 0 28px 90px rgba(0,0,0,.3); }
.detail-dialog::backdrop { background: rgba(12,25,21,.62); backdrop-filter: blur(3px); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 26px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 6px 0 0; max-width: 620px; word-break: break-all; font-size: 20px; }
.dialog-close { width: 36px; height: 36px; border: 1px solid var(--line); background: transparent; border-radius: 50%; font-size: 22px; cursor: pointer; }
#detailContent { padding: 24px 26px 32px; }
.detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 22px; }
.detail-chip { background: #eeece4; padding: 13px; border-radius: 4px; }
.detail-chip small, .detail-chip strong { display: block; }
.detail-chip small { color: var(--muted); font: 9px/1.2 var(--mono); margin-bottom: 5px; }
.event-card { border: 1px solid var(--line); border-left: 4px solid var(--teal); padding: 16px; margin-top: 10px; border-radius: 3px; }
.event-card.deactivation { border-left-color: var(--coral); }
.event-card h4 { margin: 0 0 8px; font-size: 14px; }
.event-card p { margin: 4px 0; color: var(--muted); font-size: 12px; line-height: 1.55; word-break: break-word; }
.error-card { color: #a33e2e; background: rgba(239,104,79,.08); padding: 15px; border-radius: 3px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(420px, calc(100vw - 44px)); color: #fff; background: var(--ink); border-left: 5px solid var(--lime); padding: 14px 18px; border-radius: 3px; box-shadow: 0 20px 50px rgba(0,0,0,.22); font-size: 13px; }

@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; gap: 34px; }
  .workspace { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
  .topbar, main { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-top: 16px; }
  .local-pill { display: none; }
  .hero { padding: 32px 0 46px; min-height: 0; }
  .hero h1 { font-size: 48px; }
  .rule-ledger { padding: 10px 16px; }
  .rule-line { grid-template-columns: 28px 1fr; }
  .rule-line b { display: none; }
  .import-panel, .settings-panel { padding: 20px; }
  textarea { min-height: 280px; }
  .input-footer, .results-heading { align-items: flex-start; flex-direction: column; }
  .run-strip { grid-template-columns: 1fr 48px; }
  .run-copy { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { min-height: 110px; }
  .detail-summary { grid-template-columns: 1fr; }
}
