:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --blue-soft: #eef4ff;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --gray: #64748b;
  --line: #e5e7eb;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #111827;
  --text-sub: #6b7280;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.view { min-height: 100vh; }
#loginView { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow);
}
.logo { font-size: 48px; text-align: center; }
.login-card h1 { text-align: center; margin: 8px 0 2px; font-size: 22px; }
.sub { text-align: center; color: var(--text-sub); margin: 0 0 24px; font-size: 13.5px; }
.fld { display: block; margin-bottom: 16px; }
.fld span { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.fld input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; outline: none; transition: border .15s;
}
.fld input:focus { border-color: var(--blue); }
.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.divider { text-align: center; color: var(--text-sub); font-size: 12px; margin: 18px 0; position: relative; }
.divider::before, .divider::after {
  content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--line);
}
.divider::before { left: 0; } .divider::after { right: 0; }
.foot-hint { color: var(--text-sub); font-size: 12px; text-align: center; margin-top: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 14.5px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.ghost { background: transparent; border-color: var(--blue); color: var(--blue); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 顶栏 ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 17px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.who { color: var(--text-sub); font-size: 13px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; max-width: 1100px; margin: 12px auto 0; padding: 0 16px; }
.tab {
  flex: 1; max-width: 200px; padding: 11px; border: none; background: transparent;
  font-size: 15px; font-weight: 600; color: var(--text-sub); cursor: pointer;
  border-bottom: 3px solid transparent; transition: all .15s;
}
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 60px; }
.panel { animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 统计卡片 ---------- */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat {
  flex: 1; min-width: 88px; background: var(--card); border: 1px solid transparent;
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  font: inherit; color: var(--text); text-align: center; cursor: pointer;
}
.stat .n { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat .l { display: block; font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.stat:hover, .stat.hl { border-color: var(--blue); }
.stat.hl { background: var(--blue-soft); }
.stat.hl .n { color: var(--blue); }
.stat:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 180px; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; outline: none; background: var(--card);
}
.search:focus { border-color: var(--blue); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: 13px; color: var(--text-sub); cursor: pointer;
}
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); position: relative;
}
.row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.row-title { min-width: 0; font-size: 16px; font-weight: 700; word-break: break-all; }
.row-title .tag { font-weight: 400; }
.tracking-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.tracking-number {
  max-width: 100%; min-height: 32px; padding: 4px 0; border: 0; background: transparent;
  font: inherit; text-align: left; color: var(--blue); cursor: pointer;
  overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px;
}
.tracking-number:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.registrant { color: var(--text-sub); font-size: 13px; font-weight: 400; }
.row-meta { color: var(--text-sub); font-size: 13px; margin-top: 4px; word-break: break-all; }
.row-note { white-space: pre-wrap; }
.claim-amount { color: var(--blue); font-size: 17px; }
.claim-file { min-width: 0; }
.row-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--blue-soft); color: var(--blue); white-space: nowrap;
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.gray { background: #f1f5f9; color: var(--gray); }
.empty { text-align: center; color: var(--text-sub); padding: 40px 0; font-size: 14px; }

/* 状态四小方块 */
.flag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; border: 1px solid var(--line); cursor: pointer; background: #fff; color: var(--text-sub); }
.flag.yes { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.flag.no { background: var(--red-soft); color: var(--red); border-color: #fecaca; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow-y: auto;
}
.modal-box {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 520px;
  padding: 20px; max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin: 0 0 16px; font-size: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; }
.modal-foot .btn { flex: 1; }
#exportForm .fld { min-width: 0; margin-bottom: 8px; }
#exportForm .export-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
#exportForm .modal-foot { flex-wrap: wrap; margin-top: 10px; }
#exportForm .modal-foot .btn { flex: 1 0 auto; padding: 9px 10px; }
.audit-fields { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr)); gap: 8px; }
.audit-fields .fld { margin-bottom: 8px; min-width: 0; }
.audit-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.audit-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.audit-panel-heading h3 { margin: 0; }
.audit-results { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
.audit-entry { border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 13px; overflow-wrap: anywhere; }
.audit-entry-heading { display: flex; gap: 4px 8px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; margin-bottom: 4px; }
.audit-entry-heading time, .audit-identity { color: var(--text-sub); }
.audit-identity { display: flex; gap: 2px 12px; flex-wrap: wrap; margin-top: 4px; }
select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; outline: none; background: #fff; font-family: inherit;
}
select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 64px; }

/* ---------- 照片查看器 ---------- */
.photoviewer { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; }
.pv-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: #fff; }
.pv-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pv-nav { display: flex; gap: 12px; justify-content: center; padding: 14px; }
.pv-nav .btn { min-width: 120px; }
.thumb { width: 100%; max-width: 100%; border-radius: 8px; display: block; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14px; z-index: 70; box-shadow: var(--shadow); max-width: 90vw;
}

/* ---------- 响应式：手机 ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .tab { min-width: 0; padding-inline: 5px; font-size: 14px; white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; }
  .brand { font-size: 16px; }
  .who { display: none; }
  .row-title { font-size: 15px; }
  .stat .n { font-size: 20px; }
  .audit-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-tracking { grid-column: 1 / -1; }
  .audit-controls .btn, .audit-panel-heading .btn, #btnAuditLogs { min-height: 44px; }
}
