/* ==========================================================
   订单管理平台样式
   ========================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1c2434;
  --text-2: #5b6b84;
  --muted: #94a0b5;
  --border: #e5eaf2;
  --primary: #4f6ef7;
  --primary-dark: #3f57e0;
  --primary-soft: #eef1fe;
  --red: #e5484d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 20px rgba(16,24,40,.05);
  --mono: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- 顶栏与导航 ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 62px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15.5px; font-weight: 700; letter-spacing: .2px; flex: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #8b5cf6); display: flex; align-items: center; justify-content: center; color: #fff; flex: none; box-shadow: 0 4px 10px rgba(79,110,247,.3); }
.brand-logo svg { width: 18px; height: 18px; }
.nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 10px; color: var(--text-2); font-size: 14px; font-weight: 500; transition: background .15s, color .15s, box-shadow .15s; }
.nav-link svg { width: 16px; height: 16px; }
.nav-link:hover { color: var(--text); background: #f0f2f7; }
.nav-link.active { color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px rgba(79,110,247,.18); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; margin-left: auto; }
.topbar-user { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13.5px; }
.topbar-user svg { width: 15px; height: 15px; color: var(--muted); }

/* ---------- 布局 ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 24px 60px; }
.container-narrow { max-width: 860px; }
/* 订单管理页：放宽容器宽度 & 卡片随内容自动撑开，确保删除按钮和所有完整列不会跑到框外面 */
.container-wide   { max-width: 1760px; }
.container-wide .card.table-card { display: inline-block; min-width: 100%; width: auto; vertical-align: top; box-sizing: border-box; overflow: hidden; }

