/* =====================================================================
   帽子绿 · 卡密用户端模板样式
   设计来源：参考站 b.axxlya.com 的用户卡密页（绿白单卡片、三段式、绿色主按钮）。
   自带完整样式，不依赖 classic.css；在 tokens.css 之后加载。
   只改配色：覆盖下面 body.tpl-hat-green 里的 --hg-* 变量即可。
   ===================================================================== */
body.tpl-hat-green {
  --hg-green: #4caf50;          /* 主色（按钮 / 状态栏） */
  --hg-green-d: #3d8b40;        /* 主色加深（hover / 文字） */
  --hg-green-l: #e8f5e9;        /* 主色浅底 */
  --hg-red: #f44336;            /* 已使用状态栏 / 过期提示 */
  --hg-blue: #2196f3;           /* 蓝色提示语 */
  --hg-amber: #fff3cd;          /* 验证码底色 */
  --hg-ink: #333;
  --hg-ink-2: #666;
  --hg-ink-3: #999;
  --hg-line: #ececec;
  --hg-box: #f9f9f9;
  --hg-shadow: 0 2px 10px rgba(0, 0, 0, .1);

  margin: 0;
  padding: 10px;
  min-height: 100%;
  background: #f5f5f5;
  color: var(--hg-ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body.tpl-hat-green *, body.tpl-hat-green *::before, body.tpl-hat-green *::after { box-sizing: border-box; }
body.tpl-hat-green .num, body.tpl-hat-green input { font-variant-numeric: tabular-nums; }
body.tpl-hat-green a { color: var(--hg-green-d); text-decoration: none; }
body.tpl-hat-green button { font-family: inherit; }
body.tpl-hat-green .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 卡片容器（整页一张白卡，和参考站一致） ---------- */
body.tpl-hat-green .wap {
  width: 100%; max-width: 400px; margin: 0 auto; padding: 18px 20px 20px;
  background: #fff; border-radius: 8px; box-shadow: var(--hg-shadow);
}
body.tpl-hat-green .wap--plain { padding-top: 14px; margin-top: 10px; }

/* ---------- 顶部品牌区 ---------- */
body.tpl-hat-green .hg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
body.tpl-hat-green .hg-head__t { font-size: 16px; font-weight: 700; }
body.tpl-hat-green .hg-head__sub { font-size: 12px; color: var(--hg-ink-3); margin-top: 4px; word-break: break-all; }
body.tpl-hat-green .hg-head__sub .num { color: var(--hg-ink-2); }
body.tpl-hat-green .pill {
  display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
  padding: 5px 10px; font-size: 12px; color: var(--hg-green-d);
  background: var(--hg-green-l); border: 0; border-radius: 20px; cursor: pointer;
}
body.tpl-hat-green .pill__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hg-red); }

/* ---------- 状态栏（未使用=绿 / 已使用=红） ---------- */
body.tpl-hat-green .status-bar {
  padding: 10px; margin-bottom: 18px; border-radius: 4px; text-align: center;
  background: var(--hg-green); color: #fff; font-size: 14px; font-weight: 600;
}
body.tpl-hat-green .status-bar--used { background: var(--hg-red); }

/* ---------- 分段 ---------- */
body.tpl-hat-green .hg-sec { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--hg-line); }
body.tpl-hat-green .hg-sec:first-of-type { padding-top: 0; margin-top: 0; border-top: 0; }
body.tpl-hat-green .hg-sec__h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
body.tpl-hat-green .hg-sec__h h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--hg-ink); }
body.tpl-hat-green .hg-note { font-size: 12px; color: var(--hg-ink-3); }
body.tpl-hat-green .hg-note b { color: var(--hg-red); }

/* ---------- 展示框 ---------- */
body.tpl-hat-green .hg-display {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 10px 14px; margin-bottom: 10px;
  background: var(--hg-box); border-radius: 4px; font-size: 20px; text-align: center;
}
body.tpl-hat-green .hg-display--code { font-size: 26px; font-weight: 700; }
body.tpl-hat-green .hg-display--on { background: var(--hg-amber); }
body.tpl-hat-green .hg-display--empty { font-size: 15px; color: var(--hg-ink-3); }
body.tpl-hat-green .hg-display--bad { font-size: 15px; color: var(--hg-red); }

