/* PDF 工具箱 — 样式表（无外部依赖，离线可用） */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1c2333;
  --ink-soft: #5b6478;
  --line: #e2e6f0;
  --brand: #3b5bfd;
  --brand-dark: #2a45d8;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --red: #dc2626;
  --amber: #b45309;
  --amber-soft: #fff7e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 28, 50, .06), 0 8px 24px -12px rgba(20, 28, 50, .18);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
        "PingFang SC", "Hiragino Sans GB", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px 28px;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #7b61ff);
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .5px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px -6px rgba(59, 91, 253, .7);
}

.topbar h1 { margin: 0; font-size: 19px; letter-spacing: .2px; }
.sub { margin: 0; color: var(--ink-soft); font-size: 12.5px; }

.badges { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 12px; padding: 5px 11px; border-radius: 999px;
  background: #eef1f9; color: var(--ink-soft); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: #15803d; border-color: #c9ebd6; }

/* ---------------------------------------------------------------- Tabs */

.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 14px 28px 0;
  max-width: 1180px; margin: 0 auto;
}

.tab {
  appearance: none; cursor: pointer;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-soft); font-size: 13.5px; font-weight: 600;
  padding: 9px 15px; border-radius: 10px 10px 0 0;
  transition: background .15s, color .15s;
}
.tab:hover { background: #eaeefb; color: var(--ink); }
.tab.active {
  background: var(--panel); color: var(--brand);
  border-color: var(--line); border-bottom-color: var(--panel);
  box-shadow: 0 -2px 0 var(--brand) inset;
}

/* ---------------------------------------------------------------- 布局 */

main { max-width: 1180px; margin: 0 auto; padding: 0 28px 40px; }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 14px; font-size: 14.5px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}

/* ---------------------------------------------------------------- 拖放区 */

.drop {
  border: 2px dashed #c8d0e6; border-radius: var(--radius);
  background: #fafbff;
  padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.drop:hover { border-color: var(--brand); background: #f3f6ff; }
.drop.over { border-color: var(--brand); background: #eaf0ff; transform: scale(1.005); }
.drop-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.drop-title { font-weight: 600; font-size: 14.5px; }
.drop-hint { color: var(--ink-soft); font-size: 12.5px; margin-top: 4px; }

/* ---------------------------------------------------------------- 文件列表 */

.filelist { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.fileitem {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fcfdff;
}
.fileitem .fi-icon { font-size: 17px; }
.fileitem .fi-name {
  flex: 1; min-width: 0; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fileitem .fi-meta { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.fileitem .fi-ord {
  width: 22px; height: 22px; border-radius: 6px; background: #eef1f9;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
}
.fileitem .fi-thumb {
  width: 34px; height: 44px; object-fit: contain; border: 1px solid var(--line);
  border-radius: 4px; background: #fff;
}

/* ---------------------------------------------------------------- 表单 */

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}

label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
}
label.check, label.radio {
  flex-direction: row; align-items: center; gap: 8px;
  font-weight: 500; color: var(--ink); font-size: 13px;
}
label.radio { align-items: flex-start; }

input[type="text"], input[type="number"], select {
  font: inherit; font-size: 13.5px; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; width: 100%;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 91, 253, .12);
}
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 16px; height: 16px; }

.val { color: var(--brand); font-weight: 700; }
.hint { font-weight: 400; color: #8b93a7; font-size: 12px; }

.radios { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }

.warn {
  margin: 14px 0 0; padding: 10px 12px; font-size: 12.5px;
  background: var(--amber-soft); color: var(--amber);
  border: 1px solid #f3e0b8; border-radius: 9px;
}

/* ---------------------------------------------------------------- 按钮 */

.actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 9px 18px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: #f5f7fe; border-color: #c8d0e6; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 16px -8px rgba(59, 91, 253, .9);
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { color: var(--red); border-color: #f3c9c9; }
.btn.danger:hover { background: #fdf2f2; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.note { color: var(--ink-soft); font-size: 12.5px; }

/* ---------------------------------------------------------------- 页面网格 */

.pagegrid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
}

.pagecell {
  border: 1px solid var(--line); border-radius: 10px; background: #fcfdff;
  padding: 8px; cursor: grab; position: relative;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.pagecell.selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(59, 91, 253, .18); }
.pagecell.dragging { opacity: .4; }
.pagecell.dropTarget { border-color: var(--brand); border-style: dashed; }
.pagecell.removed { opacity: .35; filter: grayscale(1); }

.pagecell img {
  width: 100%; height: 132px; object-fit: contain;
  background: #fff; border-radius: 6px; border: 1px solid #eef1f9; display: block;
  pointer-events: none;
}
.pagecell .pnum {
  text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-soft);
  margin-top: 6px;
}
.pagecell .pbadge {
  position: absolute; top: 6px; right: 6px;
  font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 999px;
  background: var(--brand); color: #fff;
}
.pagecell .pbadge.gone { background: var(--red); }

/* ---------------------------------------------------------------- 进度 */

.progress {
  height: 8px; border-radius: 999px; background: #eef1f9;
  overflow: hidden; margin-top: 16px;
}
.progress .bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #7b61ff);
  transition: width .2s ease;
}

/* ---------------------------------------------------------------- 结果区 */

.result h2 { margin-bottom: 12px; }

.res-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fcfdff;
}
.stat .k { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.stat .v { font-size: 19px; font-weight: 800; margin-top: 3px; letter-spacing: .2px; }
.stat .v.good { color: var(--green); }
.stat .v.bad { color: var(--red); }

.preview-row { display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 10px; }
.preview-row img {
  height: 230px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- 扫描件四角编辑器 */

.scan-stage {
  display: flex; align-items: center; justify-content: center;
  min-height: 220px; padding: 12px;
  background:
    repeating-conic-gradient(#f0f2f8 0% 25%, #e7eaf3 0% 50%) 50% / 18px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto;
}

.scan-stage canvas {
  display: block; max-width: 100%;
  border-radius: 6px; box-shadow: var(--shadow);
  cursor: crosshair; touch-action: none;
}

.scan-empty { color: #8b93a7; font-size: 13px; }

/* ---------------------------------------------------------------- Toast */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1c2333; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; z-index: 50;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5);
  max-width: min(680px, 92vw); text-align: center;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ---------------------------------------------------------------- 页脚 */

.foot {
  text-align: center; color: #8b93a7; font-size: 12px;
  padding: 6px 28px 30px;
}

/* ---------------------------------------------------------------- 窄屏 */

@media (max-width: 720px) {
  .topbar, .tabs, main { padding-left: 14px; padding-right: 14px; }
  .card { padding: 15px; }
  .brand-mark { width: 40px; height: 40px; }
}
