:root {
  --ink: #16241f;
  --ink-2: #45534d;
  --muted: #78847e;
  --line: #dfe6e2;
  --line-soft: #edf1ef;
  --surface: #ffffff;
  --bg: #f4f7f5;
  --teal: #1f6f5c;
  --teal-dark: #175647;
  --teal-soft: #e9f3ef;
  --amber: #a8661a;
  --amber-soft: #fdf3e3;
  --danger: #a73a32;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; }
button { cursor: pointer; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--teal-dark);
  color: #fff;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 4px solid var(--teal);
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-mark {
  width: 46px; height: 46px; flex: none;
  border: 1px solid rgba(255,255,255,.45);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 600;
  letter-spacing: 0;
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: .02em; }
.doc-no { margin: 3px 0 0; font-size: 12px; color: rgba(255,255,255,.72); }
.sep { display: inline-block; margin: 0 8px; opacity: .5; }
.topbar-actions { display: flex; align-items: center; gap: 16px; flex: none; }
.progress-pill {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  padding: 8px 14px; font-size: 13px;
}
.progress-pill strong { font-size: 17px; font-weight: 600; }
.progress-ring {
  width: 10px; height: 10px; border-radius: 50%;
  background: #6fd0b0; box-shadow: 0 0 0 4px rgba(111,208,176,.18);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--teal);
  background: var(--teal); color: #fff;
  padding: 9px 16px; font-size: 13px;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--teal-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid #7fd0b8; outline-offset: 2px; }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.4); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: #e5c5c1; }
.btn-danger-ghost:hover { background: #fdf0ee; }
.btn-block { width: 100%; }
.link-btn {
  border: 0; background: none; color: var(--teal);
  font-size: 12px; padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--teal-dark); }

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px;
  align-items: start;
}
.panel { background: var(--surface); border: 1px solid var(--line); }
.panel-left { position: sticky; top: 20px; }

/* ---------- Search & filter ---------- */
.search-block { padding: 18px; border-bottom: 1px solid var(--line); }
.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8;
}
.search-box input {
  width: 100%; padding: 10px 12px 10px 38px;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 13px; outline: none;
}
.search-box input:focus { border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px var(--teal-soft); }
.filter-chips { display: flex; gap: 8px; margin-top: 12px; }
.chip {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 6px 4px; font-size: 12px;
}
.chip span { font-family: var(--mono); font-size: 11px; opacity: .7; }
.chip:hover { border-color: var(--teal); color: var(--teal); }
.chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip.active span { opacity: .85; }

.list-head {
  display: flex; justify-content: space-between;
  padding: 9px 18px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 11px; color: var(--muted); letter-spacing: .08em;
}
.employee-list { max-height: calc(100vh - 300px); min-height: 200px; overflow-y: auto; }
.employee-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 18px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background .12s;
}
.employee-item:hover { background: #f7faf8; }
.employee-item.active { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.emp-identity { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.emp-seq { font-family: var(--mono); font-size: 11px; color: var(--muted); flex: none; }
.emp-name { font-weight: 600; font-size: 14px; }
.emp-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-status { font-size: 11px; flex: none; padding: 2px 7px; border: 1px solid; }
.mini-status.signed { color: var(--teal); border-color: #a9d3c4; background: var(--teal-soft); }
.mini-status.pending { color: var(--amber); border-color: #e8cf9f; background: var(--amber-soft); }
.list-empty { padding: 40px 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 实名查询面板 ---------- */
.query-block { padding: 22px 20px; border-bottom: 1px solid var(--line); }
.query-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.query-tip { font-size: 12px; color: var(--muted); margin: 0 0 16px; }
.query-block .field { margin-bottom: 12px; }
.query-ok {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #b9d8cc; background: var(--teal-soft);
  padding: 10px 12px; margin-top: 6px;
}
.query-ok strong { font-size: 14px; color: var(--teal-dark); }
.query-ok p { margin: 0; font-size: 11px; color: var(--ink-2); }
.query-ok div { flex: 1; }
.query-ok[hidden] { display: none; }
.side-note { padding: 16px 20px 22px; }
.side-note-t {
  font-size: 11px; letter-spacing: .1em; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 0 0 8px;
}
.side-note p { font-size: 12px; color: var(--ink-2); line-height: 1.9; margin: 0; }
.admin-link { color: var(--teal); }

/* ---------- Empty state ---------- */
.empty-state { padding: 90px 40px; text-align: center; color: var(--ink-2); }
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto 20px;
  border: 1px solid var(--line); display: grid; place-items: center;
  font-family: var(--mono); font-size: 24px; color: var(--teal); background: var(--teal-soft);
}
.empty-state h2 { font-size: 18px; margin: 0 0 8px; font-weight: 600; }
.empty-state p { margin: 0 auto; max-width: 440px; color: var(--muted); font-size: 13px; }
.empty-steps { display: flex; justify-content: center; gap: 28px; margin-top: 36px; font-size: 12px; color: var(--muted); }
.empty-steps b {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 6px;
  border: 1px solid var(--line); font-family: var(--mono); color: var(--teal); font-weight: 500;
}

/* ---------- Detail ---------- */
.detail-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px; border-bottom: 1px solid var(--line);
}
.seq-tag {
  font-family: var(--mono); font-size: 12px; color: var(--teal);
  border: 1px solid #b9d8cc; padding: 5px 9px; background: var(--teal-soft); flex: none;
}
.detail-title { flex: 1; min-width: 0; }
.detail-title h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: .04em; }
.detail-title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.status-badge { font-size: 12px; padding: 5px 12px; border: 1px solid #e8cf9f; background: var(--amber-soft); color: var(--amber); flex: none; }
.status-badge.signed { border-color: #a9d3c4; background: var(--teal-soft); color: var(--teal); }

.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.info-item { padding: 13px 20px; border-right: 1px solid var(--line-soft); min-width: 0; }
.info-item:nth-child(4n) { border-right: 0; }
.info-item-wide { grid-column: 1 / -1; border-right: 0; border-top: 1px solid var(--line-soft); }
.info-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.info-value { display: block; font-size: 13px; word-break: break-all; }
.mono { font-family: var(--mono); font-size: 12px; }
.conclusion { white-space: pre-line; color: var(--ink-2); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); padding: 0 24px; }
.tab {
  border: 0; border-bottom: 2px solid transparent; background: none;
  padding: 12px 20px 10px; color: var(--muted); font-size: 13px;
}
.tab:first-child { padding-left: 0; }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }
.tab:hover { color: var(--teal-dark); }
.doc-body {
  padding: 18px 24px 22px; max-height: 340px; overflow-y: auto;
  background: #fcfdfc; border-bottom: 1px solid var(--line);
}
.doc-section { margin-bottom: 16px; }
.doc-section:last-child { margin-bottom: 0; }
.doc-section h4 {
  margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--teal-dark);
  padding-left: 9px; border-left: 2px solid var(--teal);
}
.doc-section p { margin: 0; font-size: 12.5px; color: var(--ink-2); white-space: pre-line; line-height: 1.75; }

/* ---------- Signature ---------- */
.sign-section { padding: 22px 24px 26px; background: #fff; }
.sign-heading { display: flex; align-items: center; gap: 10px; }
.sign-index {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 2px;
}
.sign-heading h3 { margin: 0; font-size: 15px; font-weight: 600; }
.sign-notice { margin: 8px 0 18px; font-size: 12.5px; color: var(--ink-2); }
.sign-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(220px, .7fr); gap: 20px; }
.canvas-block { min-width: 0; }
.canvas-label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
#signCanvas {
  display: block; width: 100%; height: 170px;
  border: 1px dashed #b8ccc3; background: #fbfdfc; touch-action: none; cursor: crosshair;
}
.canvas-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; }
.sign-fields { display: flex; flex-direction: column; gap: 12px; }
.field span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; outline: none;
}
.field input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.field-error { margin: -4px 0 0; color: var(--danger); font-size: 11.5px; }

