/* ===========================================================
   峰辉团服 · 业务资料库  样式表
   纯本地运行，不依赖任何网络资源
   =========================================================== */

:root {
  --brand:        #1e40af;
  --brand-dark:   #1e3a8a;
  --brand-light:  #eff6ff;
  --brand-soft:   #dbeafe;

  --sidebar-bg:   #0f172a;
  --sidebar-hover:#1e293b;
  --sidebar-act:  #1d4ed8;

  --bg:           #f1f5f9;
  --card:         #ffffff;
  --border:       #e2e8f0;
  --border-soft:  #f1f5f9;

  --text:         #0f172a;
  --text-2:       #475569;
  --text-3:       #94a3b8;

  --green:        #16a34a;
  --green-bg:     #f0fdf4;
  --red:          #dc2626;
  --red-bg:       #fef2f2;
  --amber:        #d97706;
  --amber-bg:     #fffbeb;
  --purple:       #7c3aed;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.08);
  --shadow-lg:    0 10px 30px rgba(15,23,42,.15), 0 2px 8px rgba(15,23,42,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; overflow: hidden; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); }

/* ---------- 布局 ---------- */
#sidebar {
  width: 216px; flex: 0 0 216px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  height: 100vh;
}
#main {
  flex: 1; min-width: 0;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand h1 { font-size: 17px; color: #fff; letter-spacing: .5px; font-weight: 700; }
.brand p { font-size: 11px; color: #64748b; margin-top: 4px; letter-spacing: .3px; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #cbd5e1; font-size: 13.5px;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-act); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; flex: 0 0 18px; }
.nav-item .badge {
  margin-left: auto; background: rgba(255,255,255,.16);
  padding: 1px 6px; border-radius: 8px; font-size: 11px;
}
.nav-item.active .badge { background: rgba(255,255,255,.28); }

.sidebar-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: #475569; line-height: 1.7;
}
.sidebar-foot b { color: #94a3b8; font-weight: 600; }

/* ---------- 页头 ---------- */
.page-head {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.page-head h2 { font-size: 18px; font-weight: 700; }
.page-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-body { padding: 20px 24px 60px; flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .12s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 5px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  padding: 13px 18px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand);
}
.stat.g::before { background: var(--green); }
.stat.r::before { background: var(--red); }
.stat.a::before { background: var(--amber); }
.stat.p::before { background: var(--purple); }
.stat .label { font-size: 12px; color: var(--text-3); margin-bottom: 7px; }
.stat .value { font-size: 23px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.stat .foot { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; padding: 10px 12px; font-weight: 600; font-size: 12.5px;
  color: var(--text-2); background: #f8fafc;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0;
}
table.grid td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle;
}
table.grid tbody tr:hover { background: #f8fafc; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.mid, table.grid th.mid { text-align: center; }
table.grid .strong { font-weight: 600; color: var(--text); }
table.grid .muted { color: var(--text-3); font-size: 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.link-btn { color: var(--brand); font-size: 12.5px; padding: 2px 5px; border-radius: 4px; }
.link-btn:hover { background: var(--brand-light); }
.link-btn.del { color: var(--red); }
.link-btn.del:hover { background: var(--red-bg); }

.empty {
  text-align: center; padding: 52px 20px; color: var(--text-3);
}
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.empty p { font-size: 13.5px; margin-bottom: 4px; }
.empty .hint { font-size: 12px; color: #cbd5e1; }

/* ---------- 徽章 ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap; line-height: 1.7;
}
.tag.blue   { background: var(--brand-light); color: var(--brand); }
.tag.green  { background: var(--green-bg); color: var(--green); }
.tag.red    { background: var(--red-bg); color: var(--red); }
.tag.amber  { background: var(--amber-bg); color: var(--amber); }
.tag.purple { background: #f5f3ff; color: var(--purple); }
.tag.gray   { background: #f1f5f9; color: var(--text-2); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid.c3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.c1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span2 { grid-column: span 2; }
.field.span3 { grid-column: span 3; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field > label .req { color: var(--red); margin-left: 2px; }
.field .tip { font-size: 11.5px; color: var(--text-3); }
input[type=text], input[type=number], input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
input:disabled, input[readonly] { background: #f8fafc; color: var(--text-2); }
textarea { resize: vertical; min-height: 68px; line-height: 1.6; }
select { cursor: pointer; }

.section-title {
  font-size: 13px; font-weight: 700; color: var(--brand);
  padding-bottom: 7px; margin: 22px 0 14px;
  border-bottom: 2px solid var(--brand-soft);
  display: flex; align-items: center; gap: 7px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- 尺码矩阵 ---------- */
.size-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.size-table th {
  padding: 7px 6px; background: #f8fafc; font-size: 12px; font-weight: 600;
  color: var(--text-2); border: 1px solid var(--border);
  border-right: none; text-align: center; white-space: nowrap;
}
.size-table th:last-child { border-right: 1px solid var(--border); }
.size-table td { border: 1px solid var(--border); border-top: none; padding: 0; text-align: center; }
.size-table td input {
  border: none; border-radius: 0; text-align: center; padding: 7px 4px;
  background: transparent; font-variant-numeric: tabular-nums;
}
.size-table td input:focus { box-shadow: inset 0 0 0 2px var(--brand); background: #fff; }
.size-table td.total-cell { background: #f8fafc; font-weight: 700; }
.size-head { display: flex; align-items: center; gap: 4px; justify-content: center; }
.size-head .x {
  color: var(--text-3); font-size: 13px; line-height: 1; padding: 0 2px;
}
.size-head .x:hover { color: var(--red); }
.size-tools { display: flex; gap: 6px; align-items: center; }
.size-tools input { padding: 5px 9px; font-size: 12.5px; width: 130px; }

/* ---------- 图片上传 ---------- */
.img-picker {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: 14px; text-align: center; cursor: pointer; background: #fcfdff;
  transition: all .12s; min-height: 108px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.img-picker:hover { border-color: var(--brand); background: var(--brand-light); }
.img-picker .ico { font-size: 21px; opacity: .55; }
.img-picker .txt { font-size: 12px; color: var(--text-3); }
.img-preview { position: relative; display: inline-block; }
.img-preview img {
  max-width: 100%; max-height: 150px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); display: block;
}
.img-preview .rm {
  position: absolute; top: -8px; right: -8px;
  background: var(--red); color: #fff; width: 22px; height: 22px;
  border-radius: 50%; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 1000; padding: 28px 16px; overflow-y: auto;
  animation: fade .13s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 860px;
  box-shadow: var(--shadow-lg); animation: pop .16s ease;
  margin: auto 0;
}
.modal.wide { max-width: 1060px; }
.modal.narrow { max-width: 520px; }
@keyframes pop { from { transform: translateY(-10px) scale(.99); opacity: 0 } to { transform: none; opacity: 1 } }
.modal-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-head .sub { font-size: 12px; color: var(--text-3); }
.modal-head .x {
  margin-left: auto; font-size: 21px; color: var(--text-3); line-height: 1;
  width: 30px; height: 30px; border-radius: 6px;
}
.modal-head .x:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px; max-height: calc(100vh - 190px); overflow-y: auto; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end; background: #fcfdff;
  border-radius: 0 0 12px 12px;
}
.modal-foot .left { margin-right: auto; }

/* ---------- 提示 ---------- */
#toast-wrap {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease; max-width: 460px;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; display: flex; gap: 10px;
  flex-wrap: wrap; align-items: center; box-shadow: var(--shadow);
}
.filter-bar input, .filter-bar select { width: auto; min-width: 128px; padding: 7px 10px; font-size: 13px; }
.filter-bar .grow { flex: 1; min-width: 190px; }
.filter-bar .result { margin-left: auto; font-size: 12.5px; color: var(--text-3); }
.filter-bar .result b { color: var(--brand); font-size: 14px; }

/* ---------- 详情展示 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 20px; }
.detail-grid.c2 { grid-template-columns: repeat(2, 1fr); }
.detail-item .k { font-size: 11.5px; color: var(--text-3); margin-bottom: 3px; }
.detail-item .v { font-size: 13.5px; color: var(--text); word-break: break-all; }
.detail-item .v.big { font-size: 17px; font-weight: 700; }

/* ---------- 进度条 ---------- */
.bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 4px; transition: width .3s; }
.bar.warn > i { background: var(--amber); }
.bar.bad  > i { background: var(--red); }

/* ---------- 报价单打印视图 ---------- */
.quote-doc { background: #fff; padding: 34px 38px; font-size: 13px; color: #000; }
.quote-doc h2 { text-align: center; font-size: 21px; letter-spacing: 5px; margin-bottom: 6px; font-weight: 700; }
.quote-doc .doc-sub { text-align: center; font-size: 12px; color: #555; margin-bottom: 20px; }
.quote-doc .doc-meta {
  display: flex; justify-content: space-between; font-size: 12.5px;
  margin-bottom: 12px; line-height: 1.9; color: #333;
}
.quote-doc table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.quote-doc table th, .quote-doc table td { border: 1px solid #999; padding: 7px 8px; }
.quote-doc table th { background: #f2f2f2; font-weight: 600; text-align: center; }
.quote-doc table td.num { text-align: right; }
.quote-doc .doc-foot { margin-top: 18px; font-size: 12px; color: #444; line-height: 2; }
.quote-doc .stamp { text-align: right; margin-top: 26px; font-size: 13px; }

/* ---------- 报价单 v2 版式（2026-11-09）：老样版结构 + 信头式排版 ---------- */
.quote-doc .q-head { display: flex; justify-content: space-between; align-items: flex-end;
  border-bottom: 3px solid #1e40af; padding-bottom: 12px; margin-bottom: 12px; }
.quote-doc .q-brand { font-size: 26px; font-weight: 800; color: #1e40af; letter-spacing: 3px; line-height: 1.2; }
.quote-doc .q-title { font-size: 15px; color: #333; letter-spacing: 6px; margin-top: 5px; font-weight: 600; }
.quote-doc .q-no { text-align: right; font-size: 12px; color: #555; line-height: 1.9; }
.quote-doc .q-no b { font-size: 13.5px; color: #000; }
.quote-doc table th { background: #1e40af; color: #fff; border-color: #1e40af; font-weight: 600; }
.quote-doc table tbody tr:nth-child(even) td { background: #f5f8fd; }
.quote-doc .q-total-row td { background: #e8eefb !important; }
.quote-doc .doc-terms { margin-top: 14px; font-size: 12px; color: #333; line-height: 2; }
.quote-doc .doc-terms .tt { font-weight: 700; }
.quote-doc .doc-sign { display: flex; justify-content: space-between; margin-top: 36px;
  font-size: 12.5px; line-height: 2.2; color: #333; }

/* ---------- 图表条 ---------- */
.mini-bars { display: flex; flex-direction: column; gap: 11px; }
.mini-bar-row { display: grid; grid-template-columns: 96px 1fr 92px; gap: 10px; align-items: center; font-size: 12.5px; }
.mini-bar-row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar-row .track { height: 18px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.mini-bar-row .track > i { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #1e40af); border-radius: 4px; }
.mini-bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---------- 收款记录行 ---------- */
.pay-row {
  display: grid; grid-template-columns: 110px 1fr 110px 130px 40px;
  gap: 10px; align-items: center; padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.pay-row:last-child { border-bottom: none; }

/* ---------- 小工具 ---------- */
.flex { display: flex; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.between { justify-content: space-between; }
.center { align-items: center; }
.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.text-r { text-align: right; } .text-c { text-align: center; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .form-grid.c3 { grid-template-columns: repeat(2, 1fr); }
}

.notice {
  padding: 11px 15px; border-radius: var(--radius-sm); font-size: 12.8px;
  line-height: 1.75; border-left: 3px solid var(--brand);
  background: var(--brand-light); color: var(--brand-dark);
}
.notice.warn { background: var(--amber-bg); border-left-color: var(--amber); color: #92400e; }
.notice.err { background: var(--red-bg); border-left-color: var(--red); color: #991b1b; }
.notice.ok { background: var(--green-bg); border-left-color: var(--green); color: #166534; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
#sidebar ::-webkit-scrollbar-thumb { background: #334155; border-color: var(--sidebar-bg); }

/* 打印 */
@media print {
  @page { margin: 12mm; }
  /* 只打印弹窗里的单据：侧栏、主区（列表/统计卡）全部隐藏（2026-11-09） */
  #sidebar, #main, .page-head, .modal-head, .modal-foot, .no-print { display: none !important; }
  body { display: block; overflow: visible; height: auto; }
  .modal-mask { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: 100%; }
  .modal-body { max-height: none; overflow: visible; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  /* 报价单紧凑排版，保证 A4 单页 */
  .quote-doc { padding: 0; font-size: 12px; }
  .quote-doc .q-head { padding-bottom: 8px; margin-bottom: 8px; }
  .quote-doc .q-brand { font-size: 22px; }
  .quote-doc .doc-sub { margin-bottom: 10px; }
  .quote-doc table th, .quote-doc table td { padding: 5px 7px; }
  .quote-doc .doc-terms { margin-top: 10px; line-height: 1.8; }
  .quote-doc .doc-sign { margin-top: 18px; }
}

/* ---------- 键值明细编辑（量体表"其他量体数据"） ---------- */
.kv-rows { display: flex; flex-direction: column; gap: 6px; }
.kv-row { display: flex; align-items: center; gap: 8px; }
.kv-row input {
  flex: 1; height: 34px; border: 1px solid var(--line, #e2e8f0); border-radius: 8px;
  padding: 0 10px; font-size: 13px; background: #fff; min-width: 0;
}
.kv-row input.kv-k { max-width: 42%; }
.kv-row input:focus { outline: none; border-color: #1e40af; }
