/* =============================================================
   麦凯尔销售 CRM · 设计系统
   - 左侧图标导航 + 顶部工具条 + 卡片化内容区
   - 全部既有 class 保持兼容（app.js 依赖的钩子不变）
   ============================================================= */
:root {
  --brand: #2563eb;
  --brand-600: #1d4ed8;
  --brand-50: #eff5ff;
  --brand-100: #dbeafe;
  --ink: #1f2937;
  --ink-2: #5b6b7f;
  --ink-3: #94a3b8;
  --line: #e8edf3;
  --line-2: #eef2f7;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --r: 10px;
  --r-lg: 14px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --sh-2: 0 4px 16px rgba(16, 24, 40, .08);
  --side-w: 236px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { letter-spacing: .2px; }

/* ============ 应用外壳 ============ */
.app { display: flex; min-height: 100vh; align-items: stretch; }

/* ---- 左侧导航 ---- */
.sidebar {
  width: var(--side-w); flex: none; background: var(--card);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px; }
.side-brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff;
  font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .35);
}
.side-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-brand-text b { font-size: 15px; color: var(--ink); }
.side-brand-text i { font-style: normal; font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px 14px; }
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: #dbe3ec; border-radius: 3px; }
.nav-group { margin-bottom: 12px; }
.nav-group-title {
  font-size: 11px; color: var(--ink-3); font-weight: 600;
  letter-spacing: .6px; padding: 8px 11px 5px;
}

/* 既有 .tab 复用为侧栏导航项（app.js 依赖 .tab + data-view） */
.tab {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 2px;
  border: none; background: transparent; text-align: left; cursor: pointer;
  padding: 9px 11px; border-radius: 9px; position: relative;
  font-size: 13.5px; color: var(--ink-2); font-family: inherit;
  transition: background .14s, color .14s;
}
.tab .ti { width: 18px; height: 18px; flex: none; opacity: .85; }
.tab .tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab:hover { background: #f2f5fa; color: var(--ink); }
.tab.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.tab.active .ti { opacity: 1; }
.tab.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.side-foot {
  padding: 12px 18px; border-top: 1px solid var(--line-2);
  font-size: 11px; color: var(--ink-3);
}

/* ---- 主区 ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; min-height: 62px;
}
.tb-left { min-width: 0; }
.tb-left h1 { margin: 0; font-size: 17px; font-weight: 650; color: var(--ink); }
.tb-left p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { flex: 1; min-width: 0; }

/* 用户栏 */
.userbar { display: flex; align-items: center; gap: 10px; }
.userbar .uname { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.userbar .urole {
  background: var(--brand-50); color: var(--brand); border: 1px solid var(--brand-100);
  border-radius: 20px; padding: 2px 10px; font-size: 11.5px; font-weight: 600;
}
.userbar .ubtn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 8px; padding: 5px 12px; cursor: pointer; font-size: 12.5px; font-family: inherit;
  transition: .14s;
}
.userbar .ubtn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }

/* ============ 布局 / 卡片 ============ */
.layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; padding: 18px 24px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 18px; }
.view { padding: 18px 24px; }
.view > .panel { max-width: 1140px; }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh-1);
}
.panel h2 {
  margin: 0 0 12px; font-size: 15px; font-weight: 650; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.panel h2::before {
  content: ""; width: 4px; height: 15px; border-radius: 2px; background: var(--brand); flex: none;
}
.panel h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--brand); display: flex; align-items: center; gap: 6px; }

