/* 云之海 CRM 原型 · 样式表
 * 纯本地文件，无任何 CDN 依赖。浅色主题，仿真实业务系统。
 */

/* ============ 基础 ============ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --bg: #f5f7fa;
  --bg-white: #ffffff;
  --sidebar-bg: #ffffff;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* 数字等宽，金额对齐更专业 */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============ 布局 ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--primary);
}
.sidebar-logo .logo-mark {
  width: 28px; height: 28px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text { color: #fff; font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.sidebar-logo .logo-sub { color: rgba(255, 255, 255, .75); font-size: 11px; display: block; line-height: 1.2; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-group-title {
  padding: 12px 18px 6px;
  font-size: 11px;
  color: var(--text-light);
  letter-spacing: .5px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--text);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
  font-size: 14px;
}
.nav-item:hover { background: var(--border-light); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 9px;
  line-height: 17px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-footer .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-footer .u-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-footer .u-role { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

.main {
  flex: 1;
  margin-left: 208px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============ 顶部栏 ============ */
.topbar {
  height: 56px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); }
.breadcrumb .bc-sep { color: var(--text-light); }
.breadcrumb .bc-current { color: var(--text); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-date { font-size: 12px; color: var(--text-muted); }

/* 演示身份切换器 */
.role-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  border-radius: 14px;
}
.role-box .role-tag {
  font-size: 11px;
  color: var(--warning);
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.role-box select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.demo-chip {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  letter-spacing: .3px;
}

/* ============ 内容区 ============ */
.content { padding: 20px 24px 40px; flex: 1; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title { font-size: 20px; font-weight: 600; line-height: 1.4; }
.page-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* ============ 卡片 ============ */
.card {
  background: var(--bg-white);
  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-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-muted); }
.card-head .head-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 5px;
  font-size: 13px;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 9px 20px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); color: var(--text); background: #fff; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  background: #fafafa;
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12.5px;
}
table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: #fafbfc; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .t-right { text-align: right; }
table.tbl .t-center { text-align: center; }
table.tbl td.col-actions { white-space: nowrap; text-align: right; }

.link-act { color: var(--primary); cursor: pointer; font-size: 12.5px; }
.link-act:hover { text-decoration: underline; }
.link-act.danger { color: var(--danger); }
.act-sep { color: var(--border); margin: 0 6px; }

.empty-row td { text-align: center; color: var(--text-light); padding: 40px 0; }

/* ============ 状态标签 ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}
.badge-gray    { background: #f3f4f6; color: #4b5563; }
.badge-blue    { background: var(--primary-light); color: var(--primary-dark); }
.badge-green   { background: var(--success-light); color: #15803d; }
.badge-orange  { background: var(--warning-light); color: #b45309; }
.badge-red     { background: var(--danger-light); color: #b91c1c; }
.badge-purple  { background: #f5f3ff; color: #6d28d9; }

/* ============ 筛选栏 ============ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  background: #fcfcfd;
}
.filter-bar .fld { display: flex; align-items: center; gap: 6px; }
.filter-bar label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.filter-bar .f-actions { margin-left: auto; display: flex; gap: 8px; }

.input, .select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  height: 32px;
}
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
.input.w-sm { width: 110px; }
.input.w-md { width: 180px; }
.input.w-lg { width: 260px; }
.select.w-sm { width: 110px; }
.select.w-md { width: 160px; }
textarea.input { height: auto; min-height: 68px; padding: 8px 10px; resize: vertical; line-height: 1.6; }

/* 搜索框（带图标） */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box .input { padding-left: 30px; }
.search-box .s-icon {
  position: absolute; left: 9px; color: var(--text-light);
  pointer-events: none; display: flex;
}

/* ============ 表单 ============ */
.form-section { margin-bottom: 22px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 7px;
}
.form-section-title .sec-no {
  width: 18px; height: 18px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 3px;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item.span-2 { grid-column: span 2; }
.form-item.span-3 { grid-column: span 3; }
.form-item.span-full { grid-column: 1 / -1; }
.form-item label { font-size: 13px; color: var(--text-muted); }
.form-item label .req { color: var(--danger); margin-left: 2px; }
.form-item .input, .form-item .select { width: 100%; }
.form-item .hint { font-size: 11.5px; color: var(--text-light); }
.form-item .ro-val {
  padding: 6px 10px;
  background: #f9fafb;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  min-height: 32px;
  color: var(--text);
  font-size: 13px;
}
.form-item .ro-val.muted { color: var(--text-light); }

.form-footer {
  display: flex;
  gap: 10px;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--border-light);
}
.form-footer .right { margin-left: auto; display: flex; gap: 10px; }

/* ============ 报价单明细 ============ */
.line-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.line-tbl th {
  background: #fafafa;
  padding: 9px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  white-space: nowrap;
}
.line-tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.line-tbl .c-idx { width: 40px; text-align: center; color: var(--text-light); }
.line-tbl .c-num { width: 78px; }
.line-tbl .c-price { width: 108px; }
.line-tbl .c-qty { width: 78px; }
.line-tbl .c-act { width: 50px; text-align: center; }
.line-tbl input.inp-sm {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.line-tbl input.inp-sm:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(37,99,235,.1); }
.line-tbl input.inp-sm.below-cost {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 600;
}
.line-tbl tr.below-cost-row td { background: #fff8f8; }
.line-tbl .t-right { text-align: right; }

.warn-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--danger-light); color: var(--danger);
  border: 1px solid #fecaca; border-radius: 3px;
  padding: 1px 6px; font-size: 11px; font-weight: 600;
}

