/* ===========================================================
   条形码生成器 · 样式
   =========================================================== */
:root {
  --bg: #eef2f9;
  --card: #ffffff;
  --line: #e6ebf4;
  --line-strong: #d7dfee;
  --text: #1e2637;
  --label: #46536b;
  --muted: #7c889c;
  --primary: #2f6bff;
  --primary-dark: #1e50e0;
  --primary-soft: #eef3ff;
  --accent: #f97316;
  --danger: #d93a3a;
  --radius: 16px;
  --shadow: 0 12px 30px rgba(28, 48, 92, .08), 0 2px 6px rgba(28, 48, 92, .04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 12% -8%, #ffffff 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #f4f7fd 0%, var(--bg) 46%, #e7ecf8 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1664px; margin: 0 auto; padding: 22px 24px 46px; }

/* ---------------- 顶部 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  position: relative; width: 40px; height: 40px; border-radius: 13px;
  background: linear-gradient(135deg, var(--primary) 0%, #7aa2ff 100%);
  box-shadow: 0 8px 18px rgba(47, 107, 255, .28);
  flex: none;
}
.logo::after {
  content: ""; position: absolute; inset: 10px 11px;
  background: repeating-linear-gradient(90deg, #fff 0 2px, rgba(255, 255, 255, 0) 2px 5px);
  border-radius: 1px;
}
.brand-text h1 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.brand-text p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; color: #4a5a76; background: #fff;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; box-shadow: 0 1px 2px rgba(28, 48, 92, .04);
}

/* ---------------- 布局 ---------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 18px; align-items: start;
}
@media (min-width: 1440px) {
  .layout { grid-template-columns: minmax(330px, 430px) minmax(0, 1fr); gap: 20px; }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.preview-card { position: sticky; top: 18px; }

@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .preview-card { position: static; }
}

/* ---------------- 预览卡 ---------------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 15px; }
.head-tools { display: flex; align-items: center; gap: 8px; }
.badge {
  font-family: Consolas, "Courier New", monospace; font-size: 12px; font-weight: 700;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.refresh {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; color: #5b6880; font-size: 15px; line-height: 1;
  cursor: pointer; transition: color .15s, border-color .15s, transform .3s, background .15s;
}
.refresh:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.refresh:active { transform: rotate(180deg); }

.stage {
  display: grid; place-items: center;
  min-height: 190px; padding: 16px;
  border: 1px dashed var(--line-strong); border-radius: 12px;
  background: #fafcff; overflow: auto; transition: border-color .15s, background .15s;
}
.stage.checker {
  background-image:
    linear-gradient(45deg, #eff3fa 25%, transparent 25%, transparent 75%, #eff3fa 75%),
    linear-gradient(45deg, #eff3fa 25%, transparent 25%, transparent 75%, #eff3fa 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.stage.error { border-color: #f2c2c2; background: #fff7f7; }
.stage svg {
  display: block; max-width: 100%; height: auto;
  border-radius: 3px;
  filter: drop-shadow(0 4px 10px rgba(28, 48, 92, .10));
}
.stage-empty { color: var(--muted); font-size: 13px; }

.meta {
  margin: 12px 0 2px; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums; line-height: 1.7; min-height: 20px;
}

.actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 12px;
}
.btn {
  min-width: 0; height: 40px; padding: 0 12px;
  border-radius: 11px; border: 1px solid var(--line-strong); background: #fff;
  color: #3d4a63; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: transform .06s, box-shadow .15s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: #fbfdff; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, #4d81ff 100%);
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 18px rgba(47, 107, 255, .28);
}
.btn.primary:hover { color: #fff; background: linear-gradient(135deg, var(--primary-dark), #4272ff); }
.btn.ghost { color: var(--muted); font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.tip { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.tip::before {
  content: "i"; display: inline-grid; place-items: center;
  width: 14px; height: 14px; margin-right: 6px; border-radius: 50%;
  background: #e9eefb; color: #5b6f95; font-size: 10px; font-weight: 700;
  font-family: Georgia, serif; vertical-align: 1px;
}

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field.block { margin-bottom: 20px; }
.label-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--label);
}
output {
  font-size: 11.5px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border-radius: 999px; padding: 1px 9px;
  font-variant-numeric: tabular-nums;
}
.counter { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

input[type="text"], input[type="number"], select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]::placeholder { color: #a9b4c7; }
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .14);
}
input[type="number"] { font-variant-numeric: tabular-nums; padding-right: 6px; }
.input-box { position: relative; }
.input-box input { padding-right: 42px; font-family: Consolas, "Courier New", monospace; letter-spacing: .4px; }
.clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: #f1f4fa; color: #8d99ad; font-size: 17px; line-height: 1;
  cursor: pointer; transition: background .15s, color .15s;
}
.clear:hover { background: #e6ebf6; color: #4a5a76; }

.hint { margin: 0; font-size: 12px; line-height: 1.65; color: var(--muted); }
.hint.error { color: var(--danger); font-weight: 600; }

.grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 18px;
}
.grid.extras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* 跨满当前行剩余列（3 列布局时正好一行；4 列布局时接在前面的参数后面） */
.span-3 { grid-column: span 3; }
/* 宽屏：一行放 4 个参数，少滚动 */
@media (min-width: 1440px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid.extras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid, .grid.extras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .grid, .grid.extras { grid-template-columns: minmax(0, 1fr); }
}

.select-wrap { position: relative; }
.select-wrap.grow { flex: 1 1 auto; min-width: 0; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; }
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%;
  width: 7px; height: 7px; border-right: 2px solid #98a4ba; border-bottom: 2px solid #98a4ba;
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

.inline-row { display: flex; align-items: center; gap: 8px; }
.toggle {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #fff;
  color: var(--label); font: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer; transition: all .15s;
}
.toggle.italic { font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.toggle:hover { border-color: var(--primary); color: var(--primary); }
.toggle.on {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .10);
}

.check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--label); cursor: pointer; user-select: none;
}
.check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.check.tight { font-size: 12px; color: var(--muted); }

