/* 机加工零件报价系统 · tangwenhui.com/works/baojiabiaoge/app */
:root {
  --navy: #1F4E79;
  --navy2: #2E75B6;
  --navy3: #EAF1F8;
  --line: #d7dee6;
  --line2: #bfbfbf;
  --calc: #f2f4f7;
  --input: #ffffff;
  --warn: #ffe0b2;
  --bad: #ffc7ce;
  --ok: #2e9e5b;
  --txt: #23282d;
  --muted: #7a8698;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 13px/1.5 "Microsoft YaHei", "微软雅黑", -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--txt); background: #f5f7fa;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy2); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--navy); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.brand small { font-weight: 400; opacity: .7; font-size: 12px; margin-left: 6px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tabs button {
  background: rgba(255,255,255,.10); color: #dce7f3; border: 0; padding: 6px 14px;
  border-radius: 6px; cursor: pointer;
}
.tabs button:hover { background: rgba(255,255,255,.2); color: #fff; }
.tabs button.active { background: #fff; color: var(--navy); font-weight: 700; }
.actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.28);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.24); }
.btn.primary { background: #f0a500; border-color: #f0a500; color: #3a2a00; font-weight: 700; }
.btn.primary:hover { background: #ffb81c; }
.btn.ghost { background: transparent; }
.btn.file { display: inline-flex; align-items: center; }
main { padding: 14px 16px 40px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
}
.card > h3 {
  margin: 0 0 10px; font-size: 14px; color: var(--navy);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card > h3 .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 报价信息 ---------- */
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 14px; }
.meta label { display: flex; align-items: center; gap: 8px; }
.meta label > span { flex: 0 0 76px; text-align: right; color: var(--navy); font-weight: 700; }
.meta input, .meta select {
  flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line2);
  border-radius: 5px; background: #fffdf3;
}
.meta input:focus, .meta select:focus { outline: 2px solid var(--navy2); outline-offset: -1px; }

/* ---------- 明细表 ---------- */
.table-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; max-height: calc(100vh - 250px);
}
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
table.grid th, table.grid td {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 0; height: 30px; vertical-align: middle; background: #fff;
}
table.grid thead th {
  position: sticky; top: 0; z-index: 5; background: var(--navy); color: #fff;
  font-weight: 700; font-size: 12px; padding: 6px 4px; text-align: center; line-height: 1.25;
  white-space: normal;
}
table.grid td.calc { background: var(--calc); color: #333; }
table.grid td.num, table.grid td.calc.num { text-align: right; padding-right: 6px; }
table.grid td.warn { background: var(--warn) !important; }
table.grid td.badprice { background: var(--bad) !important; }
table.grid td.calc.strong { font-weight: 700; color: #0b3c62; }
table.grid td input, table.grid td select {
  width: 100%; height: 29px; border: 0; background: transparent; padding: 0 6px;
  outline: none; border-radius: 0;
}
table.grid td select { padding: 0 2px; }
table.grid td input:focus, table.grid td select:focus { background: #fffbe6; box-shadow: inset 0 0 0 2px var(--navy2); }
table.grid td.calc input { background: transparent; font-style: normal; }
table.grid td input::placeholder { color: #b9c2cd; }

/* 冻结列 */
.gcol-op, .gcol-idx { position: sticky; z-index: 3; background: #fff; }
.gcol-op { left: 0; width: 46px; }
.gcol-idx { left: 46px; width: 46px; }
thead th.gcol-op, thead th.gcol-idx { z-index: 6; background: var(--navy); }
td.gcol-op, td.gcol-idx { background: #fbfcfe; text-align: center; }
.op-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  padding: 2px 3px; border-radius: 4px; font-size: 13px; line-height: 1;
}
.op-btn:hover { background: var(--navy3); color: var(--navy); }
.op-btn.del:hover { background: #ffe4e6; color: #c62828; }

/* 工艺多选 */
.proc-cell { display: flex; align-items: center; }
.proc-cell input { flex: 1; }
.proc-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--navy2);
  padding: 0 4px; font-size: 12px;
}
.proc-btn:hover { background: var(--navy3); border-radius: 4px; }
.proc-pop {
  position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line2);
  border-radius: 8px; box-shadow: 0 8px 26px rgba(0,0,0,.18); padding: 8px; width: 268px;
}
.proc-pop .t { font-weight: 700; color: var(--navy); margin-bottom: 6px; font-size: 12px; }
.proc-pop label { display: flex; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.proc-pop label:hover { background: var(--navy3); }
.proc-pop .foot { display: flex; gap: 6px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.link-btn { background: #eef3f9; border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; cursor: pointer; }
.link-btn:hover { background: var(--navy3); }

/* 图纸缩略图 */
.thumb { max-width: 100%; max-height: 26px; display: block; margin: 0 auto; cursor: zoom-in; }
.imgcell { display: flex; align-items: center; justify-content: center; gap: 3px; height: 29px; }

/* ---------- 汇总 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 20px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.kpi .v.small { font-size: 15px; }
.kpi.hl { background: linear-gradient(180deg,#fff8e8,#fff); border-color: #f0d9a8; }
.kpi.hl .v { color: #b26a00; }
table.simple { border-collapse: separate; border-spacing: 0; width: 100%; }
table.simple th, table.simple td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
table.simple thead th { background: var(--navy); color: #fff; font-size: 12px; }
table.simple td.n, table.simple th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.simple tr.total td { font-weight: 700; background: #fdf0e6; color: #b23c00; }
table.simple tr:hover td { background: #f7fafd; }

/* ---------- 参数表 ---------- */
.param-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; }
table.mini { border-collapse: separate; border-spacing: 0; width: 100%; }
table.mini th, table.mini td { border: 1px solid var(--line); padding: 2px 4px; }
table.mini thead th { background: var(--navy); color: #fff; font-size: 12px; padding: 5px 4px; }
table.mini input, table.mini select { width: 100%; border: 0; background: #fffdf3; padding: 4px; border-radius: 3px; }
table.mini input:focus, table.mini select:focus { outline: 2px solid var(--navy2); }
table.mini td.n input { text-align: right; }
table.mini tbody tr:nth-child(even) td { background: #fafcfe; }
.mini-wrap { max-height: 320px; overflow: auto; }

/* ---------- 口令门 ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100; background: rgba(16,32,48,.92);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate .box { background: #fff; border-radius: 12px; padding: 26px 28px; width: 100%; max-width: 380px; text-align: center; }
.gate h2 { margin: 0 0 6px; color: var(--navy); font-size: 19px; }
.gate p { margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.gate input { width: 100%; padding: 10px 12px; border: 1px solid var(--line2); border-radius: 6px; margin-bottom: 10px; }
.gate input:focus { outline: 2px solid var(--navy2); }
.gate .err { color: #c62828; font-size: 12px; height: 16px; margin-bottom: 6px; }
.gate button { width: 100%; background: var(--navy); color: #fff; border: 0; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: 700; }
.gate button:hover { background: var(--navy2); }
.hidden { display: none !important; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #23282d; color: #fff; padding: 9px 16px; border-radius: 20px;
  font-size: 12px; z-index: 90; opacity: 0; transition: opacity .2s, bottom .2s; pointer-events: none;
}
.toast.show { opacity: .95; bottom: 36px; }
.notice { background: #fff8e6; border: 1px solid #f0d9a8; color: #7a5a00; padding: 8px 10px; border-radius: 6px; font-size: 12px; }
.notice.red { background: #fdecef; border-color: #f3c2ca; color: #96202f; }

/* ---------- 打印（给客户的报价单） ---------- */
#printDoc { display: none; }
@media print {
  body { background: #fff; }
  .topbar, main, .toast, .gate { display: none !important; }
  #printDoc { display: block; padding: 0; }
  #printDoc h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
  #printDoc .sub { text-align: center; color: #555; font-size: 12px; margin-bottom: 10px; }
  #printDoc .info { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 12px; margin-bottom: 8px; }
  #printDoc table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  #printDoc th, #printDoc td { border: 1px solid #999; padding: 3px 4px; }
  #printDoc th { background: #e8eef5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printDoc td.n, #printDoc th.n { text-align: right; }
  #printDoc .sig { margin-top: 26px; display: flex; justify-content: space-between; font-size: 12px; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 780px) {
  .brand small { display: none; }
  .actions { width: 100%; margin-left: 0; }
  .meta { grid-template-columns: 1fr; }
  .meta label > span { flex-basis: 66px; }
  main { padding: 10px; }
  .table-wrap { max-height: none; }
}
