* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
}
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ===== 登录页 ===== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%); }
.auth-card { background: #fff; border-radius: 12px; padding: 36px 40px; width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.tabs { display: flex; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tabs span { flex: 1; text-align: center; padding: 10px 0; cursor: pointer; color: var(--muted); }
.tabs span.active { color: var(--primary); border-bottom: 2px solid var(--primary); margin-bottom: -2px; font-weight: bold; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.field input:focus { outline: none; border-color: var(--primary); }
.btn { display: inline-block; padding: 10px 18px; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-size: 14px; cursor: pointer; }
.btn:hover { background: var(--primary-dark); }
.btn.full { width: 100%; padding: 12px; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn.green { background: var(--green); } .btn.green:hover { background: #15803d; }
.btn.red { background: var(--red); } .btn.red:hover { background: #b91c1c; }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.tip { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; display: none; font-size: 13px; }
.msg.err { display: block; background: #fee2e2; color: var(--red); }
.msg.ok { display: block; background: #dcfce7; color: var(--green); }

/* ===== 通用布局：顶栏 + 侧栏 + 内容 ===== */
.layout { min-height: 100vh; }
.topbar { height: 56px; background: #1e293b; color: #fff; display: flex; align-items: center; padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.topbar .logo { font-size: 16px; font-weight: bold; margin-right: 40px; }
.topbar .nav { flex: 1; display: flex; gap: 8px; }
.topbar .nav a { color: #cbd5e1; text-decoration: none; padding: 8px 16px; border-radius: 8px; font-size: 14px; }
.topbar .nav a.active, .topbar .nav a:hover { background: #334155; color: #fff; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #cbd5e1; }
.topbar .who b { color: #fff; }
.badge { background: var(--red); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 10px; }
.main { display: flex; }
.sidebar { width: 200px; background: var(--card); border-right: 1px solid var(--border); padding: 16px 12px; min-height: calc(100vh - 56px); }
.side-block { margin-bottom: 20px; }
.side-block h4 { font-size: 12px; color: var(--muted); padding: 0 10px; margin-bottom: 8px; letter-spacing: 1px; }
.side-block a { display: block; padding: 9px 12px; color: var(--text); text-decoration: none; border-radius: 8px; font-size: 13px; cursor: pointer; }
.side-block a:hover { background: var(--bg); }
.side-block a.active { background: #eff6ff; color: var(--primary); font-weight: bold; }
.content { flex: 1; padding: 20px 24px; max-width: 1200px; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.page-title-row h2 { font-size: 20px; }
.page-title-row .actions { display: flex; gap: 10px; }
.page-desc { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

/* ===== 卡片/统计 ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-size: 24px; font-weight: bold; }
.stat-card .value.blue { color: var(--primary); } .stat-card .value.green { color: var(--green); }
.stat-card .value.orange { color: var(--orange); } .stat-card .value.red { color: var(--red); }

/* ===== 表格 ===== */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.panel-head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: bold; display: flex; justify-content: space-between; align-items: center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f9fafb; color: var(--muted); font-weight: normal; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.tag.pending { background: #fef3c7; color: #92400e; }
.tag.grabbed { background: #ffedd5; color: #c2410c; }
.tag.paid { background: #e0e7ff; color: #4338ca; }
.tag.processing { background: #dbeafe; color: #1d4ed8; }
.tag.done { background: #dcfce7; color: #15803d; }
.tag.cancelled { background: #f3f4f6; color: #6b7280; }
.tag.role-admin { background: #ede9fe; color: #6d28d9; }
.tag.role-runner { background: #ccfbf1; color: #0f766e; }
.tag.role-user { background: #e0f2fe; color: #0369a1; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ===== 支付弹窗 ===== */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; align-items: center; justify-content: center; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 380px; max-width: 92vw; max-height: 90vh; overflow: auto; padding: 24px; }
.modal h3 { margin-bottom: 4px; }
.modal .pay-amount { font-size: 30px; color: var(--primary); font-weight: bold; text-align: center; margin: 12px 0; }
.modal .pay-info { background: var(--bg); border-radius: 8px; padding: 12px 14px; font-size: 13px; line-height: 2; margin-bottom: 14px; }
.modal .pay-info:empty { display: none; }
.modal .pay-tip:empty { display: none; }
.modal .qr-box { text-align: center; margin-bottom: 14px; }
.modal .qr-box img, .modal .qr-box canvas { width: 250px; height: 250px; max-width: 100%; }
.modal .qr-box img { object-fit: contain; border: 1px solid var(--border); border-radius: 8px; }
.modal .qr-box .no-qr { color: var(--muted); font-size: 12px; padding: 40px 0; }
.modal .btns { display: flex; gap: 10px; }
.modal .btns .btn { flex: 1; }
.pay-tip { font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.8; }

/* ===== 支付通道选择 ===== */
.channel-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.channel-item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.channel-item:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.channel-item input { accent-color: var(--primary); }

/* ===== 表单面板 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.form-grid .field { margin: 0; }
.form-grid .full { grid-column: 1 / -1; }
/* ================= 移动端自适应（手机浏览器为主） ================= */
@media (max-width: 720px) {
  body { overflow-x: hidden; }
  /* 顶栏：保留 logo / 用户信息，主导航交给侧栏横条 */
  .topbar { height: auto; min-height: 52px; padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .topbar .logo { font-size: 14px; margin-right: auto; }
  .topbar .nav { display: none; }
  .topbar .who { font-size: 12px; gap: 8px; }
  .topbar .who b { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* 侧栏：变成可横向滑动的导航条，手机端不再隐藏 */
  .main { display: block; }
  .sidebar { display: flex; flex-wrap: wrap; align-items: center; width: 100%; min-height: 0; padding: 8px 10px; background: var(--card); border-right: none; border-bottom: 1px solid var(--border); }
  .side-block { display: contents; }
  .side-block h4 { display: none; }
  .side-block a { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; margin: 2px 6px 2px 0; border-radius: 18px; font-size: 13px; white-space: nowrap; }
  .side-block.side-status { display: none; }
  /* 内容区 */
  .content { max-width: 100%; padding: 14px 12px 28px; }
  .page-title-row { flex-wrap: wrap; gap: 8px; }
  .page-title-row h2 { font-size: 18px; }
  .page-title-row .actions { flex-wrap: wrap; }
  .page-desc { font-size: 12px; margin-bottom: 12px; }
  /* 统计卡片 */
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .value { font-size: 20px; }
  /* 表单 */
  .form-grid { grid-template-columns: 1fr; padding: 14px; gap: 12px; }
  /* 弹窗/收银台 */
  .modal { width: 96vw; max-width: 96vw; max-height: 92vh; padding: 16px; }
  .modal .pay-amount { font-size: 26px; margin: 8px 0; }
  .modal .qr-box img, .modal .qr-box canvas { width: min(70vw, 250px); height: auto; }
  .modal .btns { flex-direction: column; }
  .channel-item { font-size: 12px; }
  .ali-qr-card { padding: 10px; }
  /* 登录页 */
  .auth-wrap { padding: 18px 0; }
  .auth-card { width: 92vw; max-width: 380px; padding: 24px 20px; }
  /* 面板/表格：自动转卡片式（配合 common.js 写入的 data-label） */
  .panel { overflow: visible; }
  .panel table { display: block; }
  .panel thead { display: none; }
  .panel tbody { display: block; padding: 4px 10px 10px; }
  .panel tbody tr { display: block; border: 1px solid var(--border); border-radius: 10px; margin: 8px 0; padding: 2px 10px; background: #fff; }
  .panel td { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px dashed var(--border); text-align: right; font-size: 13px; }
  .panel tr td:last-child { border-bottom: none; }
  .panel td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: normal; flex: none; text-align: left; }
  .panel td:not([data-label])::before { content: none; }
  .panel td[colspan], .panel td.empty { display: block; text-align: center; border-bottom: none; padding: 18px 0; }
  .panel td[colspan]::before, .panel td.empty::before { content: none; }
  .panel td .btn { margin: 2px 0 2px 6px; }
  .panel td[data-label="操作"] { flex-wrap: wrap; justify-content: flex-end; }
  /* 其它 */
  .page-title-row .badge { font-size: 11px; }
  .btn { padding: 10px 16px; }
  .btn.sm { padding: 6px 12px; }
  table { font-size: 13px; }
}
@media (max-width: 380px) {
  .topbar .logo { font-size: 13px; }
  .stat-card .value { font-size: 18px; }
  .panel td { font-size: 12px; }
}


/* 支付宝收银台风格二维码区 */
.ali-qr-card { display: block; width: fit-content; margin: 0 auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; line-height: 0; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.ali-qr-card canvas, .ali-qr-card img, .ali-qr-card table { margin: 0 auto; }
.ali-qr-card canvas, .ali-qr-card img { width: 190px; height: 190px; }
.ali-pay-btn { display: block; width: 230px; margin: 14px auto 0; background: #1677ff; color: #fff; text-align: center; padding: 12px 0; border-radius: 6px; font-size: 15px; text-decoration: none; cursor: pointer; }
.ali-pay-btn:hover { background: #0958d9; }
.ali-pay-link { display: block; margin-top: 12px; color: #1677ff; font-size: 14px; text-align: center; text-decoration: none; cursor: pointer; }
.ali-pay-link:hover { text-decoration: underline; }
