/* ============ 全局 ============ */
:root {
  --sidebar-w: 232px;
  --navy: #17233b;
  --navy-2: #1e2c47;
  --accent: #2f6fed;
  --accent-2: #4f8bff;
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #23304a;
  --muted: #7a8699;
  --line: #e6eaf2;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }

/* ============ 布局 ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, #101a2e 100%);
  color: #c3cede;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============ 侧边栏 ============ */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #6a5cff);
  color: #fff; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(47, 111, 237, .45);
}
.brand-name { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: #6f7d97; margin-top: 2px; letter-spacing: 1px; }

.nav-menu { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-sep {
  font-size: 11px; color: #56647e; letter-spacing: 1px;
  padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  color: #b9c5d8; font-size: 13.5px; margin-bottom: 2px;
  transition: all .15s ease;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(47,111,237,.9), rgba(47,111,237,.55));
  color: #fff;
  box-shadow: 0 4px 12px rgba(47,111,237,.35);
}
.nav-item .badge {
  margin-left: auto; background: #ff5d5d; color: #fff;
  border-radius: 20px; font-size: 11px; padding: 1px 7px; min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #2f6fed, #6a5cff);
  color: #fff; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.user-meta { min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-role { font-size: 11px; color: #7c89a3; white-space: nowrap; }
.logout { flex: 0 0 auto; color: #7c89a3; padding: 6px; border-radius: 8px; }
.logout svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.logout:hover { color: #ff6b6b; background: rgba(255,107,107,.12); }

/* ============ 顶栏 ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px 4px;
}
.page-title { font-size: 17px; font-weight: 700; margin: 0; }
.topbar-link {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted); padding: 5px 10px; border-radius: 7px;
}
.topbar-link svg { width: 15px; height: 15px; fill: currentColor; }
.topbar-link:hover { background: #e8ecf5; color: var(--accent); }

.content { padding: 10px 24px 28px; flex: 1; }

/* ============ 卡片 ============ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 1px 3px rgba(23,35,59,.05);
}
.card-h { padding: 10px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13.5px; }
.card-b { padding: 14px 16px; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; position: relative; overflow: hidden;
  box-shadow: 0 1px 3px rgba(23,35,59,.05);
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); }
.stat-card .stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-card .stat-foot { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stat-card::before {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 80px; height: 80px; border-radius: 50%; opacity: .08;
}
.stat-blue::before { background: var(--accent); }
.stat-green::before { background: var(--green); }
.stat-orange::before { background: var(--amber); }
.stat-purple::before { background: #7c3aed; }
.stat-icon { position: absolute; right: 14px; top: 12px; width: 30px; height: 30px; opacity: .9; }
.stat-icon svg { width: 100%; height: 100%; fill: var(--muted); }
.stat-blue .stat-value { color: var(--accent); }
.stat-green .stat-value { color: var(--green); }
.stat-orange .stat-value { color: var(--amber); }
.stat-purple .stat-value { color: #7c3aed; }

.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; margin-bottom: 12px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .dash-grid, .dash-grid-2 { grid-template-columns: 1fr; } }
.chart-box { height: 260px; position: relative; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
.table { margin: 0; --bs-table-hover-bg: #f6f8fd; font-size: 13px; }
.table th {
  background: #f7f9fd; color: #5a6682;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 7px 12px; vertical-align: middle; border-bottom: 1px solid #eef1f7; }
.table tbody tr:hover { background: #f6f8fd; }
.table a.order-link { color: var(--accent); font-weight: 600; }
.table a.order-link:hover { text-decoration: underline; }

/* ============ 徽章 ============ */
.badge-status { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.st-pending_manager { background: #fff4e0; color: #b45309; }
.st-pending_finance { background: #e0edff; color: #1d4ed8; }
.st-approved { background: #dcfce7; color: #15803d; }
.st-rejected { background: #fee2e2; color: #b91c1c; }
.st-returned { background: #ede9fe; color: #6d28d9; }
.st-reship_pending { background: #fef3c7; color: #b45309; }
.st-reship_approving { background: #dbeafe; color: #1e40af; }
.st-abnormal { background: #f3f4f6; color: #6b7280; }
.st-log { background: #e8ecf3; color: #475569; }
.st-cancelled { background: #e9e9f0; color: #6b7280; text-decoration: line-through; }
.st-reship { background: #fef3c7; color: #b45309; }
.st-normal { background: #e8ecf3; color: #475569; }
.row-reship td { background: #fffdf6; }
.tree-btn { border: 1px solid var(--line); background: #fff; color: #2f6fed; width: 20px; height: 20px;
            line-height: 1; border-radius: 4px; font-size: 13px; font-weight: 700; margin-right: 6px;
            cursor: pointer; vertical-align: middle; padding: 0; }
.tree-btn:hover { background: #eaf1ff; }
.tree-dash { display: inline-block; width: 20px; margin-right: 6px; }
.badge-signed { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.sg-1 { background: #dcfce7; color: #15803d; }
.sg-0 { background: #e8ecf3; color: #64748b; }
/* 物流状态徽章 */
.ls-transit { background: #e0edff; color: #1d4ed8; }
.ls-pending { background: #e8ecf3; color: #64748b; }
.ls-signed { background: #dcfce7; color: #15803d; }
.ls-customs { background: #fef3c7; color: #b45309; }
.ls-return { background: #fee2e2; color: #b91c1c; }
.ls-refund { background: #f3e8ff; color: #7c3aed; }

/* ============ 表单 ============ */
.form-label { font-size: 12.5px; font-weight: 600; color: #3c4a63; margin-bottom: 4px; }
.form-label .req { color: var(--red); margin-left: 2px; }
.form-control, .form-select {
  border-color: #dbe1ec; border-radius: 8px; font-size: 13.5px;
  padding: 6px 11px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(47,111,237,.12);
}
textarea.form-control { min-height: 68px; }
.form-text { font-size: 12px; color: var(--muted); }
.file-tip { font-size: 11px; color: var(--muted); margin-top: 3px; margin-bottom: 0; white-space: nowrap; }
.file-tip.ok { color: #16a34a; font-weight: 600; }
.input-group-text { background: #f4f6fb; border-color: #dbe1ec; border-radius: 8px; font-size: 12.5px; color: #5a6682; }

.btn { border-radius: 8px; font-size: 13px; padding: 6px 14px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #2560d6; border-color: #2560d6; }
.btn-success { background: var(--green); border-color: var(--green); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-outline-secondary { color: #5a6682; border-color: #cdd5e3; }
.btn-outline-secondary:hover { background: #eef2f9; color: #23304a; border-color: #cdd5e3; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ============ 筛选栏 ============ */
.filter-bar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
  margin-bottom: 12px;
}
.filter-bar .f-item { display: flex; flex-direction: column; gap: 3px; }
.filter-bar label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 120px; padding: 5px 9px; font-size: 12.5px; }

/* ============ 订单表单 ============ */
.section-card { margin-bottom: 12px; }
.section-title {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700;
  margin-bottom: 10px; color: var(--text);
}
.section-title::before {
  content: ''; width: 4px; height: 14px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), #6a5cff);
}
.item-row { background: #f8fafd; border: 1px solid #e3e9f3; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; position: relative; }
.img-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

/* 图片点击放大 */
.img-lightbox {
  position: fixed; inset: 0; z-index: 2000; background: rgba(10, 16, 30, .82);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.img-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.img-lightbox-close {
  position: absolute; top: 18px; right: 24px; color: #fff; font-size: 22px;
  line-height: 1; padding: 8px 12px; border-radius: 8px; background: rgba(255,255,255,.14);
}
.file-list { font-size: 12px; color: var(--muted); margin-top: 4px; }
.file-list span { display: inline-block; background: #eef2f9; border-radius: 6px; padding: 2px 8px; margin: 2px 4px 0 0; }

/* ============ 详情页 ============ */
.detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: flex; padding: 6px 0; border-bottom: 1px dashed #eef1f7; }
.kv:last-child { border-bottom: none; }
.kv .k { width: 120px; flex-shrink: 0; color: var(--muted); font-size: 12.5px; }
.kv .v { flex: 1; font-weight: 500; font-size: 13px; word-break: break-all; }
.kv .v.amount { color: var(--accent); font-weight: 700; font-size: 14px; }
.kv .v.profit-pos { color: var(--green); font-weight: 700; }
.kv .v.profit-neg { color: var(--red); font-weight: 700; }

/* 金额汇总：两列并排紧凑指标 */
.sum-grid { margin: 0 -6px; }
.sum-grid > div { padding: 0 6px; }
.kv2 { padding: 5px 0; border-bottom: 1px dashed #eef1f7; height: 100%; }
.kv2 .k { color: var(--muted); font-size: 11.5px; line-height: 1.4; white-space: nowrap; }
.kv2 .v { font-weight: 600; font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kv2 .v.amount { color: var(--accent); font-weight: 700; }
.kv2 .v.profit-pos { color: var(--green); font-weight: 700; }
.kv2 .v.profit-neg { color: var(--red); font-weight: 700; }

/* 利润「正红负绿」：盈利红色、亏损绿色（中国习惯配色） */
.profit-cn-pos { color: var(--red); font-weight: 700; }
.profit-cn-neg { color: var(--green); font-weight: 700; }
.kv .v.profit-cn-pos, .kv2 .v.profit-cn-pos { color: var(--red); font-weight: 700; }
.kv .v.profit-cn-neg, .kv2 .v.profit-cn-neg { color: var(--green); font-weight: 700; }

/* 紧凑表单：一行多列的小控件 */
.label-sm { font-size: 12px; margin-bottom: 3px; }
.file-hidden {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; overflow: hidden; clip: rect(0 0 0 0);
}
.upload-btn { cursor: pointer; white-space: nowrap; }
.img-preview { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }

/* 商品明细：上传按钮与输入框垂直对齐 */
.item-img-row .upload-btn { height: 31px; display: inline-flex; align-items: center; margin: 0; line-height: 1; }
.item-img-row .img-thumb { width: 32px; height: 32px; }
.item-img-row { min-height: 31px; }
/* 待上传图片（可逐张移除） */
.picked-item { position: relative; display: inline-flex; }
.picked-item .img-thumb { display: block; }
.picked-del {
  position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; padding: 0;
  border-radius: 50%; border: 1px solid #f2b8b8; background: #fff; color: #d9363e;
  font-size: 11px; line-height: 13px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.picked-del:hover { background: #d9363e; color: #fff; border-color: #d9363e; }

/* 金额汇总：窄栏下三列紧凑显示 */
.sum-grid-sm { margin: 0 -4px; }
.sum-grid-sm > div { padding: 0 4px; }
.sum-grid-sm .kv2 { padding: 4px 0; }
.sum-grid-sm .kv2 .k { font-size: 11px; }
.sum-grid-sm .kv2 .v { font-size: 12.5px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before {
  content: ''; position: absolute; left: 5px; top: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); border: 2px solid #d6e2ff;
}
.timeline li::after {
  content: ''; position: absolute; left: 9px; top: 16px; width: 2px; height: calc(100% - 12px);
  background: #e3e9f3;
}
.timeline li:last-child::after { display: none; }
.timeline .tl-title { font-weight: 600; font-size: 13px; }
.timeline .tl-time { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.timeline .tl-comment { font-size: 12.5px; color: #4a5872; margin-top: 4px; background: #f6f8fd; padding: 6px 10px; border-radius: 7px; }

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #101a2e 0%, #1e2c47 55%, #223a6b 100%);
  padding: 20px;
}
.login-card {
  width: 400px; background: #fff; border-radius: 18px; padding: 38px 36px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo {
  width: 58px; height: 58px; border-radius: 16px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), #6a5cff);
  color: #fff; font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(47,111,237,.4);
}
.login-title { text-align: center; font-size: 19px; font-weight: 700; }
.login-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 6px 0 24px; }
.login-hint { text-align: center; color: #8b95a8; font-size: 12px; margin-top: 18px; }

/* ============ 审批操作 ============ */
.approve-box { background: #f0f7ff; border: 1px solid #cfe3ff; border-radius: 10px; padding: 12px; }
.approve-box.reject-box { background: #fff5f5; border-color: #ffd1d1; }
textarea.approve-comment { font-size: 13px; }

/* ============ 其他 ============ */
.empty-tip { text-align: center; color: var(--muted); padding: 32px 0; }
.empty-tip .big { font-size: 36px; opacity: .35; display: block; margin-bottom: 6px; }
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.error-card { text-align: center; }
.error-code { font-size: 68px; font-weight: 800; background: linear-gradient(135deg, var(--accent), #6a5cff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount-blue { color: var(--accent); font-weight: 700; }
.pagination-x { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ============ 侧边栏收起/展开 ============ */
.sidebar-toggle {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #7c89a3;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,.1); }

.sidebar, .main { transition: margin-left .2s ease, width .2s ease; }
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand { padding: 16px 8px; justify-content: center; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-sep,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-meta { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
.sidebar.collapsed .nav-item .badge { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 1px 4px; }
.sidebar.collapsed .nav-menu { padding: 6px 8px; }
.sidebar.collapsed .sidebar-footer { flex-direction: column; gap: 8px; padding: 10px 0; }
.sidebar.collapsed .logout { margin-left: 0; }
.main.collapsed { margin-left: 64px; }

/* ============ 全局微调：统一行距与间距 ============ */
h1, h2, h3, h4, h5, h6 { line-height: 1.35; }
p { margin: 0 0 8px; }
.alert { padding: 8px 12px; font-size: 13px; margin-bottom: 10px; border-radius: 8px; }
.row { margin-bottom: 8px; }
.mb-1, .mb-2, .mb-3, .mb-4, .mb-5 { margin-bottom: 10px !important; }
/* 收紧 Bootstrap 栅格 gutter：用官方 CSS 变量，不用 flex gap（gap 会撑破 75%+25%=100% 的列宽计算，导致右侧栏掉行） */
.row { --bs-gutter-x: 14px; --bs-gutter-y: 14px; }
.row.g-2 { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
.row.g-3 { --bs-gutter-x: 14px; --bs-gutter-y: 14px; }

/* 系统日志 IP 列 */
.mono-ip { font-family: Consolas, 'Courier New', monospace; font-size: 12px; color: #475569; }
