/* ===================== 基础变量（浅色主题） ===================== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --border: #e4e8f0;
  --border-strong: #d3dae6;
  --text: #1e293b;
  --text-2: #55637a;
  --muted: #8b97ab;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --green: #14a06a;
  --green-soft: #e6f7f0;
  --amber: #d98613;
  --amber-soft: #fdf3e2;
  --red: #dc3545;
  --red-soft: #fdecee;
  --purple: #7c5cff;
  --purple-soft: #f0ecff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .14);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .3);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d5dbe6; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #c2cad9; }

/* ===================== 登录页 ===================== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 12% -10%, #e5edff 0%, rgba(229,237,255,0) 60%),
    radial-gradient(800px 500px at 92% 110%, #e9fbf4 0%, rgba(233,251,244,0) 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 30px 26px;
  box-shadow: var(--shadow-lg);
}

.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; letter-spacing: .2px; }
.login-brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }

.brand-logo {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, #2563eb, #7c5cff);
  color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, .7);
}
/* 品牌位使用真实图标（PWA 图标 192px 源），白底与浅色页面融为一体 */
img.brand-logo { object-fit: cover; background: #fff; }
.brand-logo.sm { width: 30px; height: 30px; flex-basis: 30px; border-radius: 9px; font-size: 15px; box-shadow: none; }

.login-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
textarea { resize: vertical; min-height: 72px; }

.login-error {
  background: var(--red-soft);
  color: #a01c2b;
  border: 1px solid #f6cdd2;
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 12.5px;
}

.demo-accounts { margin-top: 24px; padding-top: 18px; border-top: 1px dashed var(--border-strong); }
.demo-title { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.demo-list { display: flex; flex-wrap: wrap; gap: 7px; }
.demo-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}
.demo-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.demo-chip b { color: var(--text); font-weight: 600; }

/* ===================== 顶栏 ===================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  height: 60px;
  padding: 0 22px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-name { font-weight: 650; font-size: 15px; white-space: nowrap; }

.topnav { display: flex; gap: 2px; margin-left: 8px; }
.nav-item {
  position: relative;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f1f4f9; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  margin-left: 4px;
  background: var(--red); color: #fff;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  vertical-align: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #7c5cff);
  color: #fff; font-size: 13px; font-weight: 600;
}
.user-meta { line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 600; }
.user-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.role-badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--purple-soft);
  color: #5b3fd6;
  font-size: 11px;
}

/* ===================== 布局 ===================== */
.main { max-width: 1240px; margin: 0 auto; padding: 22px 22px 60px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-title { font-size: 19px; }
.page-desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ===================== 卡片 ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

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

/* 统计卡 */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 24px; font-weight: 680; margin-top: 6px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stat .value .unit { font-size: 13px; font-weight: 500; color: var(--text-2); margin-right: 2px; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stat.accent-blue { border-top: 3px solid var(--primary); }
.stat.accent-amber { border-top: 3px solid var(--amber); }
.stat.accent-green { border-top: 3px solid var(--green); }
.stat.accent-purple { border-top: 3px solid var(--purple); }

/* ===================== 按钮 ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: #fff;
  color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -10px rgba(37,99,235,.9); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #10855a; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c02b3a; }
.btn-danger-ghost { border-color: #f3c9ce; color: var(--red); background: #fff; }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }

/* ===================== 徽章 ===================== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.draft    { background: #eef1f6; color: #64748b; }
.pill.pending  { background: var(--amber-soft); color: #a3670a; }
.pill.approved { background: var(--green-soft); color: #0f7d53; }
.pill.rejected { background: var(--red-soft); color: #b8202f; }
.pill.paid     { background: var(--primary-soft); color: #1b4fd0; }

.tag {
  display: inline-block; padding: 1px 8px;
  border-radius: 6px; font-size: 11.5px;
  background: #f1f4f9; color: var(--text-2);
}
.tag.cat { background: var(--purple-soft); color: #5b3fd6; }

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--text-2);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12.5px;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #f8fafd; }
table.tbl tbody tr.clickable { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.cell-title { font-weight: 550; }
.cell-sub { font-size: 11.5px; color: var(--muted); }

.empty {
  padding: 46px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.empty .icon { font-size: 30px; display: block; margin-bottom: 8px; opacity: .55; }

/* ===================== 筛选栏 ===================== */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.filters .field-inline {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2);
  white-space: nowrap; flex: 0 0 auto;
}
.filters select, .filters input { padding: 6px 9px; font-size: 12.5px; }
.filters input[type="date"] { width: 138px; }
.filters .grow { flex: 1 1 160px; }

/* ===================== 明细表单 ===================== */
.items-editor { display: grid; gap: 8px; }
.item-row {
  display: grid;
  grid-template-columns: 130px 130px 150px 1fr 34px;
  gap: 8px; align-items: center;
}
.item-row .row-num {
  display: none;
}
.items-head {
  display: grid;
  grid-template-columns: 130px 130px 150px 1fr 34px;
  gap: 8px; align-items: center;
  font-size: 12px; color: var(--muted);
  padding: 0 0 4px;
}
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: #fff;
  color: var(--text-2); cursor: pointer; font-size: 15px; line-height: 1;
  display: grid; place-items: center;
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }

.items-total {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 8px;
  padding: 12px 2px 2px; border-top: 1px dashed var(--border-strong); margin-top: 6px;
  font-size: 13px; color: var(--text-2);
}
.items-total b { font-size: 19px; color: var(--primary-dark); font-variant-numeric: tabular-nums; }

/* ===================== 附件 ===================== */
.attach-list { display: flex; flex-wrap: wrap; gap: 10px; }
.attach-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--surface-2);
  min-width: 190px; max-width: 260px;
}
.attach-thumb {
  width: 38px; height: 38px; border-radius: 6px; object-fit: cover;
  background: #eef1f6; flex: 0 0 38px;
  display: grid; place-items: center; font-size: 17px; color: var(--text-2);
  overflow: hidden;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-meta { min-width: 0; }
.attach-name {
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-sub { font-size: 11px; color: var(--muted); }
.attach-del {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid #f3c9ce; background: #fff; color: var(--red);
  font-size: 12px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.attach-del:hover { background: var(--red); color: #fff; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px;
  cursor: pointer; transition: all .15s; background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* ===================== 审批时间线 ===================== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -24px; top: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--border-strong);
}
.tl-item.done .tl-dot { border-color: var(--green); background: var(--green); }
.tl-item.rejected .tl-dot { border-color: var(--red); background: var(--red); }
.tl-item.current .tl-dot { border-color: var(--amber); background: #fff; box-shadow: 0 0 0 4px var(--amber-soft); }
.tl-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tl-comment {
  margin-top: 6px; font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 6px; padding: 6px 10px;
}

/* 步骤链 */
.step-chain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-node {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 4px 12px 4px 8px; font-size: 12.5px; background: #fff;
}
.step-node .idx {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}
.step-arrow { color: var(--muted); font-size: 13px; }

/* ===================== 图表 ===================== */
.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }

/* ===================== 模态框 ===================== */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(23, 32, 48, .42);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 18px;
  overflow-y: auto;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 720px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.2,.8,.3,1);
  margin: auto 0;
}
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: .6 } to { transform: none; opacity: 1 } }
.modal.wide { max-width: 900px; }
.modal.narrow { max-width: 480px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 17px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-close {
  border: none; background: transparent; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { background: #f1f4f9; color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 64vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 15px 22px; border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
  flex-wrap: wrap;
}
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; }

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }

