:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

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

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

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* 顶部导航 */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand span { color: var(--primary); }
.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topnav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}
.topnav a.active, .topnav a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.badge-balance { background: var(--primary-light); color: var(--primary); border-radius: 999px; padding: 4px 12px; font-weight: 600; }

/* 邮箱提醒公告弹窗 */
.announce-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.announce-dialog {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid #fed7aa;
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
  text-align: center;
}
.announce-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: #9a3412;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.announce-title { font-size: 17px; font-weight: 700; color: #9a3412; margin-bottom: 10px; }
.announce-text { color: #9a3412; font-size: 14px; line-height: 1.6; margin-bottom: 18px; }
.announce-actions { display: flex; gap: 10px; }
.announce-actions .btn { flex: 1; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 16px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.title-tabs, .title-actions { display: flex; align-items: center; gap: 12px; }
.tab-link { font-size: 14px; color: var(--muted); text-decoration: none; cursor: pointer; padding: 4px 0; margin-right: 18px; white-space: nowrap; }
.tab-link.active { color: var(--primary); font-weight: 600; }

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

.stat-card { text-align: center; padding: 18px 12px; }
.stat-card .num { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* 表单 */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control[readonly] { background: #f9fafb; color: #374151; overflow-x: auto; white-space: nowrap; }
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.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); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 验证码输入行 */
.code-row { display: flex; gap: 10px; }
.code-row .form-control { flex: 1; min-width: 0; }
.code-row .btn { flex: 0 0 auto; width: auto; white-space: nowrap; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { color: var(--muted); font-weight: 500; background: #f9fafb; white-space: nowrap; }
.data-table tr:hover td { background: #f8faff; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.tag-ok { background: #dcfce7; color: var(--ok); }
.tag-warn { background: #fef3c7; color: var(--warn); }
.tag-danger { background: #fee2e2; color: var(--danger); }
.tag-muted { background: #f3f4f6; color: var(--muted); }

.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* 金额档位选择 */
.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.amount-item {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}
.amount-item.active { border-color: var(--primary); background: var(--primary-light); }
.amount-item .price { font-size: 20px; font-weight: 700; }
.amount-item .unit { color: var(--muted); font-size: 12px; }

/* 收银台 */
.cashier { max-width: 420px; margin: 30px auto; }
.qrcode-box { text-align: center; padding: 20px 0; }
.qrcode-box img { max-width: 220px; border: 1px solid var(--border); border-radius: 10px; }
.price-big { font-size: 30px; font-weight: 700; color: var(--primary); text-align: center; }

/* 后台布局 */
.admin-layout { display: flex; min-height: 100vh; }
.admin-side {
  width: 220px;
  background: #111827;
  color: #d1d5db;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.admin-side .brand { color: #fff; padding: 18px 20px; border-bottom: 1px solid #1f2937; }
#sideNav { flex: 1; }
.admin-side a.side-logout { border-top: 1px solid #1f2937; color: #9ca3af; }
.admin-side a.side-logout:hover { color: #fff; }
.admin-side a {
  display: block;
  padding: 12px 20px;
  color: #d1d5db;
  border-left: 3px solid transparent;
}
.admin-side a.active, .admin-side a:hover { background: #1f2937; color: #fff; border-left-color: var(--primary); text-decoration: none; }
.admin-main { flex: 1; padding: 20px; overflow-x: auto; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.admin-menu-btn { display: none; width: 38px; height: 38px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font-size: 20px; line-height: 1; cursor: pointer; align-items: center; justify-content: center; }
.admin-mask { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 99; }
.admin-mask.show { display: block; }

/* 响应式 */
@media (max-width: 768px) {
  .container { padding: 0 12px; }

  /* 卡片与栅格 */
  .card { padding: 14px; margin: 10px 0; border-radius: 14px; }
  .card-title { font-size: 15px; margin-bottom: 10px; flex-direction: row; flex-wrap: nowrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
  .card-title > div, .card-title > .title-tabs, .card-title > .title-actions { min-width: 0; }
  .card-title > .btn-sm { align-self: flex-start; flex: 0 0 auto; white-space: nowrap; }
  .balance-card { padding: 14px 16px; }
  .balance-card .card-title { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .balance-card .card-title .sub { display: block; margin-top: 2px; }
  .balance-card .btn-sm { align-self: flex-start; }
  .balance-card .price-big { margin-top: 10px; }
  .grid { gap: 10px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mobile-stack, .card-stack { grid-template-columns: 1fr !important; }
  .stat-card { padding: 10px 6px; border-radius: 14px; }
  .stat-card .num { font-size: 17px; }
  .stat-card .label { font-size: 11px; }

  /* 表单与按钮 */
  .form-row { margin-bottom: 10px; }
  .form-row label { font-size: 12px; margin-bottom: 5px; }
  .form-control { height: 38px; border-radius: 10px; }
  .btn { width: 100%; height: 38px; padding: 0 14px; border-radius: 10px; font-size: 14px; }
  .btn-sm { width: auto; height: 30px; padding: 0 8px; border-radius: 8px; font-size: 12px; }
  .grid .btn { width: 100%; min-width: 0; }
  .data-table .btn { width: auto; }
  .code-row { flex-direction: column; gap: 10px; }
  .code-row .form-control { flex: 0 1 auto; width: 100%; height: 38px; }
  .code-row .btn { width: 100%; }

  /* 顶部导航 */
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .topnav { order: 3; flex: 0 0 100%; width: 100%; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; gap: 6px; }
  .topnav a { flex: 0 0 auto; white-space: nowrap; padding: 7px 8px; font-size: 12px; }
  .topbar-user { order: 2; margin-left: auto; flex: 0 0 auto; gap: 8px; }
  .badge-balance { padding: 4px 10px; font-size: 12px; }

  /* 页签与操作区 */
  .card-title { overflow-x: auto; }
  .title-tabs { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow: visible; gap: 8px; }
  .tab-link { flex: 0 0 auto; white-space: nowrap; font-size: 11px; margin-right: 8px; }
  .title-actions { flex: 0 0 auto; width: auto; justify-content: flex-end; gap: 5px; }
  .title-actions .btn { flex: 0 0 auto; }
  .title-actions .btn-sm { height: 26px; padding: 0 7px; font-size: 11px; border-radius: 7px; line-height: 1; }
  .toolbar { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .toolbar-actions { display: flex; gap: 8px; }
  .toolbar-actions .btn { flex: 1 1 auto; }

  /* 充值档位 */
  .amount-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .amount-item { padding: 12px 6px; border-radius: 12px; }
  .amount-item .price { font-size: 17px; }
  .amount-item .unit { font-size: 11px; }

  /* 表格与弹窗 */
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
  .qrcode-box img { max-width: 100%; }
  .price-big { font-size: 26px; margin-top: 8px; }

  /* 后台抽屉 */
  .admin-layout { flex-direction: row; position: relative; }
  .admin-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .2s ease;
    overflow-y: auto;
  }
  .admin-side.open { transform: translateX(0); }
  .admin-main { width: 100%; padding: 14px; }
  .admin-menu-btn { display: inline-flex; }
  .admin-side .topnav { flex-direction: row; }

  /* 记录列表：手机端只留号码和内容，内容截断，点击查看完整 */
  table.data-table .col-time, table.data-table .col-direction,
  table.data-table .col-keyword, table.data-table .col-cost { display: none; }
  table.data-table .col-content { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #recordBody tr { cursor: pointer; }
}
