:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #dfe5ee;
  --ink: #17202e;
  --ink-2: #55637a;
  --brand: #0f4c81;
  --brand-2: #1a6bb0;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --grey: #64748b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: 14px 20px 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .5px; }
.sub { margin: 2px 0 0; font-size: 12px; opacity: .8; }
.tabs { display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; }
.tabs button {
  background: transparent; border: 0; color: #cddff0;
  padding: 10px 16px; font-size: 14px; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap;
  font-family: inherit;
}
.tabs button:hover { color: #fff; }
.tabs button.active { color: #fff; font-weight: 600; border-bottom-color: #7fc4ff; }

/* ---------- 提示条 ---------- */
.banner { padding: 9px 20px; font-size: 13px; }
.banner-warn { background: #fff7e6; color: #8a5a00; border-bottom: 1px solid #ffe1a8; }
.banner-warn strong { color: #a96a00; }

/* ---------- 主区 ---------- */
main { padding: 18px 20px 60px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row-between h2 { margin: 0; }
.empty { background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--ink-2); }

/* ---------- 按钮 ---------- */
.btn {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 7px 14px; border-radius: 7px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: .15s;
}
.btn:hover { border-color: var(--brand-2); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #f3c7c7; }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); color: var(--danger); }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: .18s;
}
.card:hover { border-color: var(--brand-2); box-shadow: 0 4px 16px rgba(15,76,129,.10); transform: translateY(-1px); }
.card.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(15,76,129,.15); }
.card h4 { margin: 0 0 4px; font-size: 15px; }
.card .meta { color: var(--ink-2); font-size: 12.5px; margin-bottom: 10px; }
.card .kpis { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.kpi { }
.kpi .v { font-size: 18px; font-weight: 600; color: var(--brand); }
.kpi .k { font-size: 11.5px; color: var(--ink-2); }

/* ---------- 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel ul { margin: 6px 0; padding-left: 20px; }
.panel li { margin: 4px 0; }
.mono { font-family: Consolas, "Courier New", monospace; background: #f1f5f9; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: middle; }
th { background: #eef3f9; font-weight: 600; color: #2b3d55; white-space: nowrap; }
tbody tr:nth-child(even) { background: #fafbfd; }
td input {
  width: 100%; border: 1px solid transparent; background: transparent;
  padding: 3px 5px; font-size: 13px; font-family: inherit; border-radius: 4px; color: var(--ink);
}
td input:hover { border-color: var(--line); background: #fff; }
td input:focus { outline: none; border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 2px rgba(26,107,176,.12); }
td.num input { text-align: right; }

/* ---------- 状态徽标 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.danger { background: #fee2e2; color: #b91c1c; }
.badge.grey { background: #e2e8f0; color: #475569; }
.card .kpis + div { line-height: 2; }
.card .kpis + div .badge { margin-right: 3px; cursor: help; }

/* ---------- 六环节 ---------- */
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.stage { border: 1px solid var(--line); border-radius: 8px; padding: 11px; background: #fbfcfe; }
.stage .hd { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 7px; }
.stage .nm { font-weight: 600; font-size: 13.5px; }
.stage label { display: block; font-size: 11.5px; color: var(--ink-2); margin-top: 6px; }
.stage input, .stage select, .stage textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px;
  font-size: 12.5px; font-family: inherit; background: #fff; color: var(--ink); resize: vertical;
}
.stage .partner-tag { font-size: 11px; color: var(--warn); }

/* ---------- 唛头 ---------- */
.marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.mark {
  border: 2px solid #111; background: #fff; padding: 14px;
  font-family: "Arial Black", Arial, sans-serif; color: #000;
}
.mark .mk-line { font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.mark .mk-big { font-size: 22px; font-weight: 900; margin: 6px 0; letter-spacing: 1px; }
.mark .mk-dim { font-size: 14px; font-weight: 700; }
.mark hr { border: 0; border-top: 2px solid #111; margin: 9px 0; }
.mark .mk-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.mark .mk-foot-left { flex: 1; min-width: 0; }

/* 出口商抬头（唛头顶部） */
.mark .mk-exp { padding-bottom: 2px; }
.mark .mk-exp-cn { font-size: 14px; font-weight: 900; line-height: 1.35; word-break: break-all; }
.mark .mk-exp-en { font-size: 11px; font-weight: 700; color: #333; margin-top: 1px; font-family: Arial, sans-serif; }

/* 唛头上的二维码 */
.mark .mk-qr { text-align: center; flex-shrink: 0; }
.mark .mk-qr-code { width: 74px; height: 74px; }
.mark .mk-qr-code svg { width: 100%; height: 100%; display: block; }
.mark .mk-qr-cap { font-size: 9px; font-weight: 700; margin-top: 2px; font-family: Arial, sans-serif; letter-spacing: 0; }
.mark .mk-qr-none {
  width: 74px; height: 74px; border: 1px dashed #999; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9.5px; color: #777; text-align: center; line-height: 1.25; font-family: Arial, sans-serif;
}
.muted-xsm { font-size: 8px; color: #aaa; }

.ippc {
  border: 2px solid #111; padding: 5px 7px; text-align: center;
  font-family: Arial, sans-serif; line-height: 1.15;
}
.ippc .sym { font-size: 15px; font-weight: 700; }
.ippc .cd { font-size: 12px; font-weight: 700; }

/* ---------- 照片 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.photo-item img { width: 100%; height: 130px; object-fit: cover; display: block; background: #eef2f7; }
.photo-item .cap { padding: 6px 8px; font-size: 11.5px; color: var(--ink-2); }
.photo-item .cap b { color: var(--ink); display: block; font-size: 12px; }

/* ---------- 上传区 ---------- */
.upload-box { border: 2px dashed #b9cbe0; border-radius: var(--radius); padding: 22px; text-align: center; background: #f8fbff; }
.upload-box.drag { border-color: var(--brand); background: #eef6ff; }
.upload-box input[type=file] { display: none; }
.upload-icon { font-size: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--ink-2); gap: 4px; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.inline { flex-direction: row; align-items: center; gap: 7px; }
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(26,107,176,.13);
}

/* ---------- 弹窗 ---------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,25,40,.5); z-index: 100; padding: 24px; overflow: auto; }
.modal.show { display: flex; align-items: flex-start; justify-content: center; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 780px; }
.modal-box h3 { font-size: 16px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #17202e; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 打印 ---------- */
.print-only { display: none; }

/* 页面方向由 JS 注入的 <style id="printPageRule"> 决定（见 app.js setPrintOrientation）。
   为什么不用 body 上的类：CSS 的 @page 规则**无法**被 body class 选中，
   只能整页生效，所以必须动态替换这条规则。
   这里的默认值是纵向（唛头用），箱单打印前会被替换成 landscape。 */
@page { size: A4 portrait; margin: 10mm 8mm; }

@media print {
  .topbar, .banner, .tabs, .no-print, .toast, .btn { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; margin: 0 0 14px; break-inside: avoid; }
  .print-only { display: block; }
  table { font-size: 11px; }
  th { background: #eef3f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* 去掉横向滚动容器，让表格自己收缩到纸宽，否则右侧列会被裁掉 */
  .tbl-wrap { overflow: visible !important; }
  .tbl-wrap > table { width: 100% !important; min-width: 0 !important; }

  /* 跨页时表头自动重复（长箱单必用，否则第 2 页起对不上列） */
  thead { display: table-header-group; }

  /* 合计行不要被单独留在页首 */
  .total-row { break-before: avoid; page-break-before: avoid; }

  /* 唛头：每张独立成块，绝不劈成两页 */
  .marks { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mark {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 逐页打印单张唛头时（批量打印走的是新增窗口，这里管本页即时打印） */
  tr { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------- 手机 ---------- */
@media (max-width: 720px) {
  .topbar { padding: 12px 12px 0; }
  .topbar h1 { font-size: 15.5px; }
  .sub { display: none; }
  .logo { font-size: 22px; }
  main { padding: 12px 12px 70px; }
  .tabs button { padding: 9px 12px; font-size: 13px; }
  .cards, .marks { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .photo-item img { height: 100px; }
  table { font-size: 12px; }
  th, td { padding: 5px 6px; }
  .modal { padding: 10px; }
  .btn { padding: 9px 14px; }  /* 手机加大点击区域 */
}

/* ==================== 登录页 ==================== */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f4c81 0%, #1a6bb0 55%, #2b8ac9 100%);
  padding: 20px; z-index: 500; overflow: auto;
}
.login-box {
  background: #fff; border-radius: 16px; padding: 30px 28px;
  width: 100%; max-width: 400px; box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.login-head { text-align: center; margin-bottom: 22px; }
.login-head .logo { font-size: 42px; display: block; margin-bottom: 6px; }
.login-head h1 { margin: 0; font-size: 19px; color: var(--brand); letter-spacing: .5px; }
.login-head p { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-2); }
.login-form label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.login-form input {
  width: 100%; margin-top: 5px; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 9px; font-family: inherit;
  background: #fff; color: var(--ink);
}
.login-form input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(26,107,176,.15); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; }
.login-error {
  display: none; background: #fee2e2; color: #b91c1c; padding: 9px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}
.login-help { margin-top: 20px; font-size: 12.5px; color: var(--ink-2); }
.login-help summary { cursor: pointer; color: var(--brand); }
.login-tbl { width: 100%; margin-top: 8px; font-size: 12px; border-collapse: collapse; }
.login-tbl td { border: 1px solid var(--line); padding: 4px 7px; }
.login-tbl td:first-child { font-family: Consolas, monospace; font-weight: 600; }

/* ==================== 用户信息区 ==================== */
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 13px; }
.user-chip #whoami { color: #dbeafe; white-space: nowrap; }
.user-chip .btn { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); color: #fff; }
.user-chip .btn:hover { background: rgba(255,255,255,.28); color: #fff; }

.banner-danger { background: #fee2e2; color: #b91c1c; border-bottom: 1px solid #fecaca; }

/* ==================== 通用小样式 ==================== */
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--ink-2); }
.muted-sm { font-size: 12.5px; color: var(--ink-2); }
.err-text { color: var(--danger); }
.warn-text { color: #b45309; font-size: 12.5px; line-height: 1.7; }
.hint { font-weight: 400; font-size: 12.5px; color: var(--ink-2); }
.hint-block { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.card-actions { margin-top: 10px; display: flex; gap: 8px; }
.stage-badges { margin-bottom: 8px; line-height: 2; }
.stage-badges .badge { margin-right: 3px; cursor: help; }
.stage-act { margin-top: 8px; }
.btn-ok { background: #dcfce7; border-color: #86efac; color: #15803d; font-weight: 600; }
.btn-ok:hover { background: #bbf7d0; border-color: var(--ok); color: #15803d; }
.confirm-by { font-size: 11.5px; color: var(--ok); margin: 4px 0 2px; }
.inline-row { display: flex; flex-direction: row; align-items: center; gap: 6px; margin-top: 8px; }
.inline-row input[type=checkbox] { width: auto; }
.doc-title { text-align: center; margin-bottom: 14px; }
.dt-cn { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.dt-en { font-size: 13px; color: var(--ink-2); letter-spacing: 1px; }
.total-row { font-weight: 700; background: #eef3f9 !important; }
.disclaimer { font-size: 12.5px; color: var(--ink-2); }
.disclaimer ol { margin: 6px 0; padding-left: 20px; }
.mark .nn { font-size: 11px; color: #666; }
.row-invalid { background: #fef2f2 !important; }
.mini-tbl { font-size: 12.5px; }
.mini-tbl th, .mini-tbl td { padding: 5px 8px; }

/* ==================== 照片对外可见性 ==================== */
.hint-sm { font-size: 12px; color: var(--ink-2); line-height: 1.7; margin: 8px 0 0; }
.hint-sm strong { color: var(--ink); }
.sel-hidden { color: #b45309; border-color: #fcd34d !important; background: #fffbeb; }
.sel-photos { font-size: 12px; padding: 3px 4px; max-width: 96px; }
.eff-note { font-size: 11.5px; margin-top: 3px; white-space: nowrap; }
.eff-note.on { color: var(--ok); }
.eff-note.off { color: #b45309; }
.box-hidden-row { background: #fffdf5; }
.photo-hidden-tip {
  font-size: 12.5px; color: #b45309; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}

/* ==================== 箱型建议 ==================== */
.suggest-list { display: flex; flex-direction: column; gap: 10px; }
.suggest-item {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #fbfcfe;
}
.suggest-item:hover { border-color: var(--brand-2); background: #f6faff; }
.si-main { flex: 1; min-width: 0; }
.si-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.si-title .badge { margin-left: 6px; font-size: 11px; }
.si-dims { font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.si-dims strong { color: var(--brand); font-size: 14.5px; }
.si-meta { font-size: 12px; color: var(--ink-2); }
.si-act { flex-shrink: 0; }

/* ==================== 打印补充 ==================== */
@media print {
  .login-screen, #appMain > .banner { display: none !important; }
  .user-chip { display: none !important; }

  /* 打印时隐藏「非报关必要」列，给报关列腾出空间（照片数、照片对外、操作）
     —— 老板 2026-10-07 确认：箱单走 A4 横向，这两列是内部管理用，不上纸 */
  .col-screen-only { display: none !important; }

  /* 打印页脚：只在纸上出现，标明生成时间，便于对版次 */
  .print-foot { display: block; margin-top: 8px; font-size: 10px; color: #666; }

  /* 打印时把输入框渲染成纯文本观感（避免出现难看的输入框边框） */
  input:not([type=checkbox]), select { border: 0 !important; background: transparent !important; padding: 0 !important; }
}

.print-foot { display: none; }

/* ==================== 手机适配补充 ==================== */
@media (max-width: 720px) {
  .user-chip { width: 100%; margin-left: 0; margin-top: 8px; justify-content: flex-end; }
  .brand { flex-wrap: wrap; }
  .login-box { padding: 24px 20px; }
  .suggest-item { flex-direction: column; align-items: stretch; }
  .si-act .btn { width: 100%; }
  .kpis { gap: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ICP 备案号页脚（工信部要求挂接） */
.site-footer { text-align:center; padding:14px 0 18px; font-size:11px; }
.site-footer a { color:#999; text-decoration:none; }
.site-footer a:hover { color:#666; }