/* ===================== Toast ===================== */
.toast-root {
  position: fixed; top: 74px; right: 22px; z-index: 200;
  display: grid; gap: 9px;
}
.toast {
  min-width: 220px; max-width: 380px;
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 11px 15px;
  font-size: 13px;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(16px); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast.fade-out { animation: slideOut .25s ease forwards; }
@keyframes slideOut { to { transform: translateX(16px); opacity: 0 } }

/* ===================== 工具类 ===================== */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0 } .mt-8 { margin-top: 8px } .mt-12 { margin-top: 12px } .mt-16 { margin-top: 16px }
.mb-0 { margin-bottom: 0 } .mb-8 { margin-bottom: 8px } .mb-16 { margin-bottom: 16px }
.spacer { flex: 1 }
.nowrap { white-space: nowrap }
.text-green { color: var(--green) } .text-red { color: var(--red) } .text-amber { color: var(--amber) }
.qty-input { width: 76px; text-align: right }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--primary); }

/* ===================== 弹窗滚动锁 ===================== */
body.no-scroll { overflow: hidden; }

/* ===================== 图表容器（窄屏可被媒体查询重排） ===================== */
.donut-wrap { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }
.donut-box { flex: 0 0 210px; max-width: 210px; }
.donut-legend { flex: 1 1 260px; flex-direction: column; gap: 7px; }

