* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #e8f8ef;
  --danger: #fa5151;
  --warning: #ffc300;
  --text: #333;
  --text-light: #888;
  --bg: #f0f2f5;
  --white: #fff;
  --border: #e5e5e5;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --sidebar-w: 220px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* -------------------------------------------
   通用组件
   ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 28px; border: none; border-radius: 8px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; text-decoration: none; gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #b0ecc6; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn-block { width: 100%; }

.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.input-group .hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.input-field {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 15px; transition: border-color 0.2s; outline: none;
}
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(7,193,96,0.1); }
.input-lg { font-size: 20px; padding: 14px 16px; }

/* 人民币参考显示 */
.rmb-hint {
  font-size: 13px; color: var(--text-light); margin-top: 4px;
  padding-left: 2px; font-weight: 500;
}
.pos-rmb-hint {
  text-align: center; font-size: 14px; color: var(--text-light);
  margin-top: 4px; font-weight: 500;
}

.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0.8);
  background: rgba(0,0,0,0.78); color: #fff; padding: 14px 28px; border-radius: 10px;
  font-size: 15px; z-index: 9999; opacity: 0; pointer-events: none;
  transition: all 0.25s; text-align: center; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-state p { font-size: 15px; }

/* utils */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 20px; }
.text-muted { color: var(--text-light); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ===========================================
   POS 收银台 - 收银键盘模式
   =========================================== */
.pos-body {
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 420px;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
}

/* 金额显示屏 */
.pos-display {
  background: linear-gradient(135deg, #16213e, #0f3460);
  padding: 20px 24px 16px;
  color: #fff;
}
.pos-display-top {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.pos-store-name { font-size: 14px; opacity: 0.7; }
.pos-admin-link { color: rgba(255,255,255,0.5); font-size: 13px; text-decoration: none; }
.pos-amount-area {
  display: flex; align-items: baseline; gap: 8px;
  padding: 16px 0 8px;
}
.pos-currency { font-size: 24px; opacity: 0.7; }
.pos-amount { font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.pos-order-info { font-size: 13px; opacity: 0.5; }

/* 支付方式切换（已废弃，自动识别） */

/* 数字键盘 */
.pos-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #2a2a3e;
  flex: 1;
}
.kp-btn {
  display: flex; align-items: center; justify-content: center;
  border: none; background: #1a1a2e; color: #fff;
  font-size: 24px; font-weight: 600; cursor: pointer;
  padding: 18px 0; transition: background 0.1s;
  min-height: 64px;
  user-select: none;
}
.kp-btn:active { background: #2a2a4e; }
.kp-zero { grid-column: span 1; }
.kp-clear { color: #ff6b6b; font-size: 18px; }
.kp-pay { background: var(--primary); color: #fff; font-size: 18px; font-weight: 700; }
.kp-pay:active { background: var(--primary-dark); }
.kp-utils { font-size: 14px; color: rgba(255,255,255,0.5); }
.kp-utils-last { font-size: 13px; }

/* POS 弹出层 */
.pos-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px;
}
.pos-overlay-content {
  background: #fff; border-radius: 16px; padding: 32px 24px;
  max-width: 340px; width: 100%; text-align: center;
}
.pos-overlay-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.pos-overlay-order { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.pos-overlay-amt { font-size: 28px; font-weight: 800; color: var(--primary); margin: 8px 0; }
.pos-overlay-status { font-size: 15px; color: var(--warning); margin: 8px 0; }
.pos-qr-box {
  background: #fff; display: inline-block; padding: 12px;
  border-radius: 12px; border: 2px solid var(--border); margin-bottom: 8px;
}
.pos-success-icon { font-size: 64px; line-height: 1; margin-bottom: 8px; }

/* ===========================================
   后台管理 - 左右布局
   =========================================== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1); padding: 36px 32px;
  max-width: 380px; width: 100%;
}
.login-logo { text-align: center; font-size: 48px; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 28px; }

/* 主体左右布局 */
.admin-layout {
  display: flex; min-height: 100vh;
}

/* 左侧边栏 */
.admin-sidebar {
  width: var(--sidebar-w); background: #1a1a2e; color: rgba(255,255,255,0.8);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
  z-index: 200; transition: transform 0.25s;
}
.sidebar-header {
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo { font-size: 18px; font-weight: 700; color: #fff; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; color: rgba(255,255,255,0.6); text-decoration: none;
  font-size: 15px; cursor: pointer; transition: all 0.15s;
  border: none; background: none; width: 100%; text-align: left;
}
.side-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.side-item.active { background: rgba(7,193,96,0.12); color: var(--primary); font-weight: 600; }
.side-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06); padding: 8px 0;
}
.side-logout { color: rgba(255,107,107,0.7); font-size: 14px; }
.side-logout:hover { color: #ff6b6b; }

/* 右侧主内容 */
.admin-main {
  flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column;
  min-height: 100vh;
}

.main-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04); position: sticky; top: 0; z-index: 100;
}
.main-header h2 { font-size: 18px; font-weight: 700; }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; }

.main-content { flex: 1; padding: 24px; overflow-y: auto; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; text-align: center;
}
.stat-card.stat-date { padding: 16px 12px; position: relative; }
.stat-label { font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-sub { font-size: 12px; color: var(--text-light); margin-top: -4px; }
.stat-amount-sm { font-size: 15px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.stat-success .stat-value { color: var(--primary); }
.stat-amount .stat-value { color: var(--primary); }
.stat-info .stat-value { font-size: 16px; }
.stat-info .stat-value.pending { color: var(--warning); }

/* 新付款通知 */
.new-pay-alert {
  display: none; align-items: center; justify-content: center; gap: 8px;
  position: fixed; top: 16px; right: 24px;
  background: var(--primary); color: #fff;
  padding: 12px 24px; border-radius: 10px;
  font-size: 15px; font-weight: 700;
  box-shadow: 0 4px 16px rgba(7,193,96,0.35);
  z-index: 999;
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s;
}
.new-pay-alert.show {
  transform: translateY(0);
  opacity: 1;
}
.stat-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; text-align: center;
}
.stat-label { font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-success .stat-value { color: var(--primary); }
.stat-amount .stat-value { color: var(--primary); }
.stat-info .stat-value { font-size: 16px; }

/* 支付表单 */
.pay-form { max-width: 360px; }

/* 订单列表行 */
.order-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.order-row:last-child { border-bottom: none; }
.order-left { flex: 1; min-width: 0; }
.order-no-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.order-no { font-size: 13px; font-weight: 600; word-break: break-all; }
.order-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.order-remark { font-size: 12px; color: var(--text-light); margin-top: 2px; padding-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.order-remark:before { content: "备注: "; color: var(--text-light); }
.order-right { text-align: right; flex-shrink: 0; }
.order-amount { font-weight: 700; }
.order-status { font-size: 13px; margin-top: 2px; }
.order-status.pending { color: var(--warning); }
.order-status.success { color: var(--primary); }
.order-status.closed { color: var(--text-light); }
.order-status.failed { color: var(--danger); }

/* 来源标签 */
.source-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px; line-height: 1.4;
}
.source-badge.admin { background: #e8f0fe; color: #1967d2; }
.source-badge.pos { background: var(--primary-light); color: var(--primary-dark); }

/* 配置 */
.config-badge {
  padding: 12px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; margin-bottom: 16px;
}
.config-ok { background: var(--primary-light); color: var(--primary-dark); }
.config-warn { background: #fff3cd; color: #856404; }
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px;
}

/* 账号管理：左右分栏 */
.user-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.user-grid .card {
  margin-bottom: 0;
}
.user-grid .btn-block {
  margin-top: 4px;
}

/* 分页 */
#pagination { padding: 12px 0 0; }

/* ===========================================
   响应式
   =========================================== */
@media (max-width: 860px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main { margin-left: 0; }
  .menu-toggle { display: block; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .pos-amount { font-size: 42px; }
  .kp-btn { min-height: 56px; font-size: 22px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
}