/* ---------- 提示语 ---------- */
body.tpl-hat-green .hg-tip { margin: 6px 0 10px; font-size: 13px; color: var(--hg-ink-2); text-align: center; }
body.tpl-hat-green .hg-tip--red { color: var(--hg-red); }
body.tpl-hat-green .hg-tip--blue { color: var(--hg-blue); font-weight: 700; font-size: 13px; line-height: 1.6; }
body.tpl-hat-green .hg-tip--arrived { color: var(--hg-red); font-size: 16px; font-weight: 700; margin-bottom: 8px; }
body.tpl-hat-green .hg-meta { font-size: 12px; color: var(--hg-ink-3); text-align: center; margin: 8px 0 0; word-break: break-all; }
body.tpl-hat-green .hg-meta b { color: var(--hg-ink); }
body.tpl-hat-green .hg-count { margin: 8px 0 0; font-size: 13px; color: var(--hg-ink-2); text-align: center; }

/* ---------- 按钮 ---------- */
body.tpl-hat-green .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 11px 16px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--hg-green); border: 0; border-radius: 4px; cursor: pointer;
  -webkit-appearance: none;
}
body.tpl-hat-green .btn:hover:not(:disabled) { background: var(--hg-green-d); }
body.tpl-hat-green .btn:disabled { background: #ccc; cursor: not-allowed; }
body.tpl-hat-green .btn--lg { padding: 13px 16px; font-size: 16px; }
body.tpl-hat-green .btn--sm { width: auto; padding: 7px 14px; font-size: 13px; font-weight: 500; flex: 0 0 auto; }
body.tpl-hat-green .btn--soft { background: var(--hg-green-l); color: var(--hg-green-d); }
body.tpl-hat-green .btn--soft:hover:not(:disabled) { background: #dcefdd; }
body.tpl-hat-green .btn--soft:disabled { background: #f1f1f1; color: #b6b6b6; }
body.tpl-hat-green .btn--ghost { background: #fff; color: var(--hg-ink-2); border: 1px solid var(--hg-line); }
body.tpl-hat-green .btn--ghost:hover:not(:disabled) { background: var(--hg-box); }
body.tpl-hat-green .btn--ghost:disabled { background: #f7f7f7; color: var(--hg-ink-3); border-color: var(--hg-line); }
body.tpl-hat-green .row2 { display: flex; gap: 10px; margin-top: 10px; }
body.tpl-hat-green .row2 .btn { margin-top: 0; }
body.tpl-hat-green main > .btn + .btn { margin-top: 10px; }
body.tpl-hat-green .hg-linkbtn {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px;
  font-size: 13px; color: var(--hg-green-d); background: var(--hg-green-l);
  border: 0; border-radius: 4px; cursor: pointer;
}
body.tpl-hat-green .hg-linkbtn:disabled { color: var(--hg-ink-3); background: #f2f2f2; cursor: not-allowed; }

/* ---------- 输入框 ---------- */
body.tpl-hat-green .input {
  display: block; width: 100%; padding: 12px 14px; margin-bottom: 10px;
  font-size: 16px; color: var(--hg-ink); background: var(--hg-box);
  border: 1px solid var(--hg-line); border-radius: 4px; outline: none;
}
body.tpl-hat-green .input:focus { background: #fff; border-color: var(--hg-green); }
body.tpl-hat-green .field-error { margin-top: 8px; font-size: 13px; color: var(--hg-red); text-align: center; }

/* ---------- 虚拟信息字段 ---------- */
body.tpl-hat-green .hg-fields { display: grid; gap: 8px; margin-bottom: 10px; }
body.tpl-hat-green .hg-field {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--hg-box); border-radius: 4px;
}
body.tpl-hat-green .hg-field__k { flex: 0 0 auto; font-size: 13px; color: var(--hg-ink-3); }
body.tpl-hat-green .hg-field__v { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; word-break: break-all; }

/* ---------- m01 输入卡密 ---------- */
body.tpl-hat-green .m01 { text-align: center; }
body.tpl-hat-green .m01__logo {
  width: 58px; height: 58px; margin: 4px auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--hg-green-l); color: var(--hg-green-d);
}
body.tpl-hat-green .m01__logo .ic { width: 28px; height: 28px; }
body.tpl-hat-green .m01__title { margin: 0; font-size: 18px; font-weight: 700; }
body.tpl-hat-green .m01__sub { margin: 6px 0 16px; font-size: 13px; color: var(--hg-ink-3); }
body.tpl-hat-green .m01__form { text-align: left; }
body.tpl-hat-green .m01__links { margin-top: 14px; font-size: 13px; color: var(--hg-ink-3); }
body.tpl-hat-green .m01__links span { margin: 0 8px; color: var(--hg-line); }

/* ---------- 顶栏（子页） ---------- */
body.tpl-hat-green .topbar {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 400px; margin: 0 auto; padding: 12px 14px;
  background: #fff; border-radius: 8px; box-shadow: var(--hg-shadow);
}
body.tpl-hat-green .topbar__back {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: 0 0 auto; color: var(--hg-green-d); background: var(--hg-green-l); border-radius: 50%;
}
body.tpl-hat-green .topbar__title { flex: 1 1 auto; margin: 0; font-size: 15px; font-weight: 700; text-align: center; }
body.tpl-hat-green .topbar__right { width: 32px; flex: 0 0 auto; }

/* ---------- 阶段页 / 等待 ---------- */
body.tpl-hat-green .stage { padding: 18px 0 6px; text-align: center; }
body.tpl-hat-green .stage__main { font-size: 16px; font-weight: 700; }
body.tpl-hat-green .stage__sub { margin-top: 6px; font-size: 13px; color: var(--hg-ink-3); }
body.tpl-hat-green .ring {
  width: 46px; height: 46px; margin: 6px auto 16px; border-radius: 50%;
  border: 3px solid var(--hg-green-l); border-top-color: var(--hg-green);
  animation: hg-spin .9s linear infinite;
}
body.tpl-hat-green .ring--pulse { animation: hg-pulse 1.4s ease-in-out infinite; border-top-color: var(--hg-green); }
@keyframes hg-spin { to { transform: rotate(360deg); } }
@keyframes hg-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .65; } }
body.tpl-hat-green .steps { display: grid; gap: 8px; margin-top: 14px; }
body.tpl-hat-green .step { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; color: var(--hg-ink-3); background: var(--hg-box); border-radius: 4px; }
body.tpl-hat-green .step--done { color: var(--hg-green-d); background: var(--hg-green-l); }
body.tpl-hat-green .step--now { color: var(--hg-ink); background: var(--hg-green-l); font-weight: 600; }

/* ---------- 使用记录 ---------- */
body.tpl-hat-green .hg-log { padding: 12px 14px; margin-bottom: 8px; background: var(--hg-box); border-radius: 4px; }
body.tpl-hat-green .hg-log__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
body.tpl-hat-green .hg-log__mark { font-size: 12px; font-weight: 600; color: var(--hg-green-d); }
body.tpl-hat-green .hg-log__meta { margin-top: 4px; font-size: 12px; color: var(--hg-ink-3); word-break: break-all; }
body.tpl-hat-green .hg-log__meta b { color: var(--hg-ink); }
body.tpl-hat-green .hg-log__sms { margin-top: 4px; font-size: 13px; color: var(--hg-ink-2); }

/* ---------- 弹层 ---------- */
body.tpl-hat-green .modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0, 0, 0, .45); }
body.tpl-hat-green .modal[hidden] { display: none; }
body.tpl-hat-green .modal__box { width: 100%; max-width: 360px; padding: 16px 18px 18px; background: #fff; border-radius: 8px; }
body.tpl-hat-green .modal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body.tpl-hat-green .modal__title { margin: 0; font-size: 16px; font-weight: 700; }
body.tpl-hat-green .modal__close { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; color: var(--hg-ink-3); background: none; border: 0; cursor: pointer; }
body.tpl-hat-green .modal__body { margin: 12px 0; font-size: 14px; color: var(--hg-ink-2); max-height: 50vh; overflow: auto; word-break: break-word; }
body.tpl-hat-green .modal__body h2 { font-size: 15px; color: var(--hg-ink); }

/* ---------- 全局提示（/js/wap.js 动态创建 .m-toast） ---------- */
body.tpl-hat-green .m-toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 14px 24px; border-radius: 8px; color: #fff; font-size: 15px;
  background: rgba(0, 0, 0, .7); z-index: 9999; max-width: 80vw; text-align: center;
}
body.tpl-hat-green .m-toast[hidden] { display: none; }

/* ---------- 窄屏微调 ---------- */
@media (max-width: 360px) {
  body.tpl-hat-green { padding: 8px; }
  body.tpl-hat-green .wap { padding: 14px 14px 16px; }
  body.tpl-hat-green .hg-display { font-size: 18px; }
  body.tpl-hat-green .hg-display--code { font-size: 22px; }
}