/* ---------- 首页仪表盘 ---------- */
.dashboard-grid { display: grid; grid-template-columns: 5fr 4fr; gap: 16px; align-items: start; }
.pie-card, .recent-card { padding: 20px; }
.pie-box { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.pie-chart { flex: none; width: 220px; height: 220px; }
.pie-svg { width: 100%; height: 100%; display: block; }
.pie-slice { stroke: #fff; stroke-width: 2; transition: opacity .15s; cursor: pointer; }
.pie-slice:hover { opacity: .8; }
.pie-center-num { font-size: 26px; font-weight: 700; fill: var(--text); }
.pie-center-label { font-size: 11px; fill: var(--muted); }
/* ---------- 空数据占位 ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 20px; }
.empty-icon { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, #f4f6fb, #eef1fe); display: flex; align-items: center; justify-content: center; color: #b3bef3; margin-bottom: 16px; }
.empty-icon svg { width: 30px; height: 30px; }
.empty-title { font-size: 14.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; max-width: 260px; line-height: 1.7; }
.empty-state .btn { min-width: 120px; }

.pie-legend { list-style: none; flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.legend-value { color: var(--text-2); font-variant-numeric: tabular-nums; }
.legend-pct { color: var(--muted); font-size: 12px; width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.recent-head .card-title { margin-bottom: 0; }
.recent-list { list-style: none; display: flex; flex-direction: column; }
.recent-item { padding: 12px 2px; border-bottom: 1px solid var(--border); }
.recent-item:last-child { border-bottom: none; }
.recent-main { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.recent-no { font-weight: 600; }
.recent-sub { display: flex; align-items: center; gap: 14px; color: var(--text-2); font-size: 12.5px; flex-wrap: wrap; }
.recent-time { margin-left: auto; color: var(--muted); white-space: nowrap; }

/* ---------- 统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { color: var(--text-2); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

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

/* ---------- 筛选 ---------- */
.filter-card { padding: 14px 16px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.input { height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); background: #fff; outline: none; font-family: inherit; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.12); }
.input-kw { flex: 1; min-width: 240px; }
.filter-dates { display: flex; align-items: center; gap: 8px; }
.date-sep { color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 8px; font-size: 14px; font-weight: 500; border: 1px solid transparent; cursor: pointer; font-family: inherit; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-danger:disabled { background: #e4a8ac; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------- 表格 ---------- */
.table-card { overflow: visible; } /* 允许表格按内容宽度扩展，不再内部截断或强制滚动 */
.table-head { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-head-right { display: flex; align-items: center; gap: 12px; }
.table-head-tip { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
/* 订单表：自适应布局，列宽 = 每列最长内容宽度；7 个必填列保证完整显示 */
.orders-table { table-layout: auto; width: auto; min-width: 100%; border-collapse: separate; border-spacing: 0; }
.orders-table th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-2); background: #f8fafd; border-bottom: 1px solid var(--border); white-space: nowrap; }
.orders-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; white-space: nowrap; /* 完整显示：不换行、不截断 */ }
.orders-table tbody tr:last-child td { border-bottom: none; }
.orders-table tbody tr:hover { background: #f8fafd; }

/* 勾选列 */
.th-chk, .td-chk { padding-left: 14px; padding-right: 6px; text-align: center; white-space: nowrap; width: 1%; }
.th-chk input[type="checkbox"], .td-chk input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--primary); }

/* 必须完整显示的列（不截断，宽度由内容撑开） */
.td-time { color: var(--text-2); font-size: 12.5px; }
.td-viewer { font-size: 14px; color: var(--text); font-weight: 500; }
.td-phone { font-size: 13.5px; }
.td-ip { font-size: 12.5px; }
.td-order .order-no { font-size: 12.5px; color: var(--text); }
.td-loc .badge { white-space: nowrap; max-width: none; }
/* 圆角：table-card 打开 overflow 后，自己做表头和首行末行圆角裁剪 */
.orders-table thead th:first-child { border-top-left-radius: 0; }
.orders-table thead th:last-child  { border-top-right-radius: 0; }

/* 备注列：用户允许不显示全 → 超长截断省略，悬停看全文 */
.td-remark { color: var(--text-2); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { text-align: center; color: var(--muted); padding: 48px 0 !important; }
.td-empty { padding: 0 !important; border-bottom: none !important; overflow: visible; white-space: normal; }
.td-empty:hover { background: #fff !important; }
/* 操作列与删除按钮 */
.th-op, .td-op { text-align: center; padding-left: 2px; padding-right: 2px; }
.del-form { display: inline-flex; margin: 0; }
.btn-del { display: inline-flex; align-items: center; justify-content: center; gap: 3px; height: 26px; padding: 0 8px; border-radius: 6px; border: 1px solid #f3c4c6; background: #fff; color: var(--red); font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; transition: background .15s, color .15s; }
.btn-del:hover { background: #fdebec; }
.btn-del svg { flex: none; }

.text-muted { color: var(--muted); font-size: 12.5px; }

/* 支付链接列：“打开链接 / 二维码”上下排列，适配 10% 窄列 */
.pay-actions { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.pay-link { color: var(--primary); font-weight: 500; font-size: 12.5px; line-height: 1.3; }
.pay-link:hover { text-decoration: underline; }
.pay-qr { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--border); background: #fff; color: var(--text-2); border-radius: 5px; height: 22px; padding: 0 7px; font-size: 11.5px; cursor: pointer; font-family: inherit; line-height: 1; transition: border-color .15s, color .15s; }
.pay-qr:hover { border-color: var(--primary); color: var(--primary); }
.pay-qr svg { flex: none; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge-loc { background: var(--primary-soft); color: var(--primary); }

/* ---------- 二维码弹窗 ---------- */
.qr-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.qr-modal[hidden] { display: none !important; } /* 覆盖 display:flex，保证 HTML hidden 属性生效 */
.qr-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.qr-dialog { position: relative; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(15, 23, 42, .35); width: 320px; max-width: 92vw; overflow: hidden; animation: qrIn .18s ease-out; }
@keyframes qrIn { from { transform: translateY(10px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.qr-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text); font-size: 14px; }
.qr-close { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; border: none; background: transparent; color: var(--text-2); cursor: pointer; }
.qr-close:hover { background: #f1f4fa; color: var(--text); }
.qr-body { padding: 20px; text-align: center; }
.qr-body img { width: 240px; height: 240px; border-radius: 10px; border: 1px solid var(--border); background: #fff; display: block; margin: 0 auto 14px; }
.qr-url { font-size: 12px; color: var(--text-2); word-break: break-all; margin-bottom: 14px; line-height: 1.5; padding: 8px 10px; background: #f7f9fd; border-radius: 7px; text-align: left; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 16px; flex-wrap: wrap; }
.page-btn { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text-2); font-size: 13px; }
.page-btn:hover:not(.disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .45; pointer-events: none; }
.page-dots { color: var(--muted); padding: 0 2px; }
.page-info { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- API 说明 ---------- */
.api-card { padding: 20px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.api-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.api-label { color: var(--text-2); min-width: 72px; }
.api-row code { background: #f4f6fa; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-family: var(--mono); font-size: 12.5px; }
.api-tip { color: var(--muted); font-size: 12.5px; }
.api-params { width: 100%; border-collapse: collapse; margin: 14px 0; }
.api-params th, .api-params td { border: 1px solid var(--border); padding: 8px 12px; font-size: 13px; text-align: left; }
.api-params th { background: #f8fafd; }
.api-note { color: var(--text-2); font-size: 13px; margin: 10px 0 6px; }
.api-example { background: #101623; color: #d7e0f0; border-radius: 8px; padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; line-height: 1.7; margin-bottom: 10px; white-space: pre-wrap; word-break: break-all; }

/* ---------- 提示 ---------- */
.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; }
.alert-error { background: #fdebec; color: var(--red); border: 1px solid #f6cfd1; }

/* ---------- 登录页 ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #4f6ef7 0%, #7c5cf6 60%, #9d5af8 100%); padding: 24px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 24px 64px rgba(23,20,80,.28); padding: 40px 36px 32px; width: 100%; max-width: 400px; }
.login-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), #8b5cf6); display: flex; align-items: center; justify-content: center; color: #fff; margin: 0 auto 14px; }
.login-logo svg { width: 26px; height: 26px; }
.login-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-field .input { width: 100%; }
.login-error { background: #fdebec; color: var(--red); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; text-align: center; }
.login-warn { background: #fdf3e3; color: #b25e09; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; line-height: 1.6; word-break: break-all; }
.login-btn { width: 100%; height: 42px; font-size: 15px; margin-top: 6px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .stats { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .container { padding: 16px 16px 40px; }
  .topbar-user { display: none; }
  .brand-name { display: none; }
  .nav-link span { display: none; }
  .nav-link { padding: 0 12px; }
  .filter-form .input, .filter-form .btn, .filter-form select { flex: 1; }
  .filter-dates { width: 100%; }
  .filter-dates .input { flex: 1; }
  .page-info { margin-left: 0; width: 100%; }
  .pie-box { justify-content: center; }
}
