/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --sgs-orange: #f58220;
  --sgs-dark: #3a3a3a;
  --sgs-gray: #f2f2f2;
  --sgs-border: #e0e0e0;
  --sgs-text: #333;
  --accent-blue: rgba(0, 100, 255, 0.25);
}
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--sgs-text);
  background: #e9e9e9;
}
body { display: flex; flex-direction: column; }

/* ===== 顶部品牌栏（橙色底） ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--sgs-orange);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo {
  background: #fff;
  color: var(--sgs-orange);
  font-weight: 800;
  font-size: 16px;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 1px;
}
.brand-title { font-size: 16px; font-weight: 600; color: #fff; }
.brand-slogan {
  flex: 1;
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-lang {
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.8);
  border-radius: 12px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--sgs-border);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 100;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border-right: 1px solid var(--sgs-border);
}
.tool-group:last-child { border-right: none; }
.btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sgs-text);
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn:hover { background: #f0f0f0; }
.btn:active { background: #e0e0e0; }
.zoom-level { font-size: 12px; font-variant-numeric: tabular-nums; }
.page-indicator { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.page-indicator input {
  width: 40px;
  height: 26px;
  border: 1px solid var(--sgs-border);
  border-radius: 4px;
  text-align: center;
  font-size: 13px;
}
.page-indicator .sep { color: #999; }
.search-group { flex: 1; min-width: 160px; }
#searchBox {
  flex: 1;
  min-width: 90px;
  height: 30px;
  border: 1px solid var(--sgs-border);
  border-radius: 4px;
  padding: 0 8px;
  font-size: 13px;
}
.search-info { font-size: 12px; color: #999; white-space: nowrap; }

/* ===== 主区域 ===== */
.main {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.sidebar {
  width: 140px;
  flex: 0 0 auto;
  background: #fff;
  border-right: 1px solid var(--sgs-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-title {
  padding: 8px 10px;
  font-size: 12px;
  color: #999;
  border-bottom: 1px solid var(--sgs-border);
}
.thumbnails { flex: 1; overflow-y: auto; padding: 8px; }
.thumb-item {
  margin-bottom: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  background: #fff;
}
.thumb-item.active { border-color: var(--sgs-orange); }
.thumb-item canvas { display: block; width: 100%; height: auto; }
.thumb-label {
  text-align: center;
  font-size: 11px;
  color: #666;
  padding: 2px 0;
}

.viewer-wrap {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 16px 8px;
}
.viewer { display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* ===== PDF 页面 ===== */
.page {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  margin: 0 auto;
}
.page-canvas { display: block; }

/* text layer：覆盖在 canvas 上，文字透明但可选中 */
.textLayer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  line-height: 1;
  text-align: initial;
  opacity: 0.25;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
  cursor: text;
}
.textLayer :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: var(--accent-blue); }
.textLayer .search-hit {
  color: transparent;
  background: rgba(255, 200, 0, 0.55);
  border-radius: 2px;
}
.textLayer .search-hit.current {
  background: rgba(255, 120, 0, 0.75);
  outline: 1px solid #e65100;
}

/* ===== 加载动画 ===== */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #999;
}
.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  border: 3px solid var(--sgs-border);
  border-top-color: var(--sgs-orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 底部 ===== */
.footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border-top: 1px solid var(--sgs-border);
  font-size: 12px;
  color: #999;
}
.footer .dot { color: #ccc; }

/* ===== 响应式（移动端） ===== */
@media (max-width: 768px) {
  .brand-slogan { display: none; }
  .topbar-viewer .brand-slogan { display: block; font-size: 15px; white-space: normal; }
  .sidebar { display: none; }
  .toolbar { gap: 2px; padding: 6px 4px; }
  .tool-group { padding: 0 4px; }
  .btn { min-width: 26px; padding: 0 5px; font-size: 13px; }
  #fitWidth { display: none; }
  .search-group { flex-basis: 100%; order: 10; border-right: none; }
  .viewer-wrap { padding: 8px 2px; }
  .page { box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
}

/* ===== 报告列表 ===== */
#listView { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#viewerView { display: none; flex-direction: column; flex: 1; min-height: 0; }
.list-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.list-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--sgs-dark);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--sgs-orange);
}
.report-list { display: flex; flex-direction: column; gap: 12px; }
.report-card {
  background: #fff;
  border: 1px solid var(--sgs-border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.report-card:hover { border-color: var(--sgs-orange); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.report-card:active { background: #fafafa; }
.report-card-title { font-size: 15px; font-weight: 600; color: var(--sgs-text); margin-bottom: 6px; }
.report-card-meta { font-size: 12px; color: #999; }
.list-empty { color: #999; text-align: center; padding: 40px 0; }

/* 返回按钮 */
.brand-back {
  font-size: 13px;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.8);
  border-radius: 12px;
  padding: 4px 10px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.brand-back:hover { background: rgba(255,255,255,0.15); }

/* ===== 底部悬浮按钮 ===== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex; height: 14vh; min-height: 72px;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.15);
}
.bottom-nav .nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; background: #fff; text-decoration: none; color: var(--sgs-orange);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav .nav-btn:active {
  background: var(--sgs-orange); color: #fff;
}
.bottom-nav .nav-icon { width: 28px; height: 28px; }
.bottom-nav .nav-label { font-size: 13px; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center; z-index: 300;
}
.modal-mask.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 10px; padding: 26px 30px;
  text-align: center; min-width: 260px;
}
.phone-link {
  display: block; font-size: 24px; font-weight: bold; color: var(--sgs-orange);
  text-decoration: none; letter-spacing: 1px; margin-bottom: 18px;
}
.modal-btns { display: flex; gap: 12px; }
.modal-cancel, .modal-call {
  flex: 1; border: none; border-radius: 20px; padding: 10px 0;
  font-size: 15px; cursor: pointer; text-decoration: none; text-align: center;
}
.modal-cancel { background: #eee; color: #333; }
.modal-call { background: var(--sgs-orange); color: #fff; }

/* 给内容留出底部按钮空间 */
.viewer-wrap { padding-bottom: 16vh; }
.list-container { padding-bottom: 16vh; }

/* ===== 打印 ===== */
@media print {
  .topbar, .toolbar, .sidebar, .footer, .loading, .bottom-nav, .modal-mask { display: none !important; }
  body, html { background: #fff; }
  .main { overflow: visible; }
  .viewer-wrap { overflow: visible; padding: 0; }
  .list-container { padding: 0; }
  .page { box-shadow: none; margin: 0 0 8px; page-break-after: always; }
  .textLayer { opacity: 0; }
}
