:root {
  --brand: #1677ff;
  --brand-dark: #0b5fd8;
  --brand-soft: #e8f1ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #5c6470;
  --muted: #8b93a1;
  --border: #e6eaf0;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #12a150;
  --ok-soft: #e7f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e2;
  --info: #1677ff;
  --info-soft: #e8f1ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }

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

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { font-size: 12px; color: var(--muted); }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

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

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1677ff, #4a94ff);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  box-shadow: 0 8px 18px rgba(22, 119, 255, .28);
  flex: 0 0 auto;
}

.brand-mark.small { width: 36px; height: 36px; border-radius: 10px; font-size: 12px; box-shadow: none; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
}
.nav-item:hover { background: #f5f7fb; text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }

.nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: .9; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.who {
  font-size: 12px;
  color: var(--muted);
  padding-left: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 28px 12px;
}
.topbar h1 { font-size: 20px; font-weight: 600; }
.topbar-right { font-size: 13px; color: var(--muted); }

.content {
  padding: 8px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { padding: 18px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: .3px; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.trend { display: flex; align-items: stretch; gap: 14px; height: 170px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.trend-bar-wrap { flex: 1; display: flex; align-items: flex-end; width: 100%; }
.trend-bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #7cabff, #2b6de5);
  transition: height .3s ease;
}
.trend-bar-today { background: linear-gradient(180deg, #34d399, #12b76a); }
.trend-value { margin-top: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.trend-day { font-size: 12px; color: var(--muted); white-space: nowrap; }

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

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

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 680px; }
.table.compact { min-width: 720px; }
.table th, .table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: #f7f9fc;
  color: var(--text-2);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}
.table th.num { text-align: right; }
.table td.num { text-align: right; }
.table tbody tr:nth-child(even) { background: #fafbfd; }
.table tbody tr:hover { background: #f3f7ff; }
.table tbody tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 26px 12px !important; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.6;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: #f1f3f6; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: #cfd6e2; background: #fafbfd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(22, 119, 255, .22); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.tiny { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.danger-ghost { color: var(--danger); border-color: #f3c9ca; background: #fff; }
.btn.danger-ghost:hover { background: var(--danger-soft); border-color: #eaa; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 表单 ---------- */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .12);
}
textarea { resize: vertical; min-height: 90px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field > span { font-weight: 500; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span { white-space: nowrap; }
.field.inline input, .field.inline select { width: auto; min-width: 140px; }
.field.grow { flex: 1; min-width: 180px; }
.field.grow input { width: 100%; }

.narrow { width: 110px !important; }
.tiny-num { width: 76px !important; }
.input { width: 100%; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack .btn { align-self: flex-start; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form .btn { margin-bottom: 1px; }

.mm-inputs { display: flex; align-items: center; gap: 6px; }
.mm-inputs .input { width: 80px; }
.mm-inputs span { color: var(--muted); }

/* ---------- 订单详情 ---------- */
.crumbs { font-size: 13px; }

.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv span { font-size: 12px; color: var(--muted); }
.kv b { font-weight: 500; word-break: break-all; }
.price { color: var(--brand); font-size: 16px; font-weight: 650; }

.alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.alert.warn { background: var(--warn-soft); color: #93560a; }
.alert.danger { background: var(--danger-soft); color: #b42318; }

.row-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row-actions.between { justify-content: space-between; align-items: center; }

.job-list { display: flex; flex-direction: column; gap: 10px; }
.job-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 10px;
}
.job-line .num { font-weight: 600; }

.hint { margin: 8px 0 0; }
.page-foot { margin: 0; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-btns { display: flex; gap: 8px; }
.page-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.page-btn:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.page-btn.disabled { color: #c2c8d2; background: #fafbfc; cursor: not-allowed; }

/* ---------- 计价设置 ---------- */
.pricing-form { display: flex; flex-direction: column; gap: 16px; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -6px 20px rgba(16, 24, 40, .06);
  flex-wrap: wrap;
}

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 20% 0%, #e8f1ff 0%, #f4f6fa 55%, #f4f6fa 100%);
}

.login-wrap { width: 100%; max-width: 400px; }

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .1);
  text-align: center;
}
.login-card .brand-mark { margin: 0 auto 16px; }
.login-card h1 { font-size: 22px; font-weight: 650; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.login-card .stack { text-align: left; }
.login-tip { font-size: 12px; color: var(--muted); margin: 18px 0 0; line-height: 1.6; }

/* ---------- 加载 / 提示 ---------- */
.loading { padding: 32px 0; text-align: center; color: var(--muted); font-size: 13px; }

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  padding: 11px 16px;
  border-radius: 10px;
  background: #1f2329;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .22);
  animation: toast-in .18s ease-out;
}
.toast.error { background: #c9333a; }
.toast.success { background: #12844a; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 900;
  animation: fade-in .15s;
}
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .24);
}
.modal-text { margin: 0 0 18px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
  }
  .brand { padding: 0; flex: 0 0 auto; }
  .brand-text { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; margin: 0; gap: 4px; flex: 1; min-width: 0; }
  .nav-item { padding: 8px 10px; white-space: nowrap; font-size: 13px; flex: 0 0 auto; }
  .nav-icon { display: none; }
  .sidebar-foot { border-top: 0; padding-top: 0; flex-direction: row; align-items: center; flex: 0 0 auto; }
  .sidebar-foot .who { display: none; }

  .topbar { padding: 14px 16px 8px; }
  .topbar h1 { font-size: 18px; }
  .content { padding: 6px 16px 32px; gap: 12px; }
  .card { padding: 14px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 22px; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .filters { flex-direction: column; align-items: stretch; }
  .field.inline { flex-direction: column; align-items: stretch; }
  .field.inline input, .field.inline select { width: 100%; min-width: 0; }
  .field.grow { min-width: 0; }
  .filter-actions { margin-left: 0; }
  .filter-actions .btn { flex: 1; }

  .inline-form { flex-direction: column; align-items: stretch; }
  .sticky-actions { position: static; }

  .login-card { padding: 26px 20px; }
  .table { min-width: 620px; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
}
