/* ===== LPA eSIM 二维码生成器 — styles ===== */
:root {
  --bg: #eef2f9;
  --card: #ffffff;
  --ink: #1c2333;
  --muted: #6b7590;
  --line: #e3e8f2;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(30, 45, 90, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 400px at 15% -10%, #dbe7ff 0%, rgba(219, 231, 255, 0) 55%),
    radial-gradient(900px 380px at 95% 0%, #d8f7e9 0%, rgba(216, 247, 233, 0) 50%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
}

.mono {
  font-family: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px 6px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--primary);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
  position: relative;
}
.brand-chip { display: block; }
.brand-chip::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid #fff;
  border-radius: 3px;
}
.brand-chip i {
  position: absolute;
  background: #fff;
  border-radius: 1px;
}
.brand-chip i:nth-child(1) { left: 13px; top: 4px; width: 2px; height: 5px; }
.brand-chip i:nth-child(2) { left: 29px; top: 4px; width: 2px; height: 5px; }
.brand-chip i:nth-child(3) { left: 13px; bottom: 4px; width: 2px; height: 5px; }
.brand-chip i:nth-child(4) { left: 29px; bottom: 4px; width: 2px; height: 5px; }
.brand-text h1 { font-size: 19px; margin: 0; letter-spacing: .5px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.topnav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  margin-left: 16px;
}
.topnav a:hover { color: var(--primary); }

/* ---------- layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 10px 20px 30px; }

main.wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
  padding-top: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}

/* ---------- form ---------- */
.field { margin-bottom: 18px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #33405c;
}
.req { color: #e11d48; }
.lbl-note { font-weight: 400; color: var(--muted); font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.hint code {
  background: #eef2fb; border: 1px solid var(--line);
  border-radius: 4px; padding: 0 4px; font-size: 11px;
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 2px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  background: #fff;
}
.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.text-input::placeholder { color: #b4bdd2; }

.lpa-paste {
  resize: vertical;
  min-height: 76px;
  font-size: 13px;
  letter-spacing: .3px;
  line-height: 1.7;
}

/* 分段选择 */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: #eef1f8;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 9px 6px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  color: #4b5672;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  font-weight: 600;
}
.seg button:hover { color: var(--primary); }
.seg button.on {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(30, 45, 90, 0.14);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr 1fr;
  gap: 14px;
}
.field-row .field { margin-bottom: 0; }
.field-row input[type="color"] {
  width: 100%;
  height: 38px;
  border: 2px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  cursor: pointer;
  background: #fff;
}
.field-row input[type="range"] { width: 100%; accent-color: var(--primary); }

.mini-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: #33405c;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.btn-ghost:hover:not(:disabled) { background: #f4f7fd; box-shadow: 0 2px 8px rgba(30,45,90,.1); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- preview ---------- */
.preview-card { position: sticky; top: 14px; }
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.preview-head h2 { font-size: 16px; margin: 0; }
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: #0d8a52; }
.status.err { color: #c0392b; }

.qr-stage {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 12px;
}
.qr-stage canvas {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 6px;
}
.qr-empty { color: #9aa4bd; font-size: 14px; text-align: center; line-height: 1.9; }
.qr-empty.hidden { display: none; }

.lpa-preview {
  margin-top: 14px;
  background: #f4f7fd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.lpa-preview-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.lpa-text {
  font-size: 13px;
  color: #1d2a4a;
  word-break: break-all;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 10px;
  min-height: 20px;
}

.qr-info {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 18px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  color: #33405c;
  border-radius: 10px;
  padding: 11px 10px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(30,45,90,.12); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: #1d4fd7; }

.toast {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13px;
  background: #eafaf1;
  color: #0d8a52;
  border: 1px solid #bfe8d2;
  text-align: center;
}
.toast.err { background: #fdf0ef; color: #c0392b; border-color: #f3c9c5; }

/* ---------- howto / footer ---------- */
.howto {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 26px;
  margin-top: 4px;
}
.howto h2 { font-size: 16px; margin: 0 0 10px; }
.howto h3 { font-size: 14px; margin: 16px 0 8px; }
.howto ol { margin: 0; padding-left: 20px; font-size: 14px; color: #33405c; }
.howto li { margin: 6px 0; }
.howto code, .fmt-list code {
  background: #eef2fb; border: 1px solid var(--line);
  border-radius: 4px; padding: 0 4px; font-size: 12px;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}
.fmt-list { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: #33405c; }
.fmt-list li { margin: 6px 0; }
.fineprint { font-size: 12px; color: var(--muted); margin-top: 12px; }
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 20px 30px;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  main.wrap { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* ===== 打印样式：A4 标签 ===== */
.print-sheet { display: none; }

@media print {
  @page { size: A4; margin: 8mm; }
  body { background: #fff; }
  .topbar, main.wrap, .howto, .footer { display: none !important; }
  .print-sheet {
    display: block;
    margin: 0;
    padding: 0;
  }
  .print-grid {
    display: grid;
    gap: 6mm;
  }
  .print-grid.per4  { grid-template-columns: repeat(2, 1fr); }
  .print-label {
    border: 1px solid #bbb;
    border-radius: 3mm;
    padding: 4mm;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2mm;
    break-inside: avoid;
    text-align: center;
  }
  .print-label canvas {
    max-width: 100%;
    image-rendering: pixelated;
  }
  .print-label .pl {
    font-size: 10px;
    font-weight: 700;
    word-break: break-all;
    letter-spacing: .5px;
  }
  .print-label .pt {
    font-size: 11px;
    color: #555;
  }
  .print-label .pl-brand {
    font-size: 9px;
    color: #999;
    letter-spacing: 2px;
  }
}
