:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1b2434;
  --ink-soft: #5b6779;
  --ink-mute: #8b95a7;
  --line: #e3e8f0;
  --brand: #2c62f0;
  --brand-soft: #eaf0ff;
  --ok: #12855a;
  --ok-soft: #e3f7ee;
  --warn: #b06a00;
  --warn-soft: #fff3dd;
  --danger: #c02b3a;
  --danger-soft: #fdeaec;
  --info: #1c6ea4;
  --info-soft: #e6f2fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 39, 75, .06), 0 6px 18px rgba(24, 39, 75, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------------- 侧边栏 */
.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #101828;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand small { display: block; font-weight: 400; font-size: 11px; color: #7c8ba1; letter-spacing: 0; margin-top: 2px; }

.nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: #64748b; padding: 12px 10px 6px; letter-spacing: 1px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px;
  color: #7c8ba1;
}

.sidebar-foot .who { color: #e2e8f0; font-weight: 600; font-size: 13px; }

/* ------------------------------------------------------------------ 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--ink-mute); font-size: 12.5px; margin-top: 1px; }

.content { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }

/* ------------------------------------------------------------------ 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.card-head .hint { font-size: 12.5px; color: var(--ink-mute); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ------------------------------------------------------------------ 统计 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat .label { font-size: 12.5px; color: var(--ink-mute); }
.stat .value { font-size: 23px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.stat .value.sm { font-size: 19px; }
.stat .foot { font-size: 12px; color: var(--ink-mute); margin-top: 4px; }
.stat.accent { border-left: 3px solid var(--brand); }
.stat.good { border-left: 3px solid var(--ok); }
.stat.bad { border-left: 3px solid var(--danger); }

/* ------------------------------------------------------------------ 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #344054; }
.field .tip { font-size: 12px; color: var(--ink-mute); font-weight: 400; margin-left: 6px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], input[type="email"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #d3dae6;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea { min-height: 74px; resize: vertical; }
input[type="file"] { font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid #d3dae6;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: #f7f9fc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #2453d1; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn-ok:hover { background: #0d6d49; }
.btn-danger { background: #fff; border-color: #f0c2c7; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ 表格 */
.table-wrap { overflow-x: auto; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left;
  padding: 11px 14px;
  background: #fafbfe;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  color: #475467;
  font-size: 12.5px;
  white-space: nowrap;
}

table.tbl td { padding: 11px 14px; border-bottom: 1px solid #eef2f8; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafcff; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.nowrap { white-space: nowrap; }
table.tbl .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ------------------------------------------------------------------ 标记 */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-shipped { background: var(--info-soft); color: var(--info); }
.badge-delivered { background: var(--ok-soft); color: var(--ok); }
.badge-received { background: #d8f2e6; color: #0b6b47; }
.badge-cancelled { background: #eef1f5; color: #667085; }
.badge-unpaid { background: var(--danger-soft); color: var(--danger); }
.badge-partial { background: var(--warn-soft); color: var(--warn); }
.badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-over { background: #efe6ff; color: #6b39c9; }
.badge-neutral { background: #eef1f5; color: #475467; }

.muted { color: var(--ink-mute); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }

/* ------------------------------------------------------------------ 提示条 */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: #0b6b47; border-color: #b9e6d2; }
.flash-err { background: var(--danger-soft); color: var(--danger); border-color: #f3c6cb; }

/* ------------------------------------------------------------------ 筛选栏 */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fafbfe;
}

.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters .f span { font-size: 12px; color: var(--ink-mute); }
.filters input, .filters select { padding: 6px 10px; font-size: 13px; min-width: 130px; }

/* ------------------------------------------------------------------ 分页 */
.pager { display: flex; gap: 8px; align-items: center; padding: 14px 18px; justify-content: flex-end; font-size: 13px; }
.pager a, .pager span.cur {
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
}
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.pager .info { margin-right: auto; color: var(--ink-mute); }

/* ------------------------------------------------------------------ 详情 */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.detail-item .k { font-size: 12px; color: var(--ink-mute); }
.detail-item .v { font-size: 14px; margin-top: 2px; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 4px 0 0 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid #e6ebf4; margin-left: 5px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #c6d2e6;
}
.timeline li.first::before { border-color: var(--brand); background: var(--brand); }
.timeline li.first .ctx { font-weight: 600; color: var(--ink); }
.timeline .when { font-size: 12px; color: var(--ink-mute); }
.timeline .ctx { font-size: 13.5px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb {
  width: 108px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  text-align: center;
}
.thumb img { width: 100%; height: 108px; object-fit: cover; display: block; background: #f2f4f8; }
.thumb .cap { font-size: 11.5px; padding: 5px 6px; color: var(--ink-soft); }

/* ------------------------------------------------------------------ 空状态 */
.empty { padding: 44px 20px; text-align: center; color: var(--ink-mute); font-size: 13.5px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; opacity: .35; }

/* ------------------------------------------------------------------ 登录页 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #101828 0%, #1d3a8a 60%, #2c62f0 100%);
  padding: 24px;
}

.login-box { width: 100%; max-width: 390px; background: #fff; border-radius: 16px; padding: 32px 30px 26px; box-shadow: 0 24px 60px rgba(8, 20, 50, .35); }
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box .sub { color: var(--ink-mute); font-size: 13px; margin-bottom: 22px; }
.login-foot { text-align: center; color: rgba(255, 255, 255, .7); font-size: 12px; margin-top: 18px; }

/* ------------------------------------------------------------------ 条形图 */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 0 2px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, #5b8bff, #2c62f0); border-radius: 5px 5px 0 0; min-height: 2px; }
.bar.paid { background: linear-gradient(180deg, #3fc48c, #12855a); }
.bar-lab { font-size: 11px; color: var(--ink-mute); white-space: nowrap; }
.bar-val { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

/* ------------------------------------------------------------------ 自适应 */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 7px 11px; }
  .nav-group { display: none; }
  .sidebar-foot { display: flex; justify-content: space-between; align-items: center; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .c-qty, .c-paid, .c-logi, .c-time { display: none; }
  table.tbl th, table.tbl td { padding: 9px 10px; }
}

@media (max-width: 700px) {
  .c-sales, .c-paybadge { display: none; }
  .filters { gap: 8px; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .filters .f { flex: 1 1 44%; }
}

.ship-form { flex-wrap: nowrap; align-items: center; }
