  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f7fb;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
  }
  input { font-family: inherit; -webkit-appearance: none; appearance: none; }
  input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  input[type=number] { -moz-appearance: textfield; }

  /* ===== 客户选择条 ===== */
  .customerbar {
    background: #fff;
    padding: 10px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    max-width: 720px;
    margin: 0 auto;
    box-sizing: border-box;
  }
  .customerbar label { color: #6b7280; font-size: 13px; }
  .customerbar select {
    flex: 1;
    max-width: 320px;
    height: 32px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13px;
    background: #fff;
    color: #1f2937;
  }
  .customerbar select:focus { outline: none; border-color: #1e3a5f; }
  .customerbar .customer-meta { color: #9ca3af; font-size: 12px; }
  .customerbar .customer-meta b { color: #1e3a5f; }
  .btn-mini-cust {
    background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db;
    padding: 4px 10px; border-radius: 5px; font-size: 12px; cursor: pointer;
    white-space: nowrap;
  }
  .btn-mini-cust:hover { background: #e5e7eb; }

  /* 客户管理 modal */
  .cust-modal { max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto; }
  .cust-modal h3 { color: #1e3a5f; margin: 0 0 12px; font-size: 16px; }
  .cust-form { background: #f9fafb; padding: 12px; border-radius: 8px; margin-bottom: 16px; }
  .cust-form h4 { margin: 0 0 10px; font-size: 13px; color: #6b7280; }
  .cust-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
  .cust-form-row.single { grid-template-columns: 1fr; }
  .cust-form-row input { width: 100%; height: 36px; border: 1px solid #d1d5db; border-radius: 5px; padding: 0 10px; font-size: 13px; box-sizing: border-box; }
  .cust-form-row input:focus,
.cust-form-row select:focus { outline: none; border-color: #1e3a5f; }
  .cust-form-btns { display: flex; gap: 8px; margin-top: 4px; }
  .cust-form-btns button { flex: 1; height: 36px; border-radius: 5px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; }
  .btn-cust-save { background: #1e3a5f; color: #fff; }
  .btn-cust-cancel { background: #f3f4f6; color: #4b5563; }

  .cust-list { display: flex; flex-direction: column; gap: 6px; }
  .cust-item { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; }
  .cust-item-info { flex: 1; min-width: 0; }
  .cust-item-name { font-size: 14px; font-weight: 600; color: #1f2937; }
  .cust-item-meta { font-size: 11px; color: #9ca3af; margin-top: 2px; }
  .cust-item-actions { display: flex; gap: 4px; }
  .cust-item-actions button { background: #f3f4f6; border: none; padding: 4px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; }
  .cust-item-actions .edit:hover { background: #dbeafe; color: #1e40af; }
  .cust-item-actions .del:hover { background: #fee2e2; color: #dc2626; }
  .cust-empty { text-align: center; padding: 20px; color: #9ca3af; font-size: 13px; }
  @media (max-width: 640px) {
    .customerbar { flex-wrap: wrap; }
    .customerbar select { max-width: none; width: 100%; }
  }

  /* ===== 顶部 Logo + Banner (与 PRE 报价系统一致 720px) ===== */
  .header-logo {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    padding: 12px 24px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
  }
  .header-logo img {
    max-width: 480px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
  }
  .brand-banner {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #c62828 100%);
    color: #fff;
    padding: 18px 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(26, 35, 126, 0.06);
    border-radius: 0 0 12px 12px;
    position: relative;
  }
  .brand-banner h1 { font-size: 1.5rem; font-weight: 900; letter-spacing: 2px; margin-bottom: 4px; color: #fff; }
  .brand-banner p { font-size: 0.95rem; opacity: 0.95; font-weight: 600; letter-spacing: 4px; padding-left: 4px; color: #fff; }
  .brand-userbar {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .brand-userbar .user-name { font-size: 12px; opacity: 0.95; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
  .brand-userbar .btn-mini {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
  }
  .brand-userbar .btn-mini:hover { background: rgba(255, 255, 255, 0.3); }
  .brand-userbar .btn-mini.primary { background: #fff; color: #1a237e; border-color: #fff; font-weight: 600; }
  .brand-userbar .btn-mini.primary:hover { background: #f0f4ff; }
  @media (max-width: 640px) {
    .brand-userbar { position: static; transform: none; margin-top: 10px; justify-content: center; flex-wrap: wrap; }
    .brand-banner { padding-bottom: 16px; }
  }

  /* ===== 系统选择条 (与 portal 一致 720px 居中) ===== */
  .sysbar {
    background: #fff;
    padding: 10px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    max-width: 720px;
    margin: 0 auto;
    box-sizing: border-box;
  }
  .sys-tabs { display: flex; gap: 4px; }
  .sys-tab {
    padding: 6px 14px;
    border-radius: 6px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    user-select: none;
  }
  .sys-tab:hover { background: #e5e7eb; }
  .sys-tab.active { background: #1e3a5f; color: #fff; }
  .sys-info { color: #6b7280; font-size: 12px; }
  .sys-info b { color: #1e3a5f; }

  /* ===== 主容器 (与 PRE 报价系统一致 720px) ===== */
  .container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
  }
  .layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* ===== 卡片 ===== */
  .card {
    background: #fff;
    border-radius: 10px;
    padding: 0;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    overflow: hidden;
  }
  .card-body { overflow: visible; }
  .card-head {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f1f4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
  }
  .card-head-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #1f2937; }
  .step-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #1e3a5f;
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    flex-shrink: 0;
  }
  .card-head-tag { font-size: 11px; color: #9ca3af; }
  .card-body { padding: 8px 16px 14px; }
  .field-row {
    display: flex;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px dashed #f0f1f4;
  }
  .field-row:last-child { border-bottom: none; }
  .field-label { flex: 0 0 130px; color: #4b5563; font-size: 14px; }
  .field-input-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
  .field-input {
    flex: 1;
    min-width: 50px;
    width: 100%;
    height: 36px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .field-input:focus { outline: none; border-color: #1e3a5f; box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1); }
  .field-input:hover:not(:focus) { border-color: #9ca3af; }

  /* 销售价格输入框:大字号醒目 */
  .card.step-price .field-input { font-size: 22px; font-weight: 700; height: 44px; }
  .card.step-price .field-unit { font-size: 12px; }

  /* 两列卡片行(材料规格 + 原料单价) */
  .cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .cards-row > .card { margin-bottom: 0; }
  @media (max-width: 760px) {
    .cards-row { grid-template-columns: 1fr; }
  }

  /* 费用参数: 同一卡片内两列紧凑布局 */
  .fee-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .fee-row .field-row { padding: 0; border-bottom: none; }
  .fee-row .field-label { flex: 0 0 70px; font-size: 13px; }
  .fee-row .field-input-wrap { max-width: 200px; }
  .fee-row .field-input { height: 40px; font-size: 15px; font-weight: 600; }
  @media (max-width: 480px) {
    .fee-row { grid-template-columns: 1fr; }
  }
  .field-unit {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
    pointer-events: none;
    user-select: none;
  }
  .hint-line {
    padding: 6px 0 2px;
    font-size: 11px;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 4px;
    padding: 6px 10px;
    margin: 4px 0 0;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
  }
  .hint-line b { color: #1e3a5f; }
  .hint-line.warn { background: #fffbeb; color: #b45309; }
  .hint-line-err { background: #fef2f2; color: #b91c1c; border-left: 3px solid #ef4444; padding-left: 8px; }
  .hint-line-err b { color: #b91c1c; }
  /* 结果区上方的克重计算公式 (与图1同步) */
  .hint-line-result { margin: 12px 0 0; padding: 10px 12px; font-size: 13px; background: #f0f9ff; color: #1e3a5f; border-left: 3px solid #3b82f6; border-radius: 0 6px 6px 0; }
  .hint-line-result b { color: #1e3a5f; }
  .err-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; background: #ef4444; color: #fff; border-radius: 4px; font-size: 11px; font-weight: 600; }
  .field-input-err, .field-input-err:hover { border-color: #ef4444 !important; background: #fef2f2; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important; }
  /* 锁定的输入框 (只读) */
  .field-input-locked, .field-input-locked:hover {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    color: #6b7280 !important;
    cursor: not-allowed !important;
    pointer-events: none;
    user-select: none;
  }
  /* select 下拉框样式 - 去除所有箭头, 点击呈现下拉效果 */
  .field-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    text-align: right !important;
    font-weight: 700 !important;
    background-image: none !important;
    background: #fff !important;
    padding-right: 12px !important;
    cursor: pointer;
  }

  /* ===== 结果区 ===== */
  .result-section { display: flex; flex-direction: column; gap: 12px; }

  .result-hero {
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #c62828 100%);
    color: #fff;
    padding: 22px 20px;
    text-align: center;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.15), 0 0 0 1px rgba(26, 35, 126, 0.06);
  }
  .result-rate { font-size: 42px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
  .result-rate.loss { color: #fca5a5; }
  .result-rate-label { font-size: 12px; opacity: 0.85; margin-top: 4px; }
  .result-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.2);
  }
  .result-tag.loss { background: rgba(252, 165, 165, 0.25); }

  .result-list { background: #fff; border-radius: 10px; padding: 4px 0; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
  .result-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 20px;
    font-size: 14px;
    border-bottom: 1px dashed #f0f1f4;
  }
  .result-item:last-child { border-bottom: none; }
  .result-item .k { color: #6b7280; }
  .result-item .v { font-weight: 600; color: #1f2937; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
  .result-item.highlight .v { font-size: 15px; }
  .result-item.profit .v { color: #16a34a; }
  .result-item.loss .v { color: #dc2626; }

  /* ===== 饼图 ===== */
  .chart-card { background: #fff; border-radius: 10px; padding: 16px 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
  .chart-title { font-size: 14px; font-weight: 600; color: #1f2937; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
  .chart-title svg { flex-shrink: 0; }
  .pie-wrap { display: flex; align-items: center; gap: 28px; }
  .pie-svg { width: 150px; height: 150px; flex-shrink: 0; }
  @media (min-width: 1280px) {
    .pie-svg { width: 170px; height: 170px; }
  }
  .pie-svg path { transition: opacity 0.2s; cursor: pointer; }
  .pie-svg path:hover { opacity: 0.8; }
  .pie-center { font-size: 20px; font-weight: 700; fill: #1e3a5f; font-family: ui-monospace, monospace; }
  .pie-center-sub { font-size: 10px; fill: #9ca3af; }
  .pie-legend { flex: 1; display: flex; flex-direction: column; gap: 0; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; background: #fff; }
  .pie-leg-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #374151; padding: 8px 10px; background: #f3f4f6; border-bottom: 1px solid #d1d5db; font-weight: 600; }
  .pie-leg-head .h-name { flex: 1; }
  .pie-leg-head .h-num { min-width: 62px; text-align: right; }
  .pie-leg-head .h-wpct { min-width: 62px; text-align: right; }
  .pie-leg-head .h-cost { min-width: 62px; text-align: right; }
  .pie-leg-head .h-pct { min-width: 56px; text-align: right; }
  .pie-leg-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 10px; border-bottom: 1px solid #e5e7eb; }
  .pie-leg-item:last-child { border-bottom: none; }
  .pie-leg-dot { width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0; }
  .pie-leg-name { color: #4b5563; flex: 1; }
  .pie-leg-val { font-family: ui-monospace, monospace; font-weight: 600; color: #1f2937; font-size: 12px; min-width: 62px; text-align: right; }
  .pie-leg-val .u { color: #9ca3af; font-weight: 400; font-size: 10px; margin-left: 2px; }
  .pie-leg-gsm { font-family: ui-monospace, monospace; color: #6b7280; font-size: 11px; min-width: 62px; text-align: right; }
  .pie-leg-pct { color: #9ca3af; font-size: 11px; min-width: 56px; text-align: right; }
  .pie-leg-wpct { color: #1e3a5f; font-size: 11px; min-width: 56px; text-align: right; font-weight: 500; }

  /* ===== 警告 ===== */
  .alert { background: #fffbeb; border-left: 3px solid #f59e0b; padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 12px; color: #92400e; }
  .alert-item { padding: 2px 0; }

  /* ===== 底部操作 ===== */
  .actions { display: flex; gap: 8px; padding: 4px 0 20px; }
  .btn {
    flex: 1;
    height: 44px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
  }
  .btn:active { transform: scale(0.98); }
  .btn-primary { background: linear-gradient(135deg, #1e3a5f 0%, #2a5298 100%); color: #fff; box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2); }
  .btn-primary:hover { box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3); }
  .btn-calc { background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #c62828 100%); color: #fff; box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3); font-size: 15px; }
  .btn-calc:hover { box-shadow: 0 4px 12px rgba(26, 35, 126, 0.4); }
  .btn-export { background: #16a34a; color: #fff; box-shadow: 0 2px 8px rgba(22, 163, 74, 0.2); }
  .btn-export:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3); }
  .btn-secondary { background: #f3f4f6; color: #4b5563; }
  .btn-secondary:hover { background: #e5e7eb; }

  /* ===== Toast ===== */
  .toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: rgba(31, 41, 55, 0.95); color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; z-index: 100; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 80%; }
  .toast.show { opacity: 1; }
  .toast.ok { background: #16a34a; }
  .toast.err { background: #dc2626; }

  /* ===== 弹窗 ===== */
  .modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; display: none; align-items: center; justify-content: center; padding: 16px; }
  .modal-bg.show { display: flex; }
  .modal { background: #fff; border-radius: 10px; padding: 22px; max-width: 360px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
  .modal h3 { margin: 0 0 14px; font-size: 16px; color: #1e3a5f; }
  .modal input { width: 100%; height: 40px; border: 1px solid #d1d5db; border-radius: 6px; padding: 0 12px; font-size: 14px; margin-bottom: 8px; }
  .modal input:focus { outline: none; border-color: #1e3a5f; }
  .modal-btns { display: flex; gap: 8px; margin-top: 10px; }
  .modal-btns button { flex: 1; height: 40px; border-radius: 6px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; }
  .modal-btns .cancel { background: #f3f4f6; color: #4b5563; }
  .modal-btns .submit { background: #1e3a5f; color: #fff; }

  /* ===== 抽屉 (历史) ===== */
  .drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 55; display: none; }
  .drawer-overlay.show { display: block; }
  .drawer { position: fixed; top: 0; right: -100%; width: 92%; max-width: 380px; height: 100%; background: #f5f7fb; z-index: 60; transition: right 0.3s; overflow-y: auto; box-shadow: -2px 0 12px rgba(0,0,0,0.15); }
  .drawer.open { right: 0; }
  .drawer-header { background: linear-gradient(135deg, #1e3a5f 0%, #2a5298 100%); color: #fff; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
  .drawer-header h3 { margin: 0; font-size: 15px; }
  .drawer-close { background: transparent; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
  .drawer-body { padding: 12px; }
  .history-item { background: #fff; padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
  .history-item:hover { box-shadow: 0 2px 8px rgba(30, 58, 95, 0.1); transform: translateY(-1px); transition: all 0.15s; }
  .history-top { display: flex; justify-content: space-between; font-size: 11px; color: #6b7280; margin-bottom: 4px; }
  /* .sys-badge 已清理 (公司内部使用, 不再显示 PRE/ECO/VOL 标识) */
  .history-mid { display: flex; justify-content: space-between; align-items: center; }
  .history-mid .info { font-size: 12px; color: #4b5563; }
  .history-mid .rate { font-size: 16px; font-weight: 700; color: #16a34a; font-variant-numeric: tabular-nums; }
  .history-mid .rate.loss { color: #dc2626; }
  .history-bot { font-size: 10px; color: #9ca3af; margin-top: 4px; }
  .empty { text-align: center; padding: 40px 16px; color: #9ca3af; font-size: 13px; }

  /* 客户历史条目 */
  .cust-hist-item { background: #f9fafb; border-radius: 6px; padding: 8px 10px; cursor: pointer; transition: all .15s; border: 1px solid #f0f1f4; }
  .cust-hist-item:hover { background: #f3f4f6; border-color: #1e3a5f; }
  .hist-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
  .hist-mid { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #4b5563; margin-bottom: 2px; }
  .hist-mid .rate { font-weight: 700; color: #16a34a; font-variant-numeric: tabular-nums; }
  .hist-mid .rate.loss { color: #dc2626; }
  .hist-bot { font-size: 10px; color: #9ca3af; }

  /* ===== 移动端适配 ===== */
  @media (max-width: 640px) {
    .container { padding: 10px; }
    .field-row { flex-wrap: wrap; }
    .field-label { flex: 0 0 100%; margin-bottom: 4px; }
    .field-input-wrap { max-width: none; flex: 1; }
    .result-rate { font-size: 36px; }
    .pie-wrap { flex-direction: column; gap: 16px; align-items: stretch; }
    .pie-svg { width: 130px; height: 130px; margin: 0 auto; }
    .pie-legend { width: 100%; }
    .sys-tabs { flex-wrap: wrap; }
    .sys-tab { padding: 5px 10px; font-size: 12px; }
    .sys-info { width: 100%; }
    .btn { height: 42px; font-size: 13px; }
  }
