/* ==========================================================================
 * 学员 CRM · 样式（浅色主题 / 后台管理风格）
 * ========================================================================== */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f0f3f9;
  --border: #e5e9f2;
  --border-strong: #d5dce9;
  --text: #1a2130;
  --text-2: #5a6678;
  --text-3: #8b95a6;
  --primary: #3B6EF6;
  --primary-dark: #2a55cc;
  --primary-soft: #eaf0ff;
  --success: #12a06a;
  --success-soft: #e7f7f0;
  --danger: #df4358;
  --danger-soft: #fdecee;
  --warning: #d98b0f;
  --warning-soft: #fdf3e2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(26, 33, 48, .05);
  --shadow-md: 0 8px 24px rgba(26, 33, 48, .08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .2);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

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

input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }

/* ---------------------------------------------------------------- 骨架布局 */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  flex: 0 0 34px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; font-weight: 600; }
.brand-text span { font-size: 11.5px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { flex: 0 0 18px; opacity: .9; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.side-stat { display: flex; align-items: baseline; justify-content: space-between; padding: 0 10px 10px; }
.side-stat span { font-size: 12px; color: var(--text-3); }
.side-stat strong { font-size: 18px; font-weight: 600; color: var(--text); }

.user-card { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.user-avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 500;
}
.user-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-info strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-actions { display: flex; gap: 4px; margin-top: 6px; }
.link-btn {
  flex: 1;
  padding: 6px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: .15s;
}
.link-btn:hover { background: var(--surface-3); color: var(--text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 74px;
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title h1 { font-size: 18px; font-weight: 600; letter-spacing: -.2px; }
.topbar-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 22px 28px 72px; flex: 1; }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(59, 110, 246, .24);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c73348; }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); border-color: #f7ccd3; }
.btn-danger-ghost:hover { background: #fce0e4; }
.btn-lg { padding: 11px 26px; font-size: 14px; }
.btn-block { width: 100%; }

.icon-btn {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* ------------------------------------------------------------------ 登录 */
#loginRoot:empty { display: none; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(circle at 15% 10%, #e8efff 0%, rgba(232, 239, 255, 0) 45%),
    radial-gradient(circle at 85% 85%, #eaf7f1 0%, rgba(234, 247, 241, 0) 40%),
    var(--bg);
}

.login-card {
  width: min(408px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 32px 28px;
  box-shadow: 0 20px 50px rgba(26, 33, 48, .1);
}

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.login-brand-text strong { font-size: 14px; font-weight: 600; }
.login-brand-text span { font-size: 11.5px; color: var(--text-3); }

.login-title { font-size: 22px; font-weight: 600; letter-spacing: -.4px; }
.login-sub { margin: 6px 0 22px; font-size: 13px; color: var(--text-3); line-height: 1.7; }

#loginForm .field { margin-bottom: 14px; }
#loginForm .btn { margin-top: 6px; }

.login-err {
  min-height: 20px;
  margin-bottom: 4px;
  font-size: 12.5px;
  color: var(--danger);
}

.login-tip {
  margin-top: 20px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  border: 1px solid #f3ddb4;
  font-size: 12px;
  color: #8a5c08;
  line-height: 1.7;
}
.login-tip code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .8);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}

/* ------------------------------------------------------------------ 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 14.5px; font-weight: 600; }
.card-desc { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); }
.card-body { padding: 20px 22px; }
.card-body.no-pad { padding: 0; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
  border: 1px solid var(--border);
}

/* ------------------------------------------------------------------ 统计 */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label { display: block; font-size: 12.5px; color: var(--text-3); }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -.5px; line-height: 1.3; }
.stat-value em { font-style: normal; font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.stat-card.tone-today .stat-value { color: var(--primary); }

/* ------------------------------------------------------------------ 录入 */
.capture-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.textarea { resize: vertical; min-height: 92px; line-height: 1.7; }

.capture-actions { display: flex; gap: 10px; margin: 12px 0 14px; }

.hits-box { min-height: 34px; margin-bottom: 16px; }
.hits-empty { font-size: 12.5px; color: var(--text-3); padding: 6px 0; }
.hits { display: flex; flex-wrap: wrap; gap: 6px; }
.hit {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid #d5e1ff;
  font-size: 12px;
  color: var(--primary-dark);
}
.hit b { font-weight: 500; color: var(--text-3); }

.tips { border-top: 1px dashed var(--border); padding-top: 14px; }
.tips-title { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.tips ul { margin: 0; padding-left: 18px; color: var(--text-3); font-size: 12.5px; line-height: 1.85; }
.tips b { color: var(--text-2); font-weight: 500; }

/* ------------------------------------------------------------------ 表单 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full, .field-full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.req { color: var(--danger); font-weight: 400; }
.req-hint { font-size: 11px; color: var(--text-3); font-weight: 400; }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: 0;
}
.input::placeholder { color: #b3bbc9; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 110, 246, .13); }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95a6' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

.field.has-error .input { border-color: var(--danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px rgba(223, 67, 88, .13); }
.field-error { font-size: 11.5px; color: var(--danger); min-height: 16px; line-height: 1.4; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: fit-content;
}
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
  display: block;
  padding: 5px 22px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
  transition: .15s;
}
.seg.on span { background: var(--surface); color: var(--primary); font-weight: 500; box-shadow: var(--shadow-sm); }
.seg:hover span { color: var(--text); }

.form-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-hint { font-size: 12px; color: var(--text-3); }
.form-btns { display: flex; gap: 10px; margin-left: auto; }

/* ------------------------------------------------------------------ 表格 */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.search { position: relative; flex: 1 1 260px; min-width: 200px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface-2);
  transition: .15s;
}
.search-input:focus { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 110, 246, .13); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.input-sm { padding: 8px 30px 8px 10px; font-size: 13px; width: auto; min-width: 108px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 1020px; }
.table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  padding: 10px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { color: var(--primary); }
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
  color: var(--text-2);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.row { cursor: pointer; transition: background .12s; }
.table tbody tr.row:hover { background: #f8faff; }
.table tbody tr.row-off { opacity: .6; }
.th-ops { width: 110px; }

.table-user { min-width: 760px; }
.table-user td:last-child { white-space: nowrap; }

.cell-name { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 500;
}
.avatar-m { background: #e8f0ff; color: #2f5fd0; }
.avatar-f { background: #fdeaf0; color: #c23a63; }
.cell-strong { font-size: 13.5px; color: var(--text); font-weight: 500; }
.cell-sub { font-size: 11px; color: var(--text-3); }
.cell-notes { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-ops { white-space: nowrap; }
.cell-ops .icon-btn + .icon-btn { margin-left: 6px; }

.mono { font-variant-numeric: tabular-nums; letter-spacing: .2px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge-m { background: #e8f0ff; color: #2f5fd0; border-color: #d3e0ff; }
.badge-f { background: #fdeaf0; color: #c23a63; border-color: #f8d5e0; }
.badge-admin { background: var(--primary-soft); color: var(--primary-dark); border-color: #d5e1ff; }
.badge-on { background: var(--success-soft); color: #0b7a51; border-color: #c9ebda; }
.badge-off { background: var(--surface-3); color: var(--text-3); border-color: var(--border-strong); }
.badge-you { background: var(--warning-soft); color: #8a5c08; border-color: #f3ddb4; font-size: 11px; }

.empty { padding: 46px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty.sm { padding: 18px; font-size: 12.5px; text-align: left; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pager-info { font-size: 12.5px; color: var(--text-3); }
.pager-btns { display: flex; gap: 5px; }
.page-btn {
  min-width: 32px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: .15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ------------------------------------------------------------------ 配置 */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.card-wide { grid-column: 1 / -1; }

.config-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.config-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 6px;
  border-radius: var(--radius-sm);
}
.config-row:hover { background: var(--surface-2); }
.config-row.off { opacity: .58; }
.config-row.off .input-flat { text-decoration: line-through; }

.input-flat {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 7px;
  min-width: 0;
}
.input-flat:hover { border-color: var(--border); background: var(--surface); }
.input-flat:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(59, 110, 246, .12); }

.config-count { font-size: 12px; color: var(--text-3); white-space: nowrap; min-width: 44px; text-align: right; }

.add-row { display: flex; gap: 8px; }
.add-row .input { flex: 1; }

.data-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.note { margin: 14px 0 0; font-size: 12.5px; color: var(--text-3); line-height: 1.7; }

/* ------------------------------------------------------------------ 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(19, 26, 40, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px 24px;
  z-index: 100;
  overflow-y: auto;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(720px, 100%);
  box-shadow: var(--shadow-lg);
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
}
.modal-foot.split { justify-content: space-between; }
.modal-foot-note { font-size: 12px; color: var(--text-3); }
.confirm-text { margin: 0 0 4px; font-size: 13.5px; color: var(--text-2); line-height: 1.75; white-space: pre-line; }

/* ------------------------------------------------------------------ Toast */
.toast-root {
  position: fixed;
  left: 50%; top: 22px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: #1e2636;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .26);
  animation: toastIn .2s ease;
  max-width: 440px;
  text-align: center;
}
.toast-error { background: #b52f42; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .35s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ 响应式 */
/* 手机端顶栏用户菜单：桌面隐藏，≤820px 显示（替代被隐藏的侧栏用户卡片） */
.m-user { display: none; }

@media (max-width: 1180px) {
  .capture-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto; flex: none; height: auto;
    position: sticky; top: 0; z-index: 30;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-right: 0; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .brand { padding: 0; flex: 0 0 auto; }
  .brand-text span { display: none; }
  .nav { flex-direction: row; gap: 4px; flex: 0 0 auto; }
  .nav-item { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  .nav-item span { display: none; white-space: nowrap; }
  .nav-item.active span { display: inline; }
  .sidebar-foot { display: none; }
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .topbar-actions { flex: 1 1 auto; min-width: 0; justify-content: flex-end; flex-wrap: wrap; }
  .content { padding: 16px 16px 56px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .form-foot { flex-direction: column-reverse; align-items: stretch; }
  .form-btns { margin-left: 0; }
  .form-btns .btn { flex: 1; }
  .modal-mask { padding: 12px; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
  .modal-foot { border-radius: 0; }
  .login-card { padding: 26px 22px 22px; }

  /* iOS 聚焦输入框不放大页面 */
  .input, .search-input, .input-flat { font-size: 16px; }

  /* 手机端顶栏用户菜单（替代被隐藏的侧栏用户卡片） */
  .m-user { display: block; position: relative; }
}

/* ----------------------------------------------------- 手机端顶栏用户菜单 */
.m-user summary {
  list-style: none;
  cursor: pointer;
  display: grid; place-items: center;
  border-radius: 50%;
}
.m-user summary::-webkit-details-marker { display: none; }
.m-user summary .user-avatar { width: 34px; height: 34px; flex: 0 0 34px; font-size: 14px; }
.m-user-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 60;
}
.m-user-head { display: flex; flex-direction: column; padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.m-user-head strong { font-size: 13px; font-weight: 600; }
.m-user-head span { font-size: 11px; color: var(--text-3); }
.m-user-menu .link-btn { text-align: left; padding: 9px 10px; font-size: 13px; color: var(--text-2); border-radius: 8px; }
.m-user-menu .link-btn:hover { background: var(--surface-3); color: var(--text); }
.m-user-menu .link-btn.danger { color: var(--danger); }
.m-user-menu .link-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------- 手机端表格 → 卡片堆叠（≤640px） */
@media (max-width: 640px) {
  body { overflow-x: hidden; }
  .content { padding: 12px 12px 48px; }
  .topbar { padding: 10px 12px; }
  .topbar-title h1 { font-size: 16px; }
  .topbar-title p { display: none; }
  .topbar-actions .btn { padding: 8px 12px; font-size: 13px; }
  /* 导航里已有同入口，手机上隐藏顶栏的跳转按钮，避免横向溢出 */
  .topbar-actions .btn-ghost[data-action="nav"] { display: none; }

  .toolbar { padding: 12px; gap: 10px; }
  .search { flex-basis: 100%; min-width: 0; }
  .filters { width: 100%; }
  .filters .input-sm { flex: 1; min-width: 0; }

  .stat-row { gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 10px 14px; }
  .stat-value { font-size: 20px; }

  .card-head { padding: 14px 14px; }
  .card-body { padding: 14px; }

  .table-wrap { overflow: visible; }
  .table, .table tbody { display: block; min-width: 0; }
  .table thead { display: none; }
  .table tbody tr {
    display: block;
    margin: 10px 12px;
    padding: 4px 14px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }
  .table tbody tr:first-child { margin-top: 4px; }
  .table tbody tr:last-child { margin-bottom: 4px; }
  .table tbody tr.row { cursor: default; }
  .table tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--border);
  }
  .table tbody td:last-child { border-bottom: 0; }
  .table tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--text-3);
  }
  .table tbody td:not([data-label]) { display: block; }
  .table tbody td:not([data-label])::before { content: none; }
  .cell-name { gap: 9px; min-width: 0; }
  .cell-name > div { min-width: 0; }
  .cell-strong, .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cell-notes { max-width: none; white-space: normal; text-align: right; }
  .cell-ops { justify-content: flex-end; }
  .cell-ops::before { margin-right: auto; }
  .cell-ops .icon-btn { padding: 6px 12px; }
  .empty { padding: 30px 16px; }

  .pager { padding: 10px 12px; }
  .pager-info { flex: 1 0 100%; }

  .data-actions .btn { flex: 1 1 auto; }
}
