:root {
  --primary:#1B2A4A;
  --primary-hover:#243757;
  --primary-light:#EEF2F8;
  --text:#1F2937;
  --text-secondary:#6B7280;
  --text-muted:#9CA3AF;
  --border:#E5E7EB;
  --divider:#F0F1F3;
  --bg:#F7F8FA;
  --card:#FFFFFF;
  --danger:#C0392B;
  --danger-light:#FDECEA;
  --radius:8px;
  --radius-lg:12px;
  --shadow:0 1px 3px rgba(0,0,0,.04);
  --shadow-lg:0 8px 24px rgba(27,42,74,.10);
  --sidenav-w:200px;
  --bottomnav-h:56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* 通用按钮 / 卡片 */
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 9px 14px; border-radius: var(--radius); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.btn:hover { border-color: var(--border); background: var(--divider); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger-light); background: var(--danger-light); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.muted { color: var(--text-muted); }

/* ===== 布局：PC 左侧固定竖向导航 + 右侧内容 ===== */
.app { display: flex; min-height: 100vh; }

.sidenav {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidenav-w); flex: 0 0 var(--sidenav-w);
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 70;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); }
.brand .logo {
  width: 34px; height: 34px; border-radius: var(--radius); flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
.brand .btxt { min-width: 0; }
.brand .btxt b { display: block; font-size: 15px; color: var(--text); }
.brand .btxt small { color: var(--text-muted); font-size: 11px; }

.snav { padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; }
.snav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: transparent; color: var(--text-secondary);
  padding: 11px 12px; border-radius: var(--radius); font-weight: 600; font-size: 14px; text-align: left;
  box-shadow: inset 0 0 0 0 var(--primary); transition: .15s;
}
.snav button .ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.snav button .ic svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.snav button:hover { background: var(--divider); color: var(--text); }
.snav button.active { background: var(--primary-light); color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.snav-foot { margin-top: auto; padding: 12px 14px; color: var(--text-muted); font-size: 11px; border-top: 1px solid var(--border); }

.main { flex: 1; margin-left: var(--sidenav-w); min-width: 0; }

/* 页面 */
.page { display: none; padding: 20px; }
.page.active { display: block; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { margin: 0; font-size: 20px; color: var(--text); }
.page-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 10px; }

/* 报价页：iframe 铺满 */
#page-quote { padding: 0; }
#quoteFrame { width: 100%; height: 100vh; border: 0; background: var(--card); display: block; }

/* ===== 历史报价 ===== */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.t-search { width: 100%; border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px; background: var(--card); font-size: 14px; color: var(--text); }
.t-search:focus { outline: none; border-color: var(--primary); }
.date-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--card); color: var(--text-secondary); padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-item {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); padding: 14px;
  display: flex; align-items: center; gap: 14px; cursor: pointer; box-shadow: var(--shadow); transition: .15s;
}
.hist-item:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.hi-main { flex: 1; min-width: 0; }
.hi-name { font-weight: 800; font-size: 15px; color: var(--text); }
.hi-sub { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.hi-amount { font-weight: 800; font-size: 18px; color: var(--primary); flex: 0 0 auto; }
.hi-date { color: var(--text-muted); font-size: 12px; flex: 0 0 auto; text-align: right; min-width: 82px; }
.empty { text-align: center; color: var(--text-muted); padding: 34px 12px; }

/* 详情 */
.ro-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ro-summary .box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--divider); }
.ro-summary .box .l { color: var(--text-muted); font-size: 12px; }
.ro-summary .box .n { font-weight: 700; font-size: 15px; margin-top: 2px; word-break: break-all; color: var(--text); }
.det-sec { margin-top: 14px; }
.det-sec h4 { margin: 0 0 6px; font-size: 13px; color: var(--text); }
.det-list { font-size: 12.5px; color: var(--text-secondary); line-height: 1.8; }
.det-list .li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 3px 0; }
.det-list .li b { color: var(--text); font-weight: 600; }

/* ===== 产品资料 ===== */
.gallery-entry { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; cursor: pointer; transition: .15s; }
.gallery-entry:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.ge-thumb {
  width: 64px; height: 64px; border-radius: 10px; flex: 0 0 auto;
  background: var(--divider) center/cover no-repeat; border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 26px; filter:grayscale(1);
}
.ge-body { flex: 1; min-width: 0; }
.ge-title { font-weight: 800; font-size: 15px; color: var(--text); }
.ge-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.ge-btn { flex: 0 0 auto; }

.sticky-search {
  position: sticky; top: 0; z-index: 20; width: 100%;
  border: 1px solid var(--border); border-radius: 999px; padding: 11px 16px;
  background: var(--card); font-size: 14px; margin-bottom: 12px; color: var(--text);
  box-shadow: 0 2px 8px rgba(27,42,74,.06);
}
.sticky-search:focus { outline: none; border-color: var(--primary); }