/* 产品搜索下拉 */
.prod-search { position: relative; }
.prod-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 60;
  display: none;
}
.prod-dropdown.show { display: block; }
.prod-dropdown .pd-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.prod-dropdown .pd-item:last-child { border-bottom: none; }
.prod-dropdown .pd-item:hover { background: var(--primary-light); }
.prod-dropdown .pd-ref {
  font-size: 11.5px; color: var(--text-muted);
  background: var(--border-light); padding: 1px 6px;
  border-radius: 3px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.prod-dropdown .pd-name { flex: 1; font-size: 13px; }
.prod-dropdown .pd-price { font-size: 12.5px; color: var(--text-muted); flex-shrink: 0; }
.prod-dropdown .pd-empty { padding: 14px; text-align: center; color: var(--text-light); font-size: 13px; }

/* 合计区 */
.totals {
  display: flex;
  justify-content: flex-end;
  gap: 0;
  padding: 16px 18px;
  background: #fafbfc;
  border-top: 1px solid var(--border-light);
}
.totals-inner { min-width: 320px; }
.total-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
}
.total-row .t-label { color: var(--text-muted); }
.total-row .t-val { font-variant-numeric: tabular-nums; font-weight: 500; }
.total-row.grand {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 16px;
  font-weight: 700;
}
.total-row.grand .t-val { color: var(--primary); }
.total-row.profit .t-val { color: var(--success); }
.total-row.profit.low .t-val { color: var(--danger); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, .5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.modal-sm { max-width: 420px; }
.modal.modal-lg { max-width: 780px; }
.modal-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
}
.modal-head .m-icon { flex-shrink: 0; display: flex; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  margin-left: auto;
  background: none; border: none;
  color: var(--text-light); font-size: 20px; line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 13px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 10px;
  background: #fafbfc;
}

/* 审批提示框样式 */
.approval-box {
  border: 1px solid #fecaca;
  background: var(--danger-light);
  border-radius: 5px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.approval-box .ab-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: #b91c1c; margin-bottom: 8px;
}
.approval-box .ab-list {
  background: #fff;
  border: 1px solid #fee2e2;
  border-radius: 4px;
  font-size: 12.5px;
  max-height: 180px;
  overflow-y: auto;
}
.approval-box .ab-list table { width: 100%; border-collapse: collapse; }
.approval-box .ab-list th {
  background: #fff5f5; padding: 7px 10px; text-align: left;
  font-size: 12px; color: #991b1b; border-bottom: 1px solid #fee2e2;
}
.approval-box .ab-list td { padding: 7px 10px; border-bottom: 1px solid #fef2f2; }
.approval-box .ab-list tr:last-child td { border-bottom: none; }
.approval-box .ab-note { font-size: 12.5px; color: #7f1d1d; margin-top: 10px; line-height: 1.65; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .sc-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .sc-value { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .sc-sub { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.stat-card.accent-blue .sc-value { color: var(--primary); }
.stat-card.accent-green .sc-value { color: var(--success); }
.stat-card.accent-orange .sc-value { color: var(--warning); }
.stat-card.accent-red .sc-value { color: var(--danger); }

/* ============ 图表 ============ */
.chart-box { width: 100%; overflow-x: auto; }
.chart-svg { display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--text-muted); }
.chart-legend .lg-item { display: flex; align-items: center; gap: 6px; }
.chart-legend .lg-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ============ 报表 Tab ============ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 9px 18px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ============ 类型切换（供应商/客户） ============ */
.type-switch { display: inline-flex; background: var(--border-light); border-radius: 5px; padding: 2px; }
.type-switch .ts-item {
  padding: 5px 16px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
  background: none; border: none;
}
.type-switch .ts-item.active { background: #fff; color: var(--primary-dark); font-weight: 600; box-shadow: var(--shadow); }

/* ============ 提示条 ============ */
.alert {
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.6;
}
.alert-info { background: var(--primary-light); border: 1px solid #bfdbfe; color: #1e40af; }
.alert-warn { background: var(--warning-light); border: 1px solid #fed7aa; color: #92400e; }
.alert .a-icon { flex-shrink: 0; margin-top: 2px; }

/* ============ 客户信息自动带出 ============ */
.auto-panel {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 12px 14px;
  margin-top: 10px;
  display: none;
}
.auto-panel.show { display: block; }
.auto-panel .ap-head {
  font-size: 12px; color: var(--primary-dark); font-weight: 600;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.auto-panel .ap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  font-size: 12.5px;
}
.auto-panel .ap-grid .ap-item { display: flex; gap: 6px; }
.auto-panel .ap-grid .ap-key { color: var(--text-muted); flex-shrink: 0; }
.auto-panel .ap-grid .ap-val { color: var(--text); }

/* ============ 打印 ============ */
@media print {
  .sidebar, .topbar, .page-actions, .filter-bar, .form-footer, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
  body { background: #fff; }
}

/* ============ 响应式 ============ */
@media (max-width: 1100px) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  .sidebar { width: 60px; }
  .sidebar-logo .logo-text, .sidebar-logo .logo-sub { display: none; }
  .nav-item span.nav-label { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item .nav-badge { display: none; }
  .main { margin-left: 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}
