:root {
  color-scheme: light;
  --primary: #3397FF;
  --primary-dark: #1E87DA;
  --primary-soft: #F0F8FF;
  --bg: #F2F2F2;
  --card: #FFFFFF;
  --text: #333333;
  --muted: #999999;
  --border: #ECEFF5;
  --border-2: #E6E6E6;
  --border-3: #E0E0E0;
  --success: #38D290;
  --danger: #E94242;
  --warning: #F0B92F;
  --info: #1FD1EF;
  --radius: 4px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: none; }

/* ============ 顶部导航栏 ============ */
.topbar { background: var(--card); box-shadow: 0 0 10px rgba(0,0,0,.1); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; min-width: 0; }
.brand-logo { height: 30px; width: 30px; align-self: center; object-fit: contain; flex-shrink: 0; }
.brand-name { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.brand-sub { font-size: 13px; color: var(--muted); }
.topbar-right { position: relative; display: flex; align-items: center; }
.user-btn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border-2); border-radius: 50%;
  cursor: pointer; color: #666; flex-shrink: 0;
}
.user-btn:hover { color: var(--primary); border-color: var(--primary); }
.user-btn svg { width: 20px; height: 20px; }
.user-panel {
  position: absolute; top: 48px; right: 0; z-index: 60;
  width: 200px; background: #fff; border: 1px solid var(--border-2); border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12); overflow: hidden; display: none;
}
.user-panel.open { display: block; }
.user-panel-head { padding: 14px 16px; border-bottom: 1px solid var(--border-2); }
.user-panel-name { font-size: 14px; font-weight: 600; color: var(--text); }
.user-panel-role { font-size: 12px; color: var(--muted); margin-top: 2px; }
.user-panel-item { display: flex; align-items: center; height: 44px; padding: 0 16px; font-size: 14px; color: var(--text); }
.user-panel-item:hover { background: var(--bg); color: var(--primary); }
.user-panel-item + .user-panel-item { border-top: 1px solid var(--border-2); }