/* 滑块 */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) var(--pct, 50%),
                              #dfe6f3 var(--pct, 50%), #dfe6f3 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px;
  border-radius: 50%; background: #fff; border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(28, 48, 92, .28); transition: transform .12s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 3px; background: #dfe6f3;
}
input[type="range"]::-moz-range-progress {
  height: 4px; border-radius: 3px; background: var(--primary);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 2px solid var(--primary); box-shadow: 0 1px 4px rgba(28, 48, 92, .28);
}

/* 分段控件 */
.seg {
  display: flex; gap: 2px; height: 40px; padding: 3px;
  background: #f2f5fb; border: 1px solid var(--line); border-radius: 10px;
}
.seg button {
  flex: 1 1 0; min-width: 0; padding: 0 8px;
  border: 0; border-radius: 8px; background: transparent;
  font: inherit; font-size: 12.5px; color: #5b6880; cursor: pointer;
  white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--primary); }
.seg button.active {
  background: #fff; color: var(--primary); font-weight: 700;
  box-shadow: 0 1px 4px rgba(28, 48, 92, .14);
}

/* 颜色 */
.colors { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.color {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--label); cursor: pointer;
}
input[type="color"] {
  width: 28px; height: 28px; padding: 0; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.mini {
  height: 28px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #fff;
  color: #5b6880; font: inherit; font-size: 12px; cursor: pointer;
}
.mini:hover { border-color: var(--primary); color: var(--primary); }
.mini.link {
  height: 22px; padding: 0 9px; border-color: var(--line);
  color: var(--muted); font-weight: 500; background: #fbfcff;
}

/* 分隔标题 */
.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 24px 0 18px; font-size: 13px; font-weight: 700; color: #2c3850;
}
.divider::before, .divider::after {
  content: ""; height: 1px; background: var(--line); flex: 1 1 auto;
}
.divider::after { flex: 0 1 40px; }
.divider .new {
  font-style: normal; font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), #ffa257);
  border-radius: 999px; padding: 2px 8px; letter-spacing: .5px;
}
.field.note p {
  margin: 0; font-size: 12px; line-height: 1.75; color: var(--muted);
  background: #f7f9fd; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px;
}

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  position: relative; border: 1px solid var(--line); background: #fff;
  color: #5b6880; font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 18px; border-radius: 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(28, 48, 92, .04);
  transition: color .15s, border-color .15s, background .15s;
}
.tab em {
  font-style: normal; font-weight: 500; font-size: 11.5px; color: var(--muted);
  margin-left: 7px; padding: 1px 7px; border-radius: 999px; background: #f1f4fa;
}
.tab:hover { color: var(--primary); border-color: #cdd9f5; }
.tab.is-active {
  color: var(--primary); border-color: #c3d4ff; background: var(--primary-soft);
  box-shadow: 0 6px 16px rgba(47, 107, 255, .12);
}
.tab.is-active::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--primary);
}
.tab.is-active em { background: #fff; color: var(--primary); }

/* ---------------- 批量：上传区 ---------------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 14px; text-align: center; cursor: pointer;
  border: 1.5px dashed #c8d4ea; border-radius: 12px; background: #fafcff;
  transition: border-color .15s, background .15s, transform .1s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: #f4f8ff; }
.dropzone.is-over { transform: scale(1.01); }
.dz-plus {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  font-size: 17px; font-weight: 700;
}
.dropzone strong { font-size: 13.5px; color: #2c3850; }
.dz-hint { font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.file-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 10px; padding: 8px 12px; border-radius: 10px;
  background: #f4f8ff; border: 1px solid #dde8ff;
  font-size: 12.5px; color: #3d4a63;
}
.file-chip b { font-weight: 700; }
.file-chip .chip-meta { color: var(--muted); font-size: 11.5px; }

.template-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 9px; font-size: 11.5px; color: var(--muted);
}
.linkbtn { color: var(--primary); font-weight: 600; text-decoration: none; white-space: nowrap; }
.linkbtn:hover { text-decoration: underline; }

.thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.thumbs:empty { display: none; }
.thumb {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.thumb img { width: 100%; height: auto; display: block; border-radius: 4px; }
.thumb span { font-size: 11px; color: var(--muted); text-align: center; }

.table-wrap { margin-top: 12px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.rowtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.rowtable th, .rowtable td {
  padding: 6px 9px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line); max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.rowtable th { background: #f7f9fd; color: #5b6880; font-weight: 600; position: sticky; top: 0; }
.rowtable tr:last-child td { border-bottom: 0; }
.rowtable td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }

.summary {
  font-size: 12.5px; line-height: 1.9; color: #46536b;
  background: #f7f9fd; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
}
.summary b { color: var(--primary); font-variant-numeric: tabular-nums; }

.warnbox {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: #fff8ec; border: 1px solid #ffe0b2; color: #94551a;
  font-size: 12px; line-height: 1.8; max-height: 168px; overflow: auto;
}
.warnbox strong { display: block; margin-bottom: 4px; color: #a45c12; }

/* ---------------- 页脚 / toast ---------------- */
.foot {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin-top: 26px; font-size: 12px; color: #94a0b5;
}
.dot-sep { opacity: .6; }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 12px);
  background: rgba(30, 38, 55, .94); color: #fff;
  font-size: 13px; padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 99;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
