/* 疯桃子ERP · 前端样式（多端统一：桌面/平板/手机 H5 共用一套版面） */
:root {
  --peach: #ff7a59;
  --peach-dark: #ef5b3a;
  --primary: #ff7a59;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2329;
  --text-weak: #8a9099;
  --border: #e8eaed;
  --ok: #22c55e;
  --warn: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
#app { min-height: 100vh; }

/* 顶栏 */
.erp-topbar {
  height: 56px; display: flex; align-items: center; padding: 0 16px;
  background: linear-gradient(90deg, #ff8a65, #ff7043);
  color: #fff; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.erp-logo { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.erp-logo .short { display: none; }
.erp-logo .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.erp-nav { display: flex; align-items: center; gap: 4px; margin-left: 28px; flex: 1; overflow-x: auto; }
.erp-nav a {
  color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 8px;
  font-size: 14px; white-space: nowrap; opacity: .9; cursor: pointer; user-select: none;
}
.erp-nav a:hover { background: rgba(255,255,255,.18); }
.erp-nav a.active { background: rgba(255,255,255,.28); font-weight: 700; opacity: 1; }
.erp-nav .dropdown { position: relative; }
.erp-nav .dropdown-menu {
  position: absolute; top: 40px; left: 0; background: #fff; color: var(--text);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.16); min-width: 140px; display: none; z-index: 200;
}
.erp-nav .dropdown:hover .dropdown-menu { display: block; }
.erp-nav .dropdown-menu a { display: block; color: var(--text); padding: 9px 14px; }
.erp-nav .dropdown-menu a:hover { background: var(--bg); }
.erp-user { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.erp-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--peach-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* 容器（响应式断点基于容器宽度） */
.ds { padding: 16px; max-width: 1280px; margin: 0 auto; container-type: inline-size; }

/* 区块标题 */
.section-title { font-size: 16px; font-weight: 700; margin: 6px 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 16px; background: var(--peach); border-radius: 2px; }

/* 指标卡 */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.metric-card { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); border: 1px solid var(--border); }
.metric-card .label { color: var(--text-weak); font-size: 13px; }
.metric-card .value { font-size: 22px; font-weight: 800; margin-top: 6px; }
.metric-card .sub { font-size: 12px; color: var(--text-weak); margin-top: 4px; }
.metric-group-title { font-size: 14px; font-weight: 700; color: var(--peach-dark); margin: 18px 0 10px; }
.progress-bar { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-bar > span { display: block; height: 100%; background: var(--peach); }

/* 切换栏 + 搜索栏 */
.work-switch { display: flex; align-items: center; background: var(--panel); border-radius: var(--radius); padding: 6px; border: 1px solid var(--border); }
.work-switch .tab { padding: 8px 22px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.work-switch .tab.active { background: var(--peach); color: #fff; }
.work-search { display: flex; gap: 8px; margin: 12px 0; }
.work-search input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.work-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; background: var(--panel); padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.work-toolbar .spacer { flex: 1; }
.summary-chip { background: #fff3ef; color: var(--peach-dark); padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }

/* 表格 */
.erp-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.erp-table th, .erp-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.erp-table th { background: #fafbfc; font-weight: 600; color: var(--text-weak); }
.erp-table tr:hover { background: #fcfcfd; }
.erp-table .title-link { color: var(--peach-dark); cursor: pointer; font-weight: 600; }
.table-scroll { overflow-x: auto; }

/* 品类标签组 */
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 14px; font-size: 12px; color: #fff; }
.cat-chip.sum { font-weight: 700; }

/* 状态标签 */
.pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #e7f8ee; color: var(--ok); }
.pill.warn { background: #fdeaea; color: var(--warn); }
.pill.info { background: #e8f0fe; color: #2563eb; }
.pill.muted { background: #f0f1f3; color: var(--text-weak); }
.pill.err { background: #fdeaea; color: #dc2626; }
.pill.pulling { background: #fff7e6; color: #b45309; }
.pill.pulling .spinner { display: inline-block; width: 10px; height: 10px; border-color: #b45309; border-top-color: transparent; vertical-align: -1px; margin-right: 3px; }

/* 费用状态标签（双感叹号） */
.fee-flag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 14px; font-size: 12px; font-weight: 600; margin-left: 6px; }
.fee-flag.missing { background: #fdeaea; color: var(--warn); }
.fee-flag.filled { background: #e7f8ee; color: var(--ok); }

/* 货单卡片 */
.order-card { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--border); margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.03); }
.order-card .head { display: flex; align-items: center; gap: 10px; }
.order-card .code { font-weight: 800; font-size: 15px; cursor: pointer; }
.order-card .code:hover { color: var(--peach-dark); }
.order-card .meta { color: var(--text-weak); font-size: 12px; margin: 6px 0; }
.order-card .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.fee-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.fee-strip .cell { background: #fafbfc; border-radius: 8px; padding: 8px; text-align: center; }
.fee-strip .cell .k { font-size: 12px; color: var(--text-weak); }
.fee-strip .cell .v { font-weight: 700; margin-top: 3px; }

/* 模态与表单 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-box.wide { max-width: 880px; }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-row .req { color: var(--warn); margin-left: 2px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.form-row textarea { min-height: 70px; resize: vertical; }
.btn { padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--peach); color: #fff; border-color: var(--peach); }
.btn.primary:hover { background: var(--peach-dark); }
.btn.primary:disabled { background: #f0c3b6; border-color: #f0c3b6; cursor: not-allowed; }
.btn.danger { color: var(--warn); border-color: #f3c9c9; }
.btn.ghost { border-color: transparent; }

/* 成本字段 */
.cost-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.cost-row .field { background: #fafbfc; border-radius: 8px; padding: 8px 10px; }
.cost-row .field .k { font-size: 12px; color: var(--text-weak); }
.cost-row .field .v { font-weight: 700; margin-top: 2px; }

/* 模板 / 标签编辑 */
.tpl-list { border-right: 1px solid var(--border); padding-right: 10px; min-width: 150px; }
.tpl-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.tpl-item.active { background: #fff3ef; color: var(--peach-dark); font-weight: 700; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0; }
.tpl-tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 14px; color: #fff; font-size: 12px; }

/* 标记台 */
.mark-wrap { display: grid; grid-template-columns: 1fr 220px; gap: 14px; }
.mark-canvas { position: relative; background: #111; border-radius: 10px; overflow: hidden; min-height: 360px; display: flex; align-items: center; justify-content: center; }
.mark-canvas img { max-width: 100%; max-height: 70vh; user-select: none; }
.mark-marker { position: absolute; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; transform: translate(-50%,-50%); cursor: pointer; font-size: 11px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.mark-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.mark-thumb { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; cursor: pointer; border: 2px solid transparent; }
.mark-thumb.active { border-color: var(--peach); }
.mark-side .tag-btn { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; cursor: pointer; border: 1px solid var(--border); background: #fff; }
.mark-side .tag-btn.active { border-color: var(--peach); background: #fff3ef; }

.placeholder-page { text-align: center; padding: 80px 20px; color: var(--text-weak); }
.placeholder-page .big { font-size: 56px; }

.cat-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cat-row input { flex: 1; }
.cat-row .qty { width: 90px; }

/* 响应式断点（基于容器宽度） */
@container (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .fee-strip { grid-template-columns: repeat(3, 1fr); }
}
@container (max-width: 640px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .fee-strip { grid-template-columns: repeat(2, 1fr); }
  .work-switch .tab { padding: 8px 14px; }
  .order-card .code { white-space: nowrap; }
  .order-card .actions { justify-content: flex-end; }
  .mark-wrap { grid-template-columns: 1fr; }
  .table-scroll { overflow-x: auto; }
  .erp-table { min-width: 560px; }
  .ds { padding: 12px 10px; }
  .tpl-layout { grid-template-columns: 1fr; }
  .tpl-list { border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 10px; }
  .order-card .flags { margin-left: 0; }
  .cat-row { flex-wrap: wrap; }
  .cat-row input { flex: 1 1 140px; }
  .work-search { top: 52px; }
}
/* 顶栏在 .ds 容器之外，容器查询不生效，改用媒体查询 */
@media (max-width: 1024px) {
  .erp-user .name { display: none; }
}
@media (max-width: 640px) {
  .erp-logo span.full { display: none; }
  .erp-logo .short { display: inline; }
  .erp-nav { margin-left: 14px; }
  .erp-nav a { padding: 8px 10px; font-size: 13px; }
  .erp-topbar { height: 52px; padding: 0 10px; }
}
@media (min-width: 1025px) { .metric-grid { grid-template-columns: repeat(4, 1fr); } }

.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 999; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.flash { position: fixed; bottom: 24px; right: 24px; background: var(--peach); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 998; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* ============================ 增补：视图层所需样式 ============================ */
/* 盈亏配色遵循 A 股习惯：涨（盈）红、跌（亏）绿 */
.val-up { color: #d93025 !important; }
.val-down { color: #16a34a !important; }

.muted { color: var(--text-weak); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.wide-ds { max-width: 1440px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-chart { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 12px 4px; }
.chart-legend { display: flex; gap: 16px; justify-content: flex-end; font-size: 12px; color: var(--text-weak); }
.chart-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.sw-income { background: #ff7a59; }
.trend-svg { width: 100%; height: 220px; display: block; }
.grid-line { stroke: #eef0f2; stroke-width: 1; }
.axis-text { font-size: 11px; fill: #8a9099; }

.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.full { width: 100%; }
.btn.ghost { border-color: transparent; background: #f5f6f8; }
.btn.ghost:hover { background: #ebedf0; }
.icon-btn { border: none; background: transparent; cursor: pointer; color: var(--text-weak); font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: #f0f1f3; color: var(--text); }
.row-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-inline .spacer { flex: 1; }

.hint { font-size: 12px; color: var(--text-weak); line-height: 1.6; }
.hint.err { color: var(--warn); }
.hint.ok { color: var(--ok); }
.hint-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.inline-label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.inline-label input { width: auto; }

/* 次级状态筛选（低于一级切换栏） */
.sub-tabs { display: flex; gap: 6px; }
.sub-tab { padding: 6px 14px; border-radius: 16px; cursor: pointer; font-size: 13px; color: var(--text-weak); background: #f5f6f8; }
.sub-tab.active { background: #fff3ef; color: var(--peach-dark); font-weight: 700; }

.empty-cell { text-align: center; color: var(--text-weak); padding: 30px 0 !important; }
.notes-cell { color: var(--text-weak); max-width: 320px; }
.pager { padding: 10px 12px; display: flex; justify-content: flex-end; background: var(--panel); border-top: 1px solid var(--border); }

.work-search.sticky, .work-search { position: sticky; top: 56px; z-index: 30; background: var(--bg); padding: 10px 0; margin: 0 0 4px; }
.work-search.inline { position: static; margin: 0; padding: 0; }
.work-search input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; }
.work-search.inline input { max-width: 320px; }

/* 货单卡片：品类明细与费用标签同一行 */
.order-card .catline { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.order-card .catline .cat-chips { flex: 1; min-width: 200px; }
.order-card .flags { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.order-card .actions { margin-top: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.order-card .head { flex-wrap: wrap; }

/* 详情浮层 */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px; margin-bottom: 14px; }
.detail-kv { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.detail-kv > span { color: var(--text-weak); font-size: 12px; }
.detail-kv > b { font-weight: 600; word-break: break-all; }
.sub-block { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.sub-title { font-size: 13px; font-weight: 700; color: var(--peach-dark); margin-bottom: 8px; }
.pre { white-space: pre-wrap; font-size: 13px; color: var(--text); background: #fafbfc; border-radius: 8px; padding: 8px 10px; margin-top: 6px; }

/* 模版编辑 */
.tpl-layout { display: grid; grid-template-columns: 190px 1fr; gap: 14px; }
.tpl-editor { min-width: 0; }
.tpl-tag .tag-x, .tag-btn .tag-x { margin-left: 6px; opacity: .7; cursor: pointer; }
.tpl-tag .tag-x:hover, .tag-btn .tag-x:hover { opacity: 1; }
.tpl-list .tpl-item { gap: 6px; }

/* 标记台 */
.mark-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.mark-side .side-title { font-size: 12px; font-weight: 700; color: var(--text-weak); margin: 10px 0 6px; }
.mark-side .side-title:first-child { margin-top: 0; }
.mark-side .tag-btn { display: flex; align-items: center; gap: 8px; }
.mark-side .tag-btn .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mark-side .tag-btn .nm { flex: 1; }
.mark-side .tag-btn .cnt { font-size: 12px; color: var(--text-weak); }
.mark-thumb.add { display: flex; align-items: center; justify-content: center; background: #f5f6f8; border: 1px dashed #d5d8dd; color: var(--text-weak); font-size: 20px; }
.mark-canvas.placeholder { background: #f5f6f8; border: 1px dashed #d5d8dd; }
.mark-thumbs.empty { padding: 10px 0; }

/* 创建货单：所选货品列表 */
.goods-pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.goods-pick { padding: 8px; border-bottom: 1px dashed var(--border); }
.goods-pick:last-of-type { border-bottom: none; }
.gp-head { display: flex; align-items: center; gap: 10px; }
.gp-title { font-weight: 600; flex: 1; }
.gp-cost { font-weight: 700; color: var(--peach-dark); }
.gp-meta { font-size: 12px; color: var(--text-weak); margin: 2px 0 5px; }
.gp-total { text-align: right; font-size: 13px; padding: 8px 4px 2px; }

/* 附件 */
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach { display: flex; align-items: center; gap: 8px; background: #fafbfc; border-radius: 8px; padding: 7px 10px; }
.pdf-icon { background: #fdeaea; color: var(--warn); font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 4px; }
.att-name { cursor: pointer; color: var(--peach-dark); font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.ir-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

/* PDF 预览 */
.pdf-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pdf-frame { height: 62vh; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #f5f6f8; }
.pdf-frame iframe { width: 100%; height: 100%; border: none; }

/* 财务记账台 */
.finance-panel { padding: 14px; }
.finance-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.bee-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.bee-empty { text-align: center; padding: 60px 20px; }
.bee-empty .big { font-size: 56px; }
.bee-title { font-size: 16px; font-weight: 700; margin: 10px 0 6px; }
.bee-desc { color: var(--text-weak); font-size: 13px; line-height: 1.8; }
.bee-desc code { background: #f0f1f3; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.bee-actions { margin-top: 16px; display: flex; gap: 10px; justify-content: center; }
.pub-title { font-size: 18px; font-weight: 700; color: var(--text); margin-top: 8px; }
.pub-sub { color: var(--text-weak); margin-top: 6px; font-size: 13px; }

/* 响应式补充 */
@container (max-width: 640px) {
  .tpl-layout { grid-template-columns: 1fr; }
  .tpl-list { border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 10px; }
  .order-card .flags { margin-left: 0; }
  .cat-row { flex-wrap: wrap; }
  .cat-row input { flex: 1 1 140px; }
  .work-search { top: 52px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}


/* ---- eBay 代理抓取结果（图片 / 标题 / 描述 / 诊断） ---- */
.scrape-box {
  margin: 10px 0 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fafbfc;
}
.scrape-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.scrape-head .hint { font-size: 12px; }
.scrape-msg { white-space: normal; word-break: break-word; line-height: 1.6; }
.scrape-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.scrape-imgs img {
  width: 76px; height: 76px; object-fit: cover;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.scrape-imgs.big img { width: 132px; height: 132px; }
.scrape-box a { color: var(--peach); }
@container (max-width: 640px) {
  .scrape-imgs.big img { width: 96px; height: 96px; }
}