/* ============ 页面标题 + Tab 菜单 ============ */
.page-head { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.page-head-inner { max-width: 1200px; margin: 0 auto; padding: 14px 20px 0; }
.page-title { font-size: 20px; font-weight: 600; color: var(--text); line-height: 1.4; }
.tabbar { display: flex; align-items: flex-start; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-top: 8px; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar a {
  position: relative; display: inline-flex; align-items: center;
  height: 40px; padding: 0 16px; white-space: nowrap; flex-shrink: 0;
  font-size: 15px; color: #666; transition: color .2s;
}
.tabbar a::before { content: ''; position: absolute; left: 16px; right: 16px; top: 0; height: 3px; background: transparent; }
.tabbar a:hover { color: var(--primary); }
.tabbar a.active { color: var(--primary); font-weight: 500; }
.tabbar a.active::before { background: var(--primary); }

/* ============ 内容区 ============ */
.container { max-width: 1200px; margin: 20px auto; padding: 0 20px; }
.flash { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #c7e4ff; padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 14px; }

/* ============ 看板卡片 ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--card); border: 1px solid var(--border-2); border-radius: 4px; padding: 18px 20px; }
.card .num { font-size: 26px; font-weight: 600; line-height: 1.2; }
.card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card.accent { border-color: #c7e4ff; background: var(--primary-soft); }

/* ============ 卡片模块 ============ */
.panel { background: var(--card); border: 1px solid var(--border-2); border-radius: 4px; padding: 20px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 16px; font-size: 15px; font-weight: 500; color: var(--text); }
.catalog-section-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border-2); }
.catalog-section-title:first-child { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 500; }

/* ============ 表格 ============ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; background: #F9FBFD; border-top: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.money { text-align: right; font-variant-numeric: tabular-nums; }

/* ============ 状态标签（药丸） ============ */
.badge { display: inline-block; padding: 0 8px; height: 20px; line-height: 20px; border-radius: 2px; font-size: 12px; white-space: nowrap; color: #fff; }
.badge.gray { background: #BFBFBF; }
.badge.blue { background: #76B3E0; }
.badge.green { background: #38D290; }
.badge.red { background: #E94242; }
.badge.orange { background: #F0B92F; }
.badge-fixed { display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 22px; padding: 0; text-align: center; line-height: 1; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 18px;
  background: var(--primary); color: #fff;
  border: 1px solid var(--primary); border-radius: 4px;
  cursor: pointer; font-family: inherit; font-size: 14px; line-height: 1;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.secondary:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn.danger { background: #D9534F; border-color: #D9534F; }
.btn.danger:hover { background: #c9302c; border-color: #c9302c; }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn:disabled { background: #CCCCCC; border-color: #CCCCCC; color: #fff; cursor: not-allowed; }

/* ============ 表单 ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; margin-bottom: 6px; color: #666; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-3); border-radius: 2px;
  font-size: 14px; font-family: inherit; background: #fff; color: #333;
}
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-3); border-radius: 2px; font-size: 14px; font-family: inherit; background: #fff; color: #333; resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[readonly], select[disabled] { background: #F5F6F9; color: #969191; }
.required { color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.form-error { display: none; background: #FFF1F0; color: var(--danger); border: 1px solid #ffccc7; padding: 9px 12px; border-radius: 2px; margin-bottom: 12px; font-size: 13px; }

/* ============ 登录页 ============ */
.login-wrap { max-width: 470px; margin: 8vh auto; padding: 0 20px; }
.login-card { background: var(--card); border: 1px solid var(--border-2); border-radius: 4px; padding: 40px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 500; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card form > div { margin-bottom: 14px; }

/* ============ 其它 ============ */
.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: 13px; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-form select, .row-form input { width: auto; min-width: 100px; height: 30px; font-size: 13px; padding: 0 10px; border-radius: 2px; }
.row-form .btn { height: 30px; font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=text] { width: 240px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }
.divider { border-top: 1px dashed var(--border-2); margin: 16px 0; }
.readonly-list { background: #F5F6F9; border: 1px solid var(--border-2); border-radius: 4px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px; }
.readonly-list div { padding: 3px 0; }
.export-fields { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.export-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: normal; margin: 0; cursor: pointer; color: var(--text); }
.export-field input { width: auto; height: auto; }
.scope-tree { border: 1px solid var(--border-2); border-radius: 4px; padding: 12px 14px; max-height: 360px; overflow-y: auto; background: #fff; }
.scope-tree.disabled { opacity: .5; pointer-events: none; }
.scope-tree label { font-weight: normal; margin: 0; color: var(--text); }
.scope-tree input[type=checkbox] { width: auto; height: auto; }
.scope-p-row { margin-bottom: 2px; }
.scope-p-label { font-weight: 600 !important; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.scope-c-list { margin-left: 20px; }
.scope-c-label { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.scope-d-list { margin-left: 20px; }
.scope-d-label { display: inline-flex; align-items: center; gap: 6px; margin: 1px 0; }
.scope-link { color: var(--primary-dark); cursor: pointer; text-decoration: underline; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-bar select, .filter-bar input, .list-pager select { width: auto; height: 34px; padding: 0 10px; border: 1px solid var(--border-3); border-radius: 2px; font-size: 13px; }
.filter-bar input[type=text] { width: 130px; }
.filter-bar input[type=date] { width: 142px; }
.filter-bar .muted { font-size: 12px; }
.filter-row { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar[data-block="delivery"] .filter-row:first-child { flex-wrap: nowrap; }
.filter-bar[data-block="delivery"] .filter-row:first-child > * { flex: 1 1 auto; }
.filter-bar[data-block="delivery"] .f-name { width: 96px; }
.filter-bar[data-block="delivery"] .f-vin, .filter-bar[data-block="delivery"] .f-phone { width: 132px; }
.col-dealer { width: 96px; min-width: 96px; }
.col-customer { width: 72px; min-width: 72px; }
.col-num { width: 56px; min-width: 56px; }
.col-phone { width: 116px; min-width: 116px; }
.col-date { width: 96px; min-width: 96px; }
.col-op { white-space: nowrap; }
.col-detail { width: 64px; min-width: 64px; }
.col-attach { width: 64px; min-width: 64px; }
.actions.nowrap { flex-wrap: nowrap; }
tr.dragging { opacity: .5; background: var(--primary-soft); }
.drag-handle { cursor: grab; color: var(--muted); font-size: 16px; user-select: none; text-align: center; }
.drag-handle:active { cursor: grabbing; }

/* ============ 经销商端页内 Tab 导航 ============ */
.dealer-tabs { display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; border-bottom: 1px solid var(--border-2); margin-bottom: 20px; }
.dealer-tabs::-webkit-scrollbar { display: none; }
.dealer-tab {
  position: relative; flex-shrink: 0; height: 44px; padding: 0 18px;
  background: none; border: none; cursor: pointer;
  font-size: 15px; color: #666; white-space: nowrap; font-family: inherit;
}
.dealer-tab::before { content: ''; position: absolute; left: 14px; right: 14px; top: 0; height: 3px; background: transparent; }
.dealer-tab:hover { color: var(--primary); }
.dealer-tab.active { color: var(--primary); font-weight: 500; }
.dealer-tab.active::before { background: var(--primary); }
.tab-panel[hidden] { display: none; }
.submit-bar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-2); }
.submit-bar .form-error { flex-basis: 100%; margin: 0 0 4px; }
.submit-bar .btn { min-width: 140px; }

/* ============ 弹窗 ============ */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; overflow-y: auto; padding: 20px; }
.modal-mask.open { display: flex; align-items: flex-start; justify-content: center; }
.modal { background: #fff; border-radius: 4px; width: 100%; max-width: 640px; margin: 4vh auto; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border-2); }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 400; color: #666; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px 22px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border-2); flex-wrap: wrap; }
.modal-foot .form-error { flex-basis: 100%; margin: 0 0 4px; }
.preview-table { width: 100%; border-collapse: collapse; }
.preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.preview-table td:first-child { color: var(--muted); width: 130px; white-space: nowrap; }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 16px; }
  .page-head-inner { padding: 12px 16px 0; }
  .filter-bar[data-block="delivery"] .filter-row:first-child { flex-wrap: wrap; }
  .filter-bar[data-block="delivery"] .filter-row:first-child > * { flex: 0 1 auto; }
  .filter-bar[data-block="delivery"] .f-name { width: 130px; }
  .filter-bar[data-block="delivery"] .f-vin, .filter-bar[data-block="delivery"] .f-phone { width: 130px; }
  .submit-bar { flex-direction: column; }
  .submit-bar .btn { width: 100%; min-width: 0; height: 44px; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .card .num { font-size: 22px; }
  .modal { margin: 2vh auto; }
  .modal-body { max-height: 60vh; }
  table { font-size: 12px; }
  th, td { padding: 9px 8px; }
  .container { padding: 0 12px; }
  .panel { padding: 14px; margin-bottom: 14px; }
  .toolbar input[type=text] { width: 100%; }
  .login-card { padding: 24px 20px; }
  .detail-fields { grid-template-columns: 1fr; }
}

/* ============ 列表分页 ============ */
.list-pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pager-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pager-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============ 详情客户卡 ============ */
.detail-modal { max-width: 900px; }
.detail-body { max-height: 70vh; }
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; background: #FAFAFA; border: 1px solid #F0F0F0; border-radius: 4px; padding: 14px 16px; }
.detail-field { display: flex; gap: 6px; font-size: 13px; }
.detail-label { color: var(--muted); flex-shrink: 0; }
.detail-value { color: var(--text); word-break: break-all; }
.detail-section-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 16px 0 10px; }

/* ============ 时间线 ============ */
.timeline { padding-left: 4px; }
.timeline-item { position: relative; padding-left: 20px; padding-bottom: 16px; border-left: 1px solid var(--border-3); margin-left: 6px; }
.timeline-item:last-child { border-left: 1px solid transparent; padding-bottom: 0; }
.timeline-dot { position: absolute; left: -6px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: #76B3E0; }
.timeline-dot.green { background: #38D290; }
.timeline-dot.red { background: #E94242; }
.timeline-dot.blue { background: #76B3E0; }
.timeline-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.timeline-text { font-size: 13px; color: var(--text); }
.timeline-time { font-size: 12px; color: var(--muted); }
.timeline-sub { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.timeline-actor { font-size: 12px; color: var(--muted); }
.timeline-meta { font-size: 12px; color: var(--muted); }

/* ============ 移动端详情页 ============ */
.detail-page { min-height: 100vh; background: var(--bg); }
.detail-nav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.detail-back { background: none; border: none; font-size: 15px; color: var(--primary); cursor: pointer; padding: 10px 0; }
.detail-nav-title { font-size: 16px; font-weight: 600; color: var(--text); }
.detail-page-body { padding-top: 16px; }

/* ============ 移动端卡片化（表格 → 卡片，仅小屏） ============ */
@media (max-width: 768px) {
  .card-table { display: block; }
  .card-table thead { display: none; }
  .card-table tbody { display: block; }
  .card-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    border: 1px solid var(--border-2);
    border-radius: 6px;
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--card);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  .card-table td {
    display: block;
    border: none;
    padding: 0;
    width: auto;
    white-space: normal;
    font-size: 13px;
    text-align: left;
  }
  .card-table .c-hide { display: none; }
  .card-table .c-seq { order: 1; color: var(--muted); font-size: 13px; flex: 0 0 auto; }
  .card-table .c-name { order: 1; font-size: 15px; font-weight: 600; color: var(--text); }
  .card-table .c-status { order: 2; margin-left: auto; }
  .card-table .c-info { order: 3; flex-basis: 100%; color: var(--text); }
  .card-table .c-info::before { content: attr(data-label); color: var(--muted); margin-right: 6px; }
  .card-table .c-detail { order: 0; flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .card-table .c-act { order: 4; flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 2px; }
  .detail-fields { grid-template-columns: 1fr; }
}

/* ============ 经销商端看板入口按钮 ============ */
.dealer-entries { display: flex; gap: 14px; margin-bottom: 8px; }
.dealer-entry {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 12px;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.dealer-entry:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(51,151,255,.14); }
.dealer-entry-icon { font-size: 32px; line-height: 1; }
.dealer-entry-name { font-size: 16px; font-weight: 600; color: var(--text); }
.dealer-entry-desc { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

@media (max-width: 768px) {
  .dealer-entries { gap: 8px; }
  .dealer-entry { padding: 18px 8px; gap: 6px; }
  .dealer-entry-icon { font-size: 26px; }
  .dealer-entry-name { font-size: 14px; }
  .dealer-entry-desc { font-size: 11px; }
}

/* ============ 武汉专项备案（管理端全局配置） ============ */
.wuhan-config { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.wuhan-config-block { border: 1px solid var(--border-2); border-radius: 4px; padding: 16px; }
.wuhan-config-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.whitelist-list { border: 1px solid var(--border-2); border-radius: 4px; padding: 10px 12px; max-height: 300px; overflow-y: auto; background: #fff; }
.whitelist-item { display: block; margin: 6px 0; font-size: 13px; color: var(--text); }
.whitelist-item input[type=checkbox] { width: auto; height: auto; margin-right: 6px; vertical-align: middle; }
.wl-province { border-bottom: 1px solid var(--border-2); }
.wl-province:last-child { border-bottom: none; }
.wl-province summary { cursor: pointer; padding: 8px 4px; font-weight: 600; color: var(--text); user-select: none; list-style: none; }
.wl-province summary::-webkit-details-marker { display: none; }
.wl-province summary::before { content: '▸'; display: inline-block; margin-right: 6px; color: var(--muted); transition: transform .15s; }
.wl-province[open] summary::before { transform: rotate(90deg); }
.wl-province-body { padding: 0 4px 8px 16px; }
@media (max-width: 768px) {
  .wuhan-config { grid-template-columns: 1fr; }
}
