/* MailCode — 航空邮件主题 · 提取台布局
   一个账号，一个动作：提取验证码 / 链接 / 邮件 */

:root {
  --paper: #edf1f5;
  --panel: #f7f9fb;
  --ink: #16263e;
  --blue: #24528c;
  --red: #b23b3a;
  --muted: #6b7a8f;
  --line: #d7dee6;
  --serif: Georgia, "Times New Roman", "Songti SC", serif;
  --sans: -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* 航空邮件红蓝斜条纹边 */
.airmail-edge {
  height: 5px;
  background: repeating-linear-gradient(
    -45deg,
    var(--red) 0 14px,
    var(--paper) 14px 19px,
    var(--blue) 19px 33px,
    var(--paper) 33px 38px
  );
}

/* header */
header { background: var(--panel); border-bottom: 1px solid var(--line); padding: 16px 24px; }
.hdr-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.brand-name { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; letter-spacing: 0.5px; line-height: 1.1; }
.brand-sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.hdr-meta { display: flex; align-items: center; gap: 14px; }

.health {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 4px 11px;
  transform: rotate(-1.5deg);
}
.health::before { content: "●"; font-size: 9px; }
.health.up { color: #1f7a4d; border-color: #1f7a4d; }
.health.down { color: var(--red); border-color: var(--red); }

.base { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.base-label { white-space: nowrap; }
.base input {
  width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); padding: 6px 10px; font-size: 12.5px; font-family: var(--mono);
}
.base input:focus { outline: none; border-color: var(--blue); }

/* 布局 */
.wrap { max-width: 900px; margin: 0 auto; padding: 22px 16px 64px; }

/* 账号状态条 */
.account-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.account-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: 100%; }
.account-prompt { font-family: var(--serif); font-size: 15px; }
.account-actions { display: flex; gap: 8px; }
.account-ready { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: 100%; }
.account-id { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-email { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.account-tags { display: flex; gap: 6px; }
.tag {
  font-size: 11px; color: var(--muted); background: #eef2f6;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px;
}

/* 主提取区 */
.extract {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; box-shadow: 0 1px 3px rgba(22, 38, 62, 0.06);
}

/* 模式切换 */
.mode-switch {
  display: inline-flex; gap: 4px; background: #e7ecf1; border-radius: 8px;
  padding: 4px; margin-bottom: 16px;
}
.mode {
  border: none; background: none; color: var(--muted);
  padding: 7px 16px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-family: var(--sans);
}
.mode.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(22,38,62,0.08); }

/* 表单 */
.extract-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.field { flex: 1; min-width: 140px; }
.field.grow { flex: 2; min-width: 200px; }
.field.submit { flex: 0 0 auto; min-width: auto; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); padding: 9px 11px; font-size: 13px; font-family: var(--mono);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,82,140,0.12);
}
textarea { min-height: 74px; resize: vertical; }

button.btn {
  background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 9px 16px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: var(--sans);
  white-space: nowrap;
}
button.btn:hover { background: #1d4375; }
button.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
button.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }

/* 结果 */
.extract-result { margin-top: 14px; }
.result {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; font-family: var(--mono); font-size: 12.5px;
  white-space: pre-wrap; word-break: break-all; color: var(--ink);
}
.result.ok { border-left: 3px solid #1f7a4d; }
.result.err { border-left: 3px solid var(--red); color: #8c2f2e; }
.muted { color: var(--muted); }
.desc { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.desc code { font-family: var(--mono); background: #eef2f6; padding: 1px 5px; border-radius: 4px; color: var(--ink); }

/* 邮戳验证码（signature） */
.postmark {
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px dashed var(--red); border-radius: 50%;
  padding: 22px 30px; font-family: var(--mono);
  font-size: 30px; font-weight: 700; letter-spacing: 5px; color: var(--red);
  background: #fff; transform: rotate(-3deg);
}
.postmark.stamped { animation: stamp 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes stamp {
  0%   { transform: scale(1.7) rotate(-9deg); opacity: 0; }
  60%  { transform: scale(0.95) rotate(-2deg); opacity: 1; }
  100% { transform: scale(1) rotate(-3deg); opacity: 1; }
}

/* 邮件列表 */
.msglist .m {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
}
.m .subj { font-weight: 600; }
.m .meta { color: var(--muted); font-size: 11.5px; margin: 3px 0; }
.m pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; margin: 6px 0 0; max-height: 150px; overflow: auto; font-family: var(--mono); }

/* 弹层 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(22, 38, 62, 0.4);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  width: 100%; max-width: 760px; max-height: 88vh; overflow: auto; padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; }
.modal-close { border: none; background: none; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.mtab { border: none; background: none; color: var(--muted); padding: 8px 14px; cursor: pointer; font-size: 13px; font-family: var(--sans); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mtab.active { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }
.mpanel { display: none; }
.mpanel.active { display: block; }

/* 购买栏（已选 SKU + 购买按钮） */
.purchase-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.purchase-bar .selected-sku { color: var(--ink); font-family: var(--mono); }

/* 表格 */
.table-scroll { max-height: 380px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #eef2f6; color: var(--muted); border: 1px solid var(--line); }
.badge.stock-high { color: #1f7a4d; }
.badge.stock-mid { color: #8a6d1a; }
.badge.stock-0 { color: var(--red); }
tbody tr { cursor: pointer; }
tbody tr.selected { background: #eef4fb; }
tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--blue); }

.hidden { display: none !important; }
.chart-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .postmark.stamped { animation: none; } }
@media (max-width: 640px) {
  .hdr-inner { flex-direction: column; align-items: flex-start; }
  .base { width: 100%; } .base input { flex: 1; width: auto; }
  .field { min-width: 100%; }
  .extract-form { flex-direction: column; }
  .field.submit { width: 100%; } .field.submit .btn { width: 100%; }
}