.hbar-row { display: grid; grid-template-columns: 110px 1fr 96px; gap: 10px; align-items: center; padding: 6px 0; }
.hbar-row .hbar-label { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-row .hbar-track { background: #f1f4f9; border-radius: 6px; height: 20px; position: relative; overflow: hidden; }
.hbar-row .hbar-fill { height: 100%; opacity: .88; border-radius: 6px; }
.hbar-row .hbar-value {
  font-size: 12px; color: var(--text); font-weight: 600;
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* ===================== 触屏基础（全局） ===================== */
* { -webkit-tap-highlight-color: transparent; }
button, .btn, .nav-item, .demo-chip, .icon-btn, .attach-del, .dropzone { touch-action: manipulation; }

/* ===================== 响应式 · 平板 ===================== */
@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .main { padding: 16px 14px 48px; }
  .modal-mask { padding: 20px 12px; }
}

/* ===================== 响应式 · 手机 ===================== */
@media (max-width: 768px) {
  /* ---------- 顶栏：单行紧凑 + 底部导航 ---------- */
  .topbar {
    height: auto; min-height: 54px;
    flex-direction: row; align-items: center;
    gap: 8px;
    padding: 6px 12px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    /* 关键：backdrop-filter 会让 .topbar 成为 fixed 后代的包含块，
       导致里面的底部导航被钉在顶栏里而不是屏幕底部（真机同样如此）。
       手机上改用不透明背景，去掉该属性。 */
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .topbar-left { flex: 1 1 auto; flex-wrap: nowrap; gap: 8px; min-width: 0; }
  .brand-name { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; }
  .brand-logo.sm { width: 27px; height: 27px; flex-basis: 27px; font-size: 14px; }
  .topbar-right { gap: 7px; }
  .user-sub { display: none; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
  #logout-btn { min-height: 34px; padding: 6px 11px; font-size: 12.5px; }

  /* 主菜单移到底部固定栏：拇指可达，不再挤压顶栏 */
  .topnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; margin: 0; gap: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -6px 22px -14px rgba(16, 24, 40, .45);
  }
  .nav-item {
    position: relative;
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1px; height: 56px; padding: 5px 2px;
    border-radius: 0; font-size: 11px; line-height: 1.2;
  }
  .nav-item::before { font-size: 17px; line-height: 1.05; }
  .nav-item[data-tab="records"]::before { content: "📋"; }
  .nav-item[data-tab="lessons"]::before { content: "🕐"; }
  .nav-item[data-tab="reports"]::before { content: "📊"; }
  .nav-item[data-tab="users"]::before { content: "👥"; }
  /* 触屏无 hover，去掉粘滞的高亮态 */
  .nav-item:hover { background: transparent; color: var(--text-2); }
  .nav-item.active { background: transparent; color: var(--primary-dark); font-weight: 650; }
  .nav-item.active:hover { color: var(--primary-dark); }
  .nav-item.active::after {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
  }

  /* ---------- 布局 ---------- */
  .main { padding: 14px 12px calc(76px + env(safe-area-inset-bottom, 0px)); }
  .page-head { flex-direction: column; align-items: stretch; gap: 11px; margin-bottom: 14px; }
  .page-title { font-size: 17.5px; }
  .page-desc { font-size: 12px; }
  .page-actions { flex-wrap: wrap; align-items: stretch; gap: 8px; }
  .page-actions .btn { flex: 1 1 auto; min-height: 42px; }
  .page-actions .field-inline {
    flex: 1 1 100%; min-width: 0;
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
  }
  .page-actions .field-inline select { flex: 1 1 auto; min-width: 0; max-width: 62%; }
  /* 日期控件带固有宽度（约 161px），两个并排时会把布局视口撑宽到 362px，
     移动端 Chrome 会因此扩大 layout viewport，导致底部固定导航右半边跑到屏外点不到。
     这里把宽度归零交给 flex 分配，从源头消除溢出。 */
  .page-actions .field-inline input[type="date"] { flex: 1 1 0; width: 0; min-width: 0; }

  .card-head { padding: 12px 14px; gap: 8px; }
  .card-head h3 { font-size: 14px; }
  .card-head .hint { font-size: 11.5px; }
  .card-body { padding: 14px; }
  .grid { gap: 12px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 13px 14px; }
  .stat .value { font-size: 20px; }
  .stat .label { font-size: 12px; }

  /* ---------- 输入控件：16px 防 iOS 聚焦自动缩放，加大触摸区 ---------- */
  input[type="text"], input[type="email"], input[type="password"], input[type="number"],
  input[type="date"], input[type="search"], select, textarea {
    font-size: 16px; padding: 10px 11px; min-height: 42px;
  }
  textarea { min-height: 88px; }
  .field > span { font-size: 13px; }
  .form-grid { gap: 13px; }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; padding: 6px 11px; font-size: 12.5px; }
  .btn-block { min-height: 46px; }
  .icon-btn { width: 38px; height: 38px; }

  /* ---------- 筛选栏：纵向堆叠，标签左、控件右 ---------- */
  .filters { flex-direction: column; align-items: stretch; gap: 9px; padding: 12px; }
  .filters .field-inline { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-width: 0; }
  .filters .field-inline > select,
  .filters .field-inline > input[type="text"],
  .filters .field-inline > input[type="search"] { flex: 1 1 auto; min-width: 0; max-width: 64%; }
  .filters select, .filters input { font-size: 16px; padding: 8px 10px; min-height: 40px; }
  /* width: 0（而非 auto）消除日期控件的固有宽度，防止并排两个日期把布局视口撑宽 */
  .filters input[type="date"] { width: 0; min-width: 0; flex: 1 1 0; }
  .filters .grow { flex: 1 1 auto; max-width: none; }
  .filters > .btn { align-self: flex-end; }

  /* ---------- 表格 → 卡片式列表（消灭横向滚动） ---------- */
  .table-wrap { overflow-x: visible; }
  table.tbl { display: block; font-size: 13.5px; }
  table.tbl thead { display: none; }
  table.tbl tbody, table.tbl tfoot { display: block; }
  table.tbl tbody tr {
    display: flex; flex-direction: column; align-items: stretch;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  table.tbl tbody tr:last-child { border-bottom: none; }
  table.tbl tbody tr:hover { background: transparent; }
  table.tbl tbody tr.clickable:active { background: #f6f9ff; }
  table.tbl td {
    display: flex; flex-wrap: wrap; align-items: baseline;
    justify-content: space-between; gap: 3px 12px;
    padding: 3px 0; border: none; text-align: left; white-space: normal;
  }
  table.tbl td::before {
    content: attr(data-label);
    flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 400;
  }
  table.tbl td:not([data-label])::before { display: none; }
  /* 单元格内部的块（副标题、头像行）独占一行 */
  table.tbl td > div { flex: 1 1 100%; }
  /* 主字段（标题/姓名/老师）提到卡片最上方，卡片读起来先看到「是什么」 */
  table.tbl td.cell-main {
    order: -1; display: block; padding-bottom: 6px;
    font-size: 14.5px; line-height: 1.45;
  }
  table.tbl td.cell-main .cell-title { font-size: 14.5px; font-weight: 650; }
  table.tbl td.cell-main .cell-sub { font-size: 12px; }
  table.tbl td.td-acts {
    justify-content: flex-end; gap: 8px;
    padding-top: 10px; margin-top: 8px;
    border-top: 1px dashed var(--border-strong);
  }
  table.tbl td.td-acts::before { display: none; }
  table.tbl .num { white-space: normal; }
  table.tbl tfoot tr {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 11px 14px; background: var(--surface-2); border-top: 1px solid var(--border);
  }
  table.tbl tfoot td { display: block; padding: 0; border: none; }
  table.tbl tfoot td:first-child { font-size: 13px; }
  table.tbl tfoot td.num { white-space: nowrap; }

  /* ---------- 模态框：全屏抽屉，录入表单不再被挤扁 ---------- */
  .modal-mask { padding: 0; align-items: stretch; overflow: hidden; }
  .modal, .modal.wide, .modal.narrow {
    width: 100%; max-width: none;
    min-height: 100vh; min-height: 100dvh; max-height: 100dvh;
    margin: 0; border-radius: 0;
    display: flex; flex-direction: column;
  }
  .modal-head { flex: 0 0 auto; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .modal-head h3 { font-size: 16px; }
  .modal-head .sub { font-size: 11.5px; }
  .modal-close { font-size: 22px; padding: 6px 10px; margin-right: -6px; }
  .modal-body {
    flex: 1 1 auto; max-height: none; overflow-y: auto;
    padding: 16px; -webkit-overflow-scrolling: touch;
  }
  .modal-foot {
    flex: 0 0 auto; gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
  }
  .modal-foot .btn { flex: 1 1 0; min-width: 0; min-height: 44px; }
  .modal-foot .left { flex: 1 1 100%; margin-right: 0; }
  .modal-foot .left .btn { width: 100%; }
  .modal-body .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .modal-body .stat { padding: 11px 12px; }
  .modal-body .stat .value { font-size: 17px; }
  .modal-body .stat .label { font-size: 11.5px; }
  .modal-body .grid.cols-4 .stat .value[style*="font-size:14px"] { font-size: 12.5px !important; padding-top: 6px !important; }

  /* ---------- 费用明细行 → 单行卡片 ---------- */
  .items-head { display: none; }
  .items-editor { gap: 10px; }
  .item-row {
    position: relative;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    padding: 11px 12px; padding-right: 48px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  }
  .item-row > *:nth-child(1) { grid-column: 1 / -1; }
  .item-row > *:nth-child(4) { grid-column: 1 / -1; }
  .item-row > *:nth-child(5) { position: absolute; top: 10px; right: 10px; }
  .items-total { font-size: 13px; padding-top: 11px; }
  .items-total b { font-size: 18px; }

  /* ---------- 附件、图表、toast ---------- */
  .attach-list { gap: 8px; }
  .attach-item { min-width: 0; max-width: none; flex: 1 1 100%; }

  .donut-wrap { flex-direction: column; gap: 14px; }
  .donut-box { flex: 0 0 auto; max-width: 176px; margin: 0 auto; }
  .donut-legend { flex: 1 1 100%; width: 100%; }
  .hbar-row { grid-template-columns: 84px 1fr 74px; gap: 8px; padding: 5px 0; }
  .hbar-row .hbar-label, .hbar-row .hbar-value { font-size: 11.5px; }

  .toast-root { top: calc(62px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }

  /* ---------- 登录页 ---------- */
  .login-view { padding: 20px 14px; align-items: flex-start; }
  .login-card { padding: 24px 18px 20px; border-radius: 16px; margin-top: 4vh; }
  .login-brand { margin-bottom: 20px; gap: 11px; }
  .login-brand h1 { font-size: 18.5px; }
  .demo-chip { padding: 6px 12px; }

  .empty { padding: 34px 16px; }

  /* 列表顶部汇总条：改两列网格，比纵向堆 5 行省一半高度 */
  .filters.filters-summary {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px; padding: 11px 14px;
  }
  .filters.filters-summary > span { font-size: 11.5px; line-height: 1.45; }

  /* 轻量对话框（确认 / 单行输入）：内容少，保持居中小卡片，不铺满全屏 */
  .modal.dlg {
    align-self: center;
    min-height: 0; max-height: calc(100dvh - 32px);
    width: calc(100% - 28px); max-width: 420px;
    margin: auto; border-radius: 14px;
  }
  .modal.dlg .modal-head { padding: 14px 16px; }
  .modal.dlg .modal-body { flex: 0 1 auto; padding: 16px; }
  .modal.dlg .modal-foot { padding: 12px 16px 16px; border-radius: 0 0 14px 14px; }
  .modal.dlg .modal-foot .btn { min-height: 42px; }
}

/* ===================== 响应式 · 小屏手机 ===================== */
@media (max-width: 400px) {
  .main { padding-left: 10px; padding-right: 10px; }
  .brand-name { font-size: 14px; }
  .nav-item { font-size: 10.5px; }
  .nav-item::before { font-size: 16px; }
  .page-title { font-size: 16.5px; }
  .stat .value { font-size: 18.5px; }
  table.tbl tbody tr { padding: 11px 12px; }
  .hbar-row { grid-template-columns: 74px 1fr 68px; gap: 6px; }
}