.mat-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.mgroup { border: 1px solid var(--border); border-radius: 14px; background: var(--card); padding: 16px; cursor: pointer; box-shadow: var(--shadow); transition: .15s; }
.mgroup:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.mg-ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; color: #fff; margin-bottom: 10px; filter:grayscale(1); }
.mg-name { font-weight: 800; font-size: 16px; color: var(--text); }
.mg-desc { color: var(--text-muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.mg-count { margin-top: 10px; font-size: 12px; color: var(--primary); font-weight: 700; }

.mat-panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.mat-panel-title { font-weight: 800; font-size: 15px; color: var(--text); }
.chips-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.chips-scroll .chip { flex: 0 0 auto; }

.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.mat-card { border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); padding: 10px; display: flex; align-items: center; gap: 10px; }
.mc-img { width: 62px; height: 62px; flex: 0 0 auto; border-radius: 8px; object-fit: cover; background: var(--divider); border: 1px solid var(--border); }
.mc-img.ph { display: grid; place-items: center; font-size: 17px; font-weight: 800; color: #fff; }
.mc-main { flex: 1; min-width: 0; }
.mc-name { font-weight: 700; font-size: 13px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text); }
.mc-spec { color: var(--text-muted); font-size: 11px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mc-price { color: var(--primary); font-weight: 800; font-size: 15px; margin-top: 4px; }
.mc-price small { color: var(--text-muted); font-weight: 500; font-size: 11px; }
.mc-add { flex: 0 0 auto; }

/* ===== 导入 ===== */
.imp-card { margin-bottom: 14px; }
.imp-title { font-weight: 800; font-size: 15px; margin-bottom: 6px; color: var(--text); }
.imp-desc { font-size: 13px; line-height: 1.7; margin: 0 0 12px; color: var(--text-secondary); }
.imp-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.qr-preview { font-size: 13px; color: var(--text-secondary); background: var(--primary-light); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 12px; line-height: 1.8; }

/* ===== 弹层 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(27,42,74,.45); display: none; z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-mask.show { display: flex; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-mask.lg .modal { max-width: 900px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--text); }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: transparent; border: none; font-size: 22px; color: var(--text-muted); line-height: 1; }
.modal-code { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; resize: vertical; background: var(--divider); color: var(--text); }
.sync-hint { font-size: 13px; color: var(--text-secondary); line-height: 1.7; margin: 0 0 10px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.field input, .field select, .field textarea { border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; background: var(--divider); color: var(--text); }
.field.full { grid-column: 1 / -1; }

/* 图册网格 + 大图 */
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.gal-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.gal-card img { width: 100%; aspect-ratio: 1/1; object-fit: contain; background: var(--divider); display: block; cursor: zoom-in; }
.gal-card .gc-b { padding: 6px 8px; font-size: 11px; line-height: 1.35; }
.gal-card .gc-l { font-weight: 600; min-height: 28px; color: var(--text); }
.gal-card .gc-c { color: var(--primary); font-size: 10px; margin-top: 2px; }
.lightbox { position: fixed; inset: 0; background: rgba(27,42,74,.92); display: none; align-items: center; justify-content: center; z-index: 400; padding: 24px; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 92vw; max-height: 84vh; object-fit: contain; background: #fff; border-radius: 6px; }
.lightbox .lb-close { position: absolute; top: 14px; right: 22px; color: #fff; font-size: 30px; background: none; border: none; line-height: 1; }
.lightbox .lb-cap { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; padding: 0 20px; }

/* ===== 移动端底部四宫格 ===== */
.bottomnav { display: none; }

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 500;
  opacity: 0; transition: .25s; pointer-events: none; font-size: 13px; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 移动端（<768px）：隐藏左导航，底部吸底四宫格 ===== */
@media (max-width: 767px) {
  .sidenav { display: none; }
  .main { margin-left: 0; padding-bottom: var(--bottomnav-h); }
  .page { padding: 14px 12px; }
  #page-quote { padding: 0; }
  #quoteFrame { height: calc(100vh - var(--bottomnav-h)); }

  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 300;
    background: var(--card); border-top: 1px solid var(--border);
    height: var(--bottomnav-h); align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(27,42,74,.06);
  }
  .bottomnav button {
    flex: 1; border: none; background: transparent;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--text-muted); font-size: 11px; font-weight: 600;
  }
  .bottomnav button .ic { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
  .bottomnav button .ic svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .bottomnav button.active { color: var(--primary); }

  .mat-groups { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mat-grid { grid-template-columns: 1fr; }
  .mat-card { padding: 8px; }
  .mc-img { width: 54px; height: 54px; }
  .hist-item { flex-wrap: wrap; }
  .hi-date { text-align: left; min-width: 0; }
  .meta-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
  .gal-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .ge-btn { display: none; }
  .toast { bottom: calc(var(--bottomnav-h) + 16px); }
}