/* ============ 按钮 ============ */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 9px; padding: 7px 14px; cursor: pointer; font-size: 13px;
  font-family: inherit; font-weight: 500; transition: .14s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.btn:hover { border-color: #c9d6e6; color: var(--ink); background: #fafcff; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 1px 2px rgba(37, 99, 235, .22); }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c9c9; }
.btn.danger:hover { background: #fef2f2; color: var(--danger); border-color: #f0a9a9; }

.mini-btn {
  background: #fff; color: var(--danger); border: 1px solid #f3d3d3; border-radius: 8px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
  transition: .14s; align-self: center; white-space: nowrap;
}
.mini-btn:hover { background: #fef2f2; }
.mini-btn.pull { color: var(--brand); border-color: var(--brand-100); font-weight: 600; }
.mini-btn.pull:hover { background: var(--brand-50); }
.mini-btn.danger {
  color: var(--danger); border-color: #f3d3d3; border-radius: 50%;
  width: 22px; height: 22px; line-height: 1; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.mini-btn.danger:hover { background: #fef2f2; }

/* ============ 列表 / 客户卡片 ============ */
.list { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.cust {
  border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px;
  cursor: pointer; background: #fff; transition: .14s;
}
.cust:hover { border-color: var(--brand-100); box-shadow: var(--sh-1); }
.cust.active { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.cust .name { font-weight: 600; color: var(--ink); }
.cust .meta { color: var(--ink-3); font-size: 12px; margin-top: 4px; line-height: 1.5; }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; margin-left: 6px; font-weight: 500; line-height: 1.5; }
.badge.ok { background: #e7f7ed; color: #1a8f4c; }
.badge.no { background: #fdeaea; color: var(--danger); }
.badge.pool { background: #eaf1fd; color: var(--brand); }

/* ============ 表单 ============ */
.form { display: flex; flex-direction: column; gap: 11px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.form input, .form select, .form textarea {
  padding: 8px 10px; border: 1px solid #d7dee8; border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff; transition: .14s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.block { border-top: 1px solid var(--line-2); padding-top: 14px; margin-top: 14px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.6; }
.hint.warn { color: var(--danger); font-weight: 600; }

/* ============ 时间线 / 任务 ============ */
.timeline { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.task {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; background: #fff;
}
.task .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
.task.done { opacity: .6; }
.task.done .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .14); }
.task .t-main { flex: 1; min-width: 0; }
.task .t-title { font-size: 13px; color: var(--ink); }
.task .t-date { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.task.done .t-title { text-decoration: line-through; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 2000; box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 筛选器 / 勾选 ============ */
.filters { margin: 10px 0 14px; }
.filters select, .filters input {
  padding: 8px 10px; border: 1px solid #d7dee8; border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff; transition: .14s;
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.scope-hint { font-size: 12px; color: var(--ink-3); margin: 2px 0 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 8px 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; color: var(--ink-2); }

/* 作物多选管理 */
.crop-manage { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.crop-add-row { display: flex; gap: 6px; align-items: center; }
.crop-manage input { padding: 7px 9px; border: 1px solid #d7dee8; border-radius: 8px; font-size: 13px; flex: 1; font-family: inherit; }
.crop-list { display: flex; flex-wrap: wrap; gap: 6px; }
.crop-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 20px;
  padding: 3px 6px 3px 12px; font-size: 12px; color: var(--brand); font-weight: 500;
}

/* ============ 详情头 ============ */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.detail-head h2 { margin: 0; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat {
  position: relative; display: flex; align-items: center; gap: 14px; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 18px 15px 22px; box-shadow: var(--sh-1);
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: var(--r-lg) 0 0 var(--r-lg); background: var(--c, #2563eb); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c, #2563eb) 13%, #fff);
  color: var(--c, #2563eb);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-body { min-width: 0; }
.stat-v, .stat-num { font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -.5px; line-height: 1.15; }
.stat-k, .stat-label { font-size: 12px; color: var(--ink-3); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-num.pay-ok { color: var(--ok); }
.stat-num.pay-warn { color: var(--danger); }
.stats { margin-bottom: 4px; }

/* ============ 用户头像 ============ */
.userbar .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 1px 3px rgba(16, 24, 40, .15);
}

/* ============ 右侧提醒栏 ============ */
.body-row { display: flex; flex: 1; min-width: 0; align-items: stretch; }
.aside-right {
  width: 300px; flex: none; border-left: 1px solid var(--line);
  background: #fbfcfe; padding: 16px 14px; overflow-y: auto;
  position: sticky; top: 62px; height: calc(100vh - 62px);
}
.rem-head {
  display: flex; flex-direction: column; gap: 2px; padding: 2px 4px 12px;
  position: sticky; top: 0; background: #fbfcfe; z-index: 2;
}
.rem-head-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.rem-head-sub { font-size: 11px; color: var(--ink-3); }
.rem-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rem-dismiss { font-size: 11px; color: var(--brand); background: var(--brand-50); border: none; border-radius: 7px; padding: 3px 9px; cursor: pointer; transition: .15s; }
.rem-dismiss:hover { background: var(--brand); color: #fff; }
.rem-undo { color: var(--brand); cursor: pointer; text-decoration: underline; margin-left: 4px; }
.task-flash { animation: taskFlash 1.8s ease-out; }
@keyframes taskFlash {
  0% { background: #fff6cc; box-shadow: 0 0 0 2px #f5c518 inset; }
  100% { background: #fff; box-shadow: none; }
}
.rem-list { display: flex; flex-direction: column; gap: 14px; }
.rem-group { display: flex; flex-direction: column; }
.rem-group-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--ink-3); letter-spacing: .4px; margin: 0 2px 7px; }
.rem-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--brand-50); color: var(--brand); font-size: 11px; font-weight: 700; }
.rem-group .rem-item { margin-bottom: 8px; }
.rem-group .rem-item:last-child { margin-bottom: 0; }
.rem-item {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 10px; padding: 10px 11px; transition: .14s;
}
.rem-item:hover { box-shadow: var(--sh-1); border-color: #cdd8e6; }
.rem-item.over { border-left-color: var(--danger); }
.rem-item.soon { border-left-color: var(--warn); }
.rem-ic { width: 30px; height: 30px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand); }
.rem-ic svg { width: 16px; height: 16px; }
.rem-task .rem-ic { background: #eef2ff; color: #4f46e5; }
.rem-contract .rem-ic { background: #fff1e6; color: #c4621a; }
.rem-stock .rem-ic { background: #e7f7ed; color: #16a34a; }
.rem-item.over .rem-ic { background: #fdeaea; color: var(--danger); }
.rem-body { min-width: 0; }
.rem-title { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rem-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.5; }
.rem-go { align-self: center; margin-left: auto; padding-left: 6px; color: var(--ink-3); font-size: 19px; line-height: 1; opacity: .45; transition: opacity .15s, transform .15s; }
.rem-item:hover .rem-go { opacity: 1; transform: translateX(2px); color: var(--brand); }
.rem-empty { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); padding: 14px 6px; }
.rem-ok-ic { width: 22px; height: 22px; color: var(--ok); display: inline-flex; }
.rem-ok-ic svg { width: 20px; height: 20px; }

/* ============ 登录页 ============ */
.login-screen {
  position: fixed; inset: 0; z-index: 50; padding: 20px;
  background:
    radial-gradient(1100px 560px at 18% 0%, rgba(96, 165, 250, .55), transparent 60%),
    linear-gradient(135deg, #1e3a8a, #2563eb 58%, #3b82f6);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 36px 38px;
  width: 360px; max-width: 92vw; text-align: center; box-shadow: 0 24px 60px rgba(8, 20, 45, .4);
}
.login-brand { font-size: 20px; font-weight: 700; color: var(--ink); }
.login-sub { font-size: 13px; color: var(--brand); margin-top: 6px; font-weight: 500; }
.login-tip { color: var(--ink-3); font-size: 13px; margin: 18px 0; line-height: 1.6; }
.login-actions { display: flex; flex-direction: column; gap: 11px; }
.login-actions a.btn, .login-actions button.btn { display: flex; width: 100%; text-align: center; text-decoration: none; padding: 11px 14px; font-size: 14px; }
.login-foot { color: var(--ink-3); font-size: 11px; margin-top: 20px; }
/* 网页口令登录（仅 webLoginEnabled 时渲染） */
.login-actions .web-login { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.login-actions .web-login input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid #d8dee7; border-radius: 8px; outline: none; font-family: inherit;
}
.login-actions .web-login input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
.login-actions .web-login .hint { font-size: 11px; color: var(--ink-3); line-height: 1.6; text-align: left; }

/* ============ 签约管理：状态徽章 + deadline 高亮 ============ */
.badge.ct-intent { background: #eef2f7; color: #5b6b7f; }
.badge.ct-nego { background: #fff5e6; color: #b45309; }
.badge.ct-signed { background: #e7f7ed; color: #1a8f4c; }
.badge.ct-lost { background: #fdeaea; color: var(--danger); }
.badge.ct-soon { background: #fff0db; color: #c4621a; }
.badge.ct-over { background: #fde2de; color: #c0392b; }
.cust.alert { border-left: 3px solid #e0872b; }
.cust .badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-left: 4px; }

/* ============ 收款 / 回款 ============ */
.pay-summary {
  font-size: 12px; color: var(--ink-2); background: #f6f9fd;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; line-height: 1.8;
}
.pay-summary b { color: var(--ink); }
.pay-ok { color: #1a8f4c; font-weight: 600; }
.pay-warn { color: var(--danger); font-weight: 600; }
.pay-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.pay-row { display: flex; align-items: center; gap: 8px; font-size: 12px; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; }
.pay-row b { color: var(--ink); }
.pay-row .mini-btn.danger { margin-left: auto; }
#contractForm select:disabled { background: #f1f3f6; color: var(--ink-3); cursor: not-allowed; }
#contractPanel, #productPanel, #restockPanel { margin-top: 16px; border-left: 3px solid var(--brand); }

/* ============ 明细编辑器（合同 / 采购 / 出库） ============ */
.items-fs { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 6px 0; background: #fcfdff; }
.items-fs legend { font-size: 12px; color: var(--ink-2); padding: 0 8px; font-weight: 600; }
.ct-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ct-item-row { display: flex; gap: 8px; align-items: center; }
.ct-item-row .ct-item-prod { flex: 2; min-width: 0; }
.ct-item-row .ct-item-qty, .ct-item-row .ct-item-price { flex: 1; min-width: 0; }
.ct-item-sub { flex: 1; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-size: 13px; font-weight: 600; }
.ct-item-row input { flex: 1; min-width: 0; padding: 7px 9px; border: 1px solid #d7dee8; border-radius: 8px; font-size: 13px; font-family: inherit; }
.ct-item-row .mini-btn.danger { flex: none; }
.s-def-wrap { flex: none !important; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); white-space: nowrap; margin: 0; }
.s-def-wrap input { flex: none !important; width: auto; margin: 0; }
.po-item { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.po-item input, .po-item select { padding: 7px 9px; border: 1px solid #d7dee8; border-radius: 8px; font-size: 13px; font-family: inherit; min-width: 0; }
.po-prod { flex: 2; } .po-qty, .po-price { flex: 1; }
.dl-cust { font-size: 13px; color: var(--ink-2); background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.ct-total { margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.ct-total b { color: var(--brand); font-size: 16px; }
.delivery-summary { margin-bottom: 8px; }
.delivery-summary .hint { margin: 0 0 6px; }
.delivery-summary .meta { font-size: 13px; color: var(--ink-2); }

/* 出库单行：库存校验标红 */
.dl-row { flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; }
.dl-row.over-stock { background: #fef4f3; border-color: #eeb0b0; }
.dl-row.over-stock .dl-item-prod, .dl-row.over-stock .dl-item-qty { border-color: #eeb0b0; }
.dl-warn { flex-basis: 100%; color: var(--danger); font-size: 12px; margin-top: 3px; }

/* ============ 库存 ============ */
#inventoryList .badge.ct-over { background: #fde2de; color: #c0392b; }
#inventoryList .badge.ct-soon { background: #fff0db; color: #c4621a; }

/* ============ 客户完善信息 ============ */
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; }
.info-item { display: flex; gap: 8px; line-height: 1.6; }
.info-item.full { grid-column: 1 / -1; flex-direction: column; gap: 2px; }
.info-k { flex: 0 0 84px; color: var(--ink-3); font-size: 12px; }
.info-v { flex: 1; color: var(--ink); word-break: break-all; }
.badge.due-over { background: #fde2de; color: #c0392b; }
.badge.due-soon { background: #fff0db; color: #c4621a; }

/* ============ 人员权限网格 ============ */
#permChecks { padding: 8px 0; }
#permChecks .chk { min-width: 150px; }
#permChecks .chk[style*="width:100%"] { min-width: 100%; }

/* ============ 弹窗（表单浮层） ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px); display: none; z-index: 1000;
  align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto;
}
.modal-overlay.show { display: flex; }
.modal {
  position: relative; width: 700px; max-width: 100%; background: #fff; border-radius: 16px;
  box-shadow: 0 30px 80px rgba(8, 20, 45, .35);
  max-height: 87vh; display: flex; flex-direction: column;
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border: none; background: transparent; color: var(--ink-3); cursor: pointer;
  border-radius: 8px; z-index: 3; display: inline-flex; align-items: center; justify-content: center;
  transition: .14s;
}
.modal-close:hover { background: #f0f3f7; color: var(--ink); }
.modal-body { overflow-y: auto; padding: 4px 22px 22px; }
body.modal-open { overflow: hidden; }
/* 浮层内的 panel 去掉外框，作为弹窗主体 */
.modal-body > .panel { border: none; border-radius: 0; padding: 0; margin: 0; box-shadow: none; }
.modal-body > .panel > h2 { padding: 18px 40px 12px 0; }
.modal-body > .panel > .row { margin-top: 12px; }

/* ============ 跟进照片 / 灯箱 ============ */
.fu-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fu-thumb { width: 66px; height: 66px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.fu-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fu-photo {
  width: 74px; height: 74px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line);
  cursor: zoom-in; transition: transform .12s, box-shadow .12s; background: #fff;
}
.fu-photo:hover { transform: scale(1.05); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .86); display: flex; align-items: center; justify-content: center; z-index: 9999; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.lightbox .lb-close { position: absolute; top: 16px; right: 24px; color: #fff; font-size: 32px; line-height: 1; cursor: pointer; opacity: .85; }
.lightbox .lb-close:hover { opacity: 1; }

/* ============ 底部备案 ============ */
.beian { text-align: center; font-size: 12px; color: var(--ink-3); padding: 18px 12px 22px; border-top: 1px solid var(--line-2); margin-top: 20px; }
.beian a { color: var(--ink-3); text-decoration: none; }
.beian a:hover { color: var(--brand); text-decoration: underline; }

/* ============ 工作日报 ============ */
.dr { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: #fff; transition: .14s; }
.dr:hover { border-color: var(--brand-100); box-shadow: var(--sh-1); }
.dr-head { font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dr-head b { color: var(--ink); }
.dr-content { font-size: 13px; color: var(--ink); margin: 8px 0; white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.dr-meta { font-size: 12px; color: var(--ink-3); }
.dr-meta .badge { margin-right: 4px; }

/* ============ 响应式 ============ */
/* 全局：超长无空格串（产品编号/备注/客户名/合同号等）强制断行，避免把布局视口撑宽导致整页横向滚动 */
body { overflow-wrap: anywhere; }
.toast { max-width: calc(100vw - 32px); text-align: center; }

/* 平板：收起右侧提醒栏（改由窄屏直接浏览） */
@media (max-width: 1080px) {
  .aside-right { display: none; }
}

/* 窄屏 / 手机：侧栏折叠为顶部横滑导航，内容单列 */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; flex: none;
    border-right: none; border-bottom: 1px solid var(--line);
    position: static;
  }
  .side-brand { padding: 10px 14px 8px; }
  .side-brand-text i { display: none; }
  .side-foot { display: none; }
  /* 品牌行随页面滚走，导航条吸顶常驻，便于随时切换模块 */
  .side-nav {
    position: sticky; top: 0; z-index: 60;
    display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden;
    padding: 6px 12px 10px; background: var(--card);
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-group { display: flex; gap: 6px; margin: 0; }
  .nav-group-title { display: none; }
  .tab { width: auto; margin-bottom: 0; white-space: nowrap; padding: 7px 12px; gap: 7px; }
  .tab .ti { width: 16px; height: 16px; }
  .tab.active::before { display: none; }
  .topbar { position: static; padding: 10px 14px; min-height: auto; }
  .tb-left p { display: none; }
  .tb-left h1 { font-size: 17px; }
  .layout { grid-template-columns: 1fr; gap: 14px; padding: 12px 14px; }
  .view { padding: 12px 14px; }
  .info-grid { grid-template-columns: 1fr; }
}

/* 手机（≤640）：统计卡两列、筛选器两列、弹窗变底部抽屉 */
@media (max-width: 640px) {
  .panel { padding: 14px; border-radius: 12px; }

  /* 统计卡：两列、图标在上、标签可换行不截断 */
  .stat-grid, .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 12px 12px 16px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 10px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-v, .stat-num { font-size: 20px; }
  .stat-k, .stat-label { white-space: normal; font-size: 11.5px; line-height: 1.35; margin-top: 2px; }

  /* 筛选器：搜索整行，下拉两列（避免原生 select 被长选项撑宽） */
  .filters { display: flex; flex-wrap: wrap; gap: 8px; }
  .filters input, .filters select { flex: 1 1 calc(50% - 4px); min-width: 0; max-width: 100%; }
  .filters input#custSearch, .filters input#fltKw { flex: 1 1 100% !important; }
  .filters label { flex: none; white-space: nowrap; }

  /* 权限勾选铺满两列 */
  #permChecks .chk { min-width: calc(50% - 8px); }

  /* 弹窗：底部抽屉、全宽、留白收窄 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-body { padding: 4px 16px 20px; }
  .modal-body > .panel > h2 { padding: 16px 40px 10px 0; }

  /* 登录卡 */
  .login-screen { padding: 16px; }
  .login-card { padding: 28px 22px; width: 100%; }

  /* 合同/采购明细行允许换行，删除按钮靠右 */
  .ct-item-row { flex-wrap: wrap; }
  .ct-item-row .mini-btn.danger { margin-left: auto; }

  .beian { padding: 14px 12px 18px; }
}

/* 极窄屏：隐藏角色胶囊，仅留 头像 + 姓名 + 退出 */
@media (max-width: 420px) {
  .userbar .urole { display: none; }
  .side-brand-text b { font-size: 14px; }
}
