/* ============================================================
   油链云 · AI 智能采销一体化平台 — 设计系统
   浅色企业级主题 / 数据密集型
   ============================================================ */
:root {
  --bg: #f2f5fa;
  --panel: #ffffff;
  --panel-2: #f8fafd;
  --line: #e4e9f2;
  --line-strong: #cfd8e6;
  --text: #101b2d;
  --text-2: #43536b;
  --muted: #6f7f96;
  --faint: #95a3b8;
  --brand: #1456c8;
  --brand-2: #2f7cf6;
  --brand-soft: #eaf1fe;
  --amber: #b45309;
  --amber-soft: #fef4e6;
  --green: #0f9d58;
  --green-soft: #e8f7ef;
  --red: #d92d20;
  --red-soft: #fdecea;
  --purple: #6d3fd4;
  --purple-soft: #f0ebfd;
  --teal: #0e7c86;
  --teal-soft: #e5f5f6;
  --shadow-sm: 0 1px 2px rgba(16, 27, 45, .06);
  --shadow: 0 2px 10px rgba(16, 27, 45, .06), 0 1px 2px rgba(16, 27, 45, .04);
  --shadow-lg: 0 12px 32px rgba(16, 27, 45, .12);
  --r: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 13.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cdd6e3; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

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

.sidebar {
  width: 232px; flex: 0 0 232px; background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(140deg, #1456c8, #2f8ff6 60%, #23b7c4);
  display: grid; place-items: center; color: #fff; font-weight: 700;
  font-size: 15px; letter-spacing: -.5px;
  box-shadow: 0 4px 12px rgba(20, 86, 200, .28);
}
.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 10.5px; color: var(--faint); letter-spacing: .6px; margin-top: -1px; }

.nav { padding: 6px 10px 16px; overflow-y: auto; flex: 1; }
.nav-group { margin: 14px 0 6px; padding: 0 8px; font-size: 10.5px; font-weight: 600; color: var(--faint); letter-spacing: .8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8.5px 10px; border-radius: 9px; cursor: pointer;
  color: var(--text-2); font-size: 13.2px; font-weight: 500;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover { background: #f3f6fb; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.nav-item .ic { width: 17px; height: 17px; flex: 0 0 17px; opacity: .85; }
.nav-item.active .ic { opacity: 1; }
.nav-item .cnt {
  margin-left: auto; font-size: 10.5px; font-weight: 700; color: #fff;
  background: var(--red); border-radius: 20px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.nav-item .cnt.gray { background: #dbe2ee; color: #64748b; }
.nav-item.locked { color: #b3bfd0; }
.nav-item.locked .ic { opacity: .5; }

.sidebar-foot {
  border-top: 1px solid var(--line); padding: 12px 14px;
  font-size: 11px; color: var(--faint);
}
.sidebar-foot b { color: var(--text-2); font-weight: 600; display: block; font-size: 11.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.crumb { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.crumb b { color: var(--text); font-weight: 600; font-size: 13.5px; }
.crumb .sep { color: #cbd5e1; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.searchbox {
  display: flex; align-items: center; gap: 7px;
  background: #f3f6fb; border: 1px solid transparent; border-radius: 9px;
  padding: 6px 11px; width: 250px; color: var(--faint); font-size: 12.5px;
}
.searchbox:focus-within { background: #fff; border-color: var(--line-strong); }
.searchbox input { border: 0; background: transparent; outline: none; width: 100%; color: var(--text); font-size: 12.5px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:hover { border-color: var(--line-strong); background: #fafcff; }
.icon-btn .dot { position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); border: 1.5px solid #fff; }

.roleswitch {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px 4px 5px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.roleswitch:hover { border-color: #b9c8de; box-shadow: var(--shadow-sm); }
.roleswitch .av {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg, #1456c8, #3d86f6); color: #fff; font-size: 11px; font-weight: 700;
}
.roleswitch .who { line-height: 1.2; }
.roleswitch .who b { display: block; font-size: 12.2px; font-weight: 600; }
.roleswitch .who span { font-size: 10.5px; color: var(--faint); }

.content { padding: 20px 22px 40px; max-width: 1560px; width: 100%; }

/* ---------------- 通用组件 ---------------- */
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.2px; font-weight: 700; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; max-width: 900px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card-h {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.card-h h3 { margin: 0; font-size: 13.8px; font-weight: 650; letter-spacing: .1px; }
.card-h .sub { font-size: 11.5px; color: var(--faint); }
.card-h .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 14px 16px; }
.card-b.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-3-2 { grid-template-columns: 3fr 2fr; }

.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi .k-label { font-size: 11.8px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-val { font-size: 23px; font-weight: 700; letter-spacing: -.6px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-val small { font-size: 11.5px; font-weight: 500; color: var(--faint); margin-left: 3px; letter-spacing: 0; }
.kpi .k-foot { margin-top: 7px; font-size: 11.3px; color: var(--muted); display: block; line-height: 1.5; }
.kpi .k-foot .tag { margin-right: 4px; vertical-align: 1px; }
.kpi .k-ic { position: absolute; right: 12px; top: 12px; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 1.5px 7px; border-radius: 6px;
  background: #eef2f8; color: var(--text-2); white-space: nowrap; line-height: 1.5;
}
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.purple { background: var(--purple-soft); color: var(--purple); }
.tag.teal { background: var(--teal-soft); color: var(--teal); }
.tag.outline { background: #fff; border: 1px solid var(--line-strong); color: var(--text-2); }
.tag .d { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  border-radius: 8px; padding: 6.5px 12px; font-size: 12.5px; font-weight: 550; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #a9bad2; background: #fafcff; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 3px rgba(20,86,200,.3); }
.btn.primary:hover { background: #1049ad; border-color: #1049ad; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { padding: 4px 9px; font-size: 11.8px; border-radius: 7px; }
.btn.danger { color: var(--red); border-color: #f3c9c4; background: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.segmented { display: inline-flex; background: #eef2f8; border-radius: 9px; padding: 2.5px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 4.5px 11px; border-radius: 7px;
  font-size: 12.2px; font-weight: 550; color: var(--text-2); cursor: pointer;
}
.segmented button.on { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 12.6px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11.4px;
  padding: 9px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line);
  white-space: nowrap; letter-spacing: .2px;
}
table.tbl td { padding: 9.5px 12px; border-bottom: 1px solid #eef2f8; vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafcff; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .strong { font-weight: 650; }
table.tbl tr.best td { background: linear-gradient(90deg, rgba(20,86,200,.055), rgba(20,86,200,0) 70%); }
table.tbl tr.best td:first-child { box-shadow: inset 3px 0 0 var(--brand); }

.bar-wrap { background: #eef2f8; border-radius: 20px; height: 6px; overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; border-radius: 20px; background: var(--brand); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tnum { font-variant-numeric: tabular-nums; }
.up { color: var(--red); }       /* 涨：红 */
.down { color: var(--green); }   /* 跌：绿 */
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.lock {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; color: var(--faint); background: #f1f4f9;
  border-radius: 5px; padding: 0 5px; font-weight: 500; letter-spacing: .3px;
}

.ai-box {
  border: 1px solid #d6e3fb; border-radius: var(--r);
  background: linear-gradient(135deg, #f7fafe 0%, #f2f6ff 55%, #f6fbff 100%);
  padding: 12px 14px; position: relative;
}
.ai-box .ai-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.8px; font-weight: 700;
  color: var(--brand); letter-spacing: .4px; margin-bottom: 6px;
}
.ai-box p { margin: 0; font-size: 12.6px; color: var(--text-2); line-height: 1.7; }
.ai-box b { color: var(--text); }
.ai-box .hl { background: linear-gradient(180deg, transparent 62%, #d8e8ff 62%); padding: 0 1px; font-weight: 650; color: #0f3d8f; }

.alert-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed #e8edf5; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 26px; margin-top: 1px; }
.alert-item .txt { font-size: 12.4px; line-height: 1.5; }
.alert-item .txt b { font-weight: 600; }
.alert-item .meta { font-size: 11px; color: var(--faint); margin-top: 2px; }

.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: #fff; background: #7c8aa0; flex: 0 0 30px; }
.avatar.lg { width: 40px; height: 40px; border-radius: 11px; font-size: 14px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* 客户画像 */
.portrait-hero {
  display: flex; gap: 14px; align-items: center; padding: 16px;
  background: linear-gradient(120deg, #f7faff, #fbfdff 60%, #f4f9ff);
  border-bottom: 1px solid var(--line);
}
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); }
.metric-cell { background: #fff; padding: 11px 13px; }
.metric-cell .m-l { font-size: 11px; color: var(--muted); }
.metric-cell .m-v { font-size: 15px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }

.timeline { position: relative; padding-left: 16px; }
.timeline:before { content: ''; position: absolute; left: 3.5px; top: 4px; bottom: 4px; width: 1.5px; background: #e3eaf4; }
.tl-item { position: relative; padding: 0 0 12px; }
.tl-item:before { content: ''; position: absolute; left: -16px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #fff; border: 2px solid var(--brand-2); }
.tl-item.gray:before { border-color: #c3cedd; }
.tl-item .t { font-size: 12.4px; }
.tl-item .d { font-size: 11px; color: var(--faint); }

/* 登录门户 / 外部视角 */
.portal-banner {
  border-radius: var(--r); padding: 14px 16px; margin-bottom: 14px;
  background: linear-gradient(120deg, #0f2a52, #1657c8 55%, #1f8ad0);
  color: #fff; display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 24px rgba(15,42,82,.18);
}
.portal-banner .pb-ic { width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: 0 0 38px; }
.portal-banner h2 { margin: 0; font-size: 15.5px; font-weight: 650; }
.portal-banner p { margin: 2px 0 0; font-size: 11.8px; color: rgba(255,255,255,.78); }
.portal-banner .pb-r { margin-left: auto; text-align: right; font-size: 11.5px; color: rgba(255,255,255,.85); }

/* 权限矩阵 */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-on { color: var(--green); font-weight: 700; }
.perm-off { color: #cbd5e1; }

/* 流程闭环图 */
.flowline { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.flowstep {
  flex: 1 1 0; min-width: 150px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; position: relative; margin-right: 18px;
}
.flowstep:last-child { margin-right: 0; }
.flowstep:after {
  content: ''; position: absolute; right: -13px; top: 50%; width: 8px; height: 8px;
  border-top: 1.5px solid #b9c8de; border-right: 1.5px solid #b9c8de; transform: translateY(-50%) rotate(45deg);
}
.flowstep:last-child:after { display: none; }
.flowstep .fs-n { font-size: 10.5px; font-weight: 700; color: var(--brand); letter-spacing: .5px; }
.flowstep .fs-t { font-size: 12.8px; font-weight: 650; margin: 2px 0 3px; }
.flowstep .fs-d { font-size: 11.2px; color: var(--muted); line-height: 1.5; }

.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--red); }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  background: #101b2d; color: #fff; padding: 10px 15px; border-radius: 10px;
  font-size: 12.6px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: slidein .25s ease;
}
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(16,27,45,.45); z-index: 150;
  display: grid; place-items: center; padding: 24px; backdrop-filter: blur(2px);
}
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-h { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-h h3 { margin: 0; font-size: 14.5px; }
.modal-b { padding: 16px 18px; max-height: 70vh; overflow: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--panel-2); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.8px; color: var(--muted); margin-bottom: 4px; font-weight: 550; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 10px; outline: none; font-size: 13px; background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,124,246,.12); }
.field input[type=range] { padding: 0; border: 0; accent-color: var(--brand); }

.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row .v { font-size: 12px; font-weight: 700; color: var(--brand); width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

.hint { font-size: 11.5px; color: var(--faint); }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

.hamburger { display: none; }

@media (max-width: 1300px) {
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .g3, .g-3-2, .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
  .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------- 手机 / 平板：侧栏抽屉 + 单列布局 ---------------- */
@media (max-width: 900px) {
  .sidebar {
    display: flex; position: fixed; z-index: 80; left: 0; top: 0; bottom: 0;
    width: 268px; flex: 0 0 268px; height: 100vh; overflow-y: auto;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 0 12px 40px rgba(6, 22, 54, .18);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: none; position: fixed; inset: 0; z-index: 70;
    background: rgba(11, 22, 40, .42); backdrop-filter: blur(1.5px);
  }
  .sidebar-mask.show { display: block; }
  .hamburger {
    display: grid; place-items: center; width: 34px; height: 34px;
    border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text-2);
    margin-right: 2px; cursor: pointer;
  }
  .topbar { padding: 10px 12px !important; gap: 8px; }
  .topbar .crumb { font-size: 11.5px; line-height: 1.35; }
  .topbar .searchbox { display: none; }
  .roleswitch .who span { display: none; }
  .content { padding: 14px 12px 44px; }
  .grid.g2, .grid.g3, .grid.g4, .grid.g5 { grid-template-columns: 1fr !important; }
  .page-head { align-items: flex-start; }
  .page-head .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .page-head .actions .btn { flex: 1; justify-content: center; min-width: 120px; }
  .card-h { flex-wrap: wrap; gap: 6px; }
  .card-h .right { flex-wrap: wrap; }
  .card-b { padding: 12px; }
  .card-b.tight { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.tbl { min-width: 620px; }
  .modal { width: 96vw !important; max-height: 88vh; }
  .modal-b { padding: 14px; }
  .grid.g2 { gap: 10px !important; }
  .kpi .k-val { font-size: 19px; }
}
@media (max-width: 560px) {
  .page-head h1 { font-size: 17.5px; }
  .page-head p { font-size: 11.5px; }
  .g5 { grid-template-columns: 1fr !important; }
  .btn { padding: 7px 11px; font-size: 12px; }
  .segmented { width: 100%; overflow-x: auto; }
}
