/* ============================================================
   二维码识别转单工具 — 样式
   ============================================================ */

:root {
  --brand: #2b6cff;
  --brand-dark: #1a4fd6;
  --brand-soft: #eef3ff;
  --extra: #ff8a00;
  --extra-dark: #e07600;
  --extra-soft: #fff4e5;
  --ok: #12b76a;
  --danger: #e2445c;

  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;
  --line: #e4e7ec;
  --bg: #f4f6fb;
  --card: #ffffff;

  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 12px 28px -6px rgba(16, 24, 40, .12);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 8% -12%, #dfe9ff 0%, transparent 62%),
    radial-gradient(900px 460px at 104% 4%, #e6f7ef 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* ---------------- 顶部 ---------------- */

.bar {
  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;
  min-width: 0;
}

.logo {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(140deg, #4b86ff, var(--brand-dark));
  box-shadow: 0 6px 16px -4px rgba(43, 108, 255, .6);
  user-select: none;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: -.2px;
}

.brand .sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
}

/* 正常单 / 补单 分段控件 */
.segmented {
  position: relative;
  display: flex;
  padding: 4px;
  gap: 2px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.seg {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  padding: 9px 22px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .18s, color .18s, transform .12s;
  white-space: nowrap;
}

.seg:hover { color: var(--text); }
.seg:active { transform: scale(.97); }

.seg.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 10px -3px rgba(43, 108, 255, .7);
}

.seg.active[data-type="extra"] {
  background: var(--extra);
  box-shadow: 0 4px 10px -3px rgba(255, 138, 0, .7);
}

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card > h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
}

.step {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
}

/* ---------------- 省份 ---------------- */

.search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-wrap .ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  display: flex;
}

#search {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 11px 36px 11px 36px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}

#search::placeholder { color: var(--text-3); }

#search:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(43, 108, 255, .12);
}

.clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #eef0f4;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.clear-search.show { display: grid; }

.prov-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  max-height: 340px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 4px;
  scrollbar-width: thin;
}

.prov-grid::-webkit-scrollbar { width: 8px; }
.prov-grid::-webkit-scrollbar-thumb {
  background: #d5dbe5;
  border-radius: 8px;
}
.prov-grid::-webkit-scrollbar-track { background: transparent; }

.prov {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  background: #fbfcfe;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 4px;
  cursor: pointer;
  transition: all .14s;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prov:hover {
  border-color: #b9c8e8;
  color: var(--text);
  background: #fff;
}

.prov:active { transform: scale(.95); }

.prov.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 5px 12px -4px rgba(43, 108, 255, .75);
}

.no-match {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 24px 0;
}

/* ---------------- 上传区 ---------------- */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 176px;
  padding: 22px 16px;
  text-align: center;
  border: 2px dashed #cbd5e6;
  border-radius: 14px;
  background: linear-gradient(180deg, #fafcff, #f5f8ff);
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .16s;
}

.dropzone:hover {
  border-color: var(--brand);
  background: linear-gradient(180deg, #f7faff, var(--brand-soft));
}

.dropzone.drag {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.008);
  box-shadow: inset 0 0 0 3px rgba(43, 108, 255, .08);
}

.dz-icon {
  color: var(--brand);
  opacity: .9;
  margin-bottom: 2px;
}

.dz-main {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.dz-sub {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.7;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  background: #fff;
  border: 1px solid #d9dee8;
  border-bottom-width: 2px;
  border-radius: 5px;
  vertical-align: 1px;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* ---------------- 按钮 ---------------- */

.btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #c2cbd9; background: #fafbfd; }
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px -5px rgba(43, 108, 255, .8);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-ghost { color: var(--text-2); }

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* ---------------- 前缀条 ---------------- */

.prefix-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  border: 1px solid #d8e3ff;
}

.prefix-bar.extra {
  background: var(--extra-soft);
  border-color: #ffe0b8;
}

.prefix-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  flex: 0 0 auto;
}

#prefixText {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: .3px;
  word-break: break-all;
}

.prefix-bar.extra #prefixText { color: var(--extra-dark); }

.prefix-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------------- 结果列表 ---------------- */

.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.result-head h2 { margin: 0; }

.count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: #f1f3f7;
  border-radius: 20px;
  padding: 3px 9px;
}

.result-tools {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.result-tools .btn {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 9px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: #d5dbe5; border-radius: 8px; }

.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  background: #fcfdff;
  animation: pop .22s ease both;
}

.item.is-fail { border-color: #f6ccd4; background: #fff8f9; }
.item.is-pending { border-color: #e3e8f2; background: #fafbfe; }

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.idx {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  background: #f1f3f7;
  border-radius: 6px;
  padding: 2px 7px;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.fname {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.item-head .btn-copy {
  margin-left: auto;
  flex: 0 0 auto;
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  background: #fff;
  border: 1px solid #cddafc;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all .15s;
}

.item-head .btn-copy:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.item-head .btn-copy:active { transform: scale(.95); }
.item-head .btn-copy.done { background: var(--ok); border-color: var(--ok); color: #fff; }

.out {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.55;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.item.is-fail .out { color: var(--danger); font-weight: 500; font-family: inherit; font-size: 13.5px; }
.item.is-pending .out { color: var(--text-3); font-weight: 500; font-family: inherit; }

.raw {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed #e6eaf2;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.raw .k { color: var(--text-3); }

/* 空状态 */
.empty {
  text-align: center;
  padding: 38px 12px;
  color: var(--text-3);
  font-size: 13.5px;
  line-height: 1.9;
}

.empty svg { color: #cfd8e6; margin-bottom: 8px; }

/* ---------------- 页脚 ---------------- */

.foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.9;
}

.foot .dot { margin: 0 7px; opacity: .5; }

/* ---------------- Toast ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: #1d2939;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 99;
  max-width: calc(100vw - 40px);
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { background: #0e9f6e; }
#toast.err { background: #d1293d; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .prov-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-height: 260px; }
}

@media (max-width: 560px) {
  .app { padding: 14px 12px 44px; }
  .card { padding: 15px; border-radius: 14px; }
  .brand h1 { font-size: 17px; }
  .brand .sub { font-size: 11.5px; }
  .logo { width: 38px; height: 38px; flex-basis: 38px; border-radius: 11px; font-size: 17px; }
  .bar { gap: 12px; margin-bottom: 14px; }
  .segmented { width: 100%; }
  .seg { flex: 1; padding: 10px 0; }
  .prov-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .prov { font-size: 13px; padding: 11px 2px; }
  .dropzone { min-height: 150px; }
  .upload-actions .btn { flex: 1; }
  .result-tools { margin-left: 0; width: 100%; }
  .result-tools .btn { flex: 1; }
  .out { font-size: 14px; }
  #prefixText { font-size: 15px; }
  .list { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- 全站识别计数 ---------------- */

.foot-line {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.9;
}

.counter {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 18px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.counter-label {
  font-size: 12px;
  color: var(--text-2);
}

.counter-value {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}

.counter-unit {
  font-size: 12px;
  color: var(--text-3);
}

.counter.is-error .counter-value {
  font-size: 15px;
  color: var(--text-3);
}