.signed-proof { border: 1px solid #b9d8cc; background: var(--teal-soft); padding: 16px 18px; }
.proof-top { display: flex; align-items: center; gap: 12px; }
.proof-check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: var(--teal); color: #fff; display: grid; place-items: center; font-size: 14px;
}
.proof-top div { flex: 1; }
.proof-top strong { font-size: 13px; color: var(--teal-dark); }
.proof-top p { margin: 0; font-size: 11.5px; color: var(--ink-2); font-family: var(--mono); }
#proofImage {
  display: block; margin-top: 12px; max-width: 320px; max-height: 120px;
  border: 1px solid var(--line); background: #fff;
}

/* ---------- Action bar ---------- */
.action-bar {
  border-top: 1px solid var(--line); background: #fff;
  padding: 16px 32px; display: flex; flex-direction: column; gap: 8px;
}
.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.action-note { margin: 0; font-size: 11.5px; color: var(--muted); }

/* ---------- Server status ---------- */
.srv-status {
  font-size: 12px; padding: 5px 12px; border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.85); flex: none;
}
.srv-status.ok { color: #9fe8cf; border-color: #4f9c84; }
.srv-status.off { color: #ffd2a1; border-color: #b98b52; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 20px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .info-item:nth-child(2n) { border-right: 0; }
  .sign-row { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .topbar { padding: 14px 18px; flex-wrap: wrap; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .layout { grid-template-columns: 1fr; padding: 14px; gap: 14px; }
  .panel-left { position: static; }
  .employee-list { max-height: 260px; }
  .detail-header, .sign-section, .doc-body { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 16px; }
  .action-bar { padding: 14px 16px; }
  .empty-state { padding: 60px 20px; }
}
@media (max-width: 520px) {
  .brand h1 { font-size: 16px; }
  .doc-no { font-size: 11px; }
  .info-grid { grid-template-columns: 1fr; }
  .info-item { border-right: 0 !important; border-bottom: 1px solid var(--line-soft); }
  .empty-steps { gap: 12px; flex-wrap: wrap; }
  .action-buttons .btn { flex: 1 1 45%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* ---------- 签收表：工具条 / 双击放大 / 下载 ---------- */
.btn-sm { padding: 5px 12px; font-size: 12px; }
.proof-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 12px;
}
.proof-hint { font-size: 11.5px; color: var(--muted); }
#proofImage { cursor: zoom-in; }
.proof-lightbox {
  position: fixed; inset: 0; z-index: 9999; display: flex;
  align-items: center; justify-content: center; padding: 24px;
}
.proof-lightbox[hidden] { display: none; }
.proof-lightbox-mask {
  position: absolute; inset: 0; background: rgba(10,20,16,.72);
}
.proof-lightbox-body {
  position: relative; display: flex; flex-direction: column;
  max-width: 92vw; max-height: 92vh; background: #fff; border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.4); overflow: hidden;
}
.proof-lightbox-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--teal-dark); font-weight: 600; background: var(--teal-soft);
}
.proof-lightbox-bar > div { display: flex; gap: 8px; }
#lightboxImage {
  display: block; margin: 0 auto; padding: 14px;
  max-width: 88vw; max-height: calc(92vh - 52px); object-fit: contain; background: #fff;
}
