:root {
  --bg0: #eef3f1;
  --bg1: #f5f8f6;
  --ink: #1b2d26;
  --ink-soft: #3d5249;
  --muted: #6b7d75;
  --line: #e2eae6;
  --teal: #1b9a68;
  --teal-deep: #127a52;
  --mint: #d8f0e4;
  --gold: #d9a21b;
  --amber: #e09f3e;
  --coral: #e0543c;
  --danger: #e0543c;
  --danger-soft: rgba(224, 84, 60, 0.1);
  --sky: #2b88c4;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(27, 45, 38, 0.04), 0 8px 24px rgba(27, 45, 38, 0.05);
  --radius: 12px;
  --radius-lg: 16px;
  --space: 16px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 24px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 56px;
  --control-h: 44px; /* 输入、下拉、主按钮、验证码、金额/性别选择 */
  --chip-h: 32px; /* 筛选标签、标题旁操作、轻量按钮 */
  --tag-h: 24px; /* 状态小标签 */
  --badge-h: 22px; /* 列表/角色徽标 */
  --check-s: 18px; /* 复选/单选 */
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --display: var(--font);
  --focus: 0 0 0 3px rgba(27, 154, 104, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 作者样式里的 display:flex/grid 会盖掉 UA 的 [hidden]，必须强制隐藏 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg1);
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
}

body:has(.login-wrap) {
  padding-bottom: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 0 var(--space) var(--space-lg);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(-1 * var(--space)) var(--space);
  padding: 10px var(--space) 10px;
  background: rgba(245, 248, 246, 0.92);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar-titles {
  text-align: center;
  flex: 1;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.child-switch {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.child-switch-label {
  font-size: 0.7rem;
  color: var(--muted);
}

.child-switch select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 28px 0 12px;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--ink);
  max-width: 160px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.child-switch-hint {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-icon {
  width: var(--control-h);
  height: var(--control-h);
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 1.1rem;
}

.btn-icon.ghost {
  background: transparent;
  border-color: transparent;
}

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 18px var(--space) 16px;
  color: #f4fff8;
  background: linear-gradient(165deg, #1c9d6c 0%, #157a58 100%);
  box-shadow: none;
}

.hero .pill {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
  z-index: 1;
}

.hero-name {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 650;
  margin: 0 0 4px;
  position: relative;
  z-index: 1;
}

.hero::after {
  content: "";
  position: absolute;
  right: -36px;
  top: -36px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.hero-sub {
  margin: 0;
  opacity: 0.88;
  font-size: 0.82rem;
  position: relative;
  z-index: 1;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space);
  position: relative;
  z-index: 1;
}

.stat {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 0.7rem;
  opacity: 0.85;
}

.stat.earn b {
  color: #d8ffe8;
}
.stat.deduct b {
  color: #ffd3c8;
}
.stat.net b {
  color: #ffe7a8;
}

/* Sections */
.section {
  margin-top: var(--space);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.section-label {
  margin: var(--space) 0 var(--space-sm);
  padding: 0 2px;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.06em;
}

#topbar + .section-label {
  margin-top: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.cta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.section-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* 区块标题旁的辅助按钮保持紧凑，不与表单 44px 控件抢视觉层级 */
.section-head .btn,
.bank-strip .btn {
  height: var(--chip-h);
  min-height: var(--chip-h);
  padding: 0 12px;
  font-size: 0.78rem;
  line-height: 1;
}

.bank-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space);
}

.bank-strip .amt-lg {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.panel-pad {
  padding: var(--space);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}

.kpi b {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.kpi span {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi.warn b {
  color: var(--danger);
}

.quick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-md);
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: none;
  transition: transform 0.15s ease;
}

.section-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.section-head a,
.link {
  color: var(--teal);
  font-size: 0.85rem;
  font-weight: 500;
}

.link.danger {
  color: var(--danger);
}

.quick:active {
  transform: scale(0.98);
}

.quick .q-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--mint);
  color: var(--teal-deep);
  font-weight: 700;
  font-size: 1.15rem;
}

.quick strong {
  font-size: 0.95rem;
}

.quick small {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Panels / lists */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  overflow: hidden;
}

button.list-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.list-item {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: 14px var(--space);
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: var(--badge-h);
  min-height: var(--badge-h);
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.list-item .badge {
  margin-top: 2px;
  min-width: 42px;
  background: #e7f6ee;
  color: var(--teal-deep);
}

.member-card .badge {
  margin-top: 2px;
}

.badge.red {
  background: #ffe5df;
  color: var(--coral);
}
.badge.gold {
  background: #fff1c9;
  color: #8a6500;
}
.badge.blue {
  background: #e3f1fb;
  color: var(--sky);
}
.badge.orange {
  background: #ffedd4;
  color: #9a5b00;
}
.badge.pending {
  background: #fff1d6;
  color: #9a5b00;
}
.badge.review {
  background: #ffe8d6;
  color: #a14a00;
  min-width: 52px;
}

.list-item.is-ai-review {
  background: linear-gradient(90deg, rgba(255, 164, 56, 0.14), transparent 52%);
  box-shadow: inset 3px 0 0 #e0891a;
}
.list-item.is-ai-ok {
  box-shadow: inset 3px 0 0 rgba(27, 154, 104, 0.35);
}
.list-item.pulse-review {
  animation: reviewPulse 1.6s ease;
}
@keyframes reviewPulse {
  0%,
  100% {
    background-color: transparent;
  }
  30%,
  60% {
    background-color: rgba(255, 164, 56, 0.18);
  }
}
.ai-review-note {
  display: block;
  margin-top: 4px;
  color: #a14a00;
  font-size: 0.75rem;
  line-height: 1.4;
}

.child-tag {
  display: inline-flex;
  align-items: center;
  height: var(--tag-h);
  min-height: var(--tag-h);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  color: var(--brand, #1b9a68);
  background: rgba(27, 154, 104, 0.1);
  padding: 0 8px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
}

.list-item .main {
  flex: 1;
  min-width: 0;
}

.list-item .main strong {
  display: block;
  font-size: 0.95rem;
}

.list-item .main small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
  line-height: 1.4;
}

.list-item .amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amt.plus {
  color: var(--teal);
}
.amt.minus {
  color: var(--coral);
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* maai 助手弹窗 */
.ai-assist-dialog-head strong {
  font-size: 0.98rem;
  color: var(--teal-deep);
}

.ai-assist-dialog-head small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 2px;
}

.ai-assist-dialog textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  line-height: 1.45;
  color: var(--ink);
  background: #fff;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.ai-assist-dialog textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: var(--focus);
}

/* 右侧浮动入口 */
.ai-fab {
  position: fixed;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
  z-index: 45;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 20px rgba(18, 122, 82, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ai-fab:active {
  transform: scale(0.96);
}

.ai-fab-badge {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}

.ai-fab-text {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.95;
  line-height: 1;
}

/* maai 助手弹窗 */
#aiAssistMask {
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}

#aiAssistMask.show {
  display: flex;
}

.ai-assist-dialog {
  width: min(420px, 100%);
  max-height: min(82vh, 640px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-assist-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid #eef3f0;
}

.ai-assist-close {
  width: var(--control-h);
  height: var(--control-h);
  border: none;
  border-radius: 10px;
  background: #f3f8f5;
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.ai-assist-dialog-body {
  padding: 14px 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-assist-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding: 3px;
  border-radius: var(--radius);
  background: #f3f8f5;
}
.ai-assist-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--chip-h);
  min-height: var(--chip-h);
  border: 0;
  border-radius: 10px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.ai-assist-tab.active {
  background: #fff;
  color: var(--teal-deep);
  box-shadow: 0 1px 4px rgba(20, 38, 31, 0.08);
}
.ai-assist-pane[hidden] {
  display: none !important;
}

.ai-suggest-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-suggest-item {
  text-align: left;
  border: 1px solid var(--line);
  background: #f7fbf8;
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
}

.ai-suggest-item:hover {
  border-color: rgba(27, 154, 104, 0.35);
}

.ai-suggest-item .ai-suggest-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.ai-suggest-item strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.ai-suggest-item .ai-suggest-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.ai-suggest-item .badge {
  flex-shrink: 0;
}

/* 待确认核验摘要 */
.pending-summary-card {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid #d7ebe0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f4fbf7 0%, #fff 100%);
}

.pending-summary-card .ps-text {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.pending-summary-card .ps-flags {
  margin: 0;
  padding-left: 18px;
  color: #8a5a12;
  font-size: 0.82rem;
  line-height: 1.45;
}

.pending-summary-card .ps-flags li {
  margin: 0 0 4px;
}

.pending-summary-card .ps-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

#pendingSummaryMask {
  z-index: 60;
}

#pendingSummaryMask .ai-assist-dialog-body {
  padding-top: 12px;
}

.ps-check-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 8px;
}
.ps-check-head strong {
  font-size: 0.95rem;
  color: var(--ink);
}
.ps-check-head span {
  color: var(--muted);
  font-size: 0.75rem;
}
.ps-check-section {
  margin-top: 10px;
}
.ps-check-label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--teal-deep);
}
.ps-check-label.warn {
  color: #a14a00;
}
.ps-check-item.is-review {
  border-color: rgba(224, 137, 26, 0.45);
  background: #fff8ef;
}
.ps-check-item.is-ok {
  background: #f7fbf8;
}
.ps-check-ok {
  opacity: 0.92;
}
.ps-jump-hint {
  display: inline-block;
  margin-left: 4px;
  color: var(--teal-deep);
  font-size: 0.72rem;
}
.ps-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.review-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid rgba(224, 137, 26, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff8ef 0%, #fff 100%);
}
.review-banner[hidden] {
  display: none !important;
}
.review-banner-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.review-banner-mark {
  flex-shrink: 0;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  min-height: var(--badge-h);
  padding: 0 7px;
  border-radius: 999px;
  background: #ffe8d6;
  color: #a14a00;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}
.review-banner-text {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.4;
}
.review-banner-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}
.review-banner-actions .btn {
  height: var(--chip-h);
  min-height: var(--chip-h);
  padding: 0 12px;
  font-size: 0.78rem;
  line-height: 1;
}
.review-banner-actions .btn.is-active {
  border-color: rgba(224, 137, 26, 0.55);
  color: #a14a00;
  background: #fff1d6;
}
@media (max-width: 420px) {
  .review-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .review-banner-actions {
    justify-content: flex-end;
  }
}

/* 结算周报弹窗 */
#settleReportMask {
  z-index: 60;
}
.settle-report-card .sr-summary {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}
.settle-report-card .sr-block {
  margin: 0 0 12px;
}
.settle-report-card .sr-label {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--teal-deep);
}
.settle-report-card .sr-label.warn {
  color: #a14a00;
}
.settle-report-card .sr-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.45;
}
.settle-report-card .sr-list li {
  margin: 0 0 4px;
}
.settle-report-card .sr-goal {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
}
.settle-report-card .sr-speak {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f4fbf7 0%, #fff 100%);
  border: 1px solid #d7ebe0;
}
.settle-report-card .sr-speak-text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
}

/* Chips / filters */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--chip-h);
  min-height: var(--chip-h);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-soft);
}

.chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* 与 chip 同排的轻量按钮，高度与标签对齐 */
.btn.btn-chip {
  height: var(--chip-h);
  min-height: var(--chip-h);
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

/* Forms */
.form {
  display: grid;
  gap: 12px;
}

.field {
  min-width: 0;
  max-width: 100%;
}

.field label {
  display: block;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.field-label-row label {
  margin: 0;
}
.btn-polish {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: #e7f6ee;
  color: var(--teal-deep);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  height: var(--chip-h);
  min-height: var(--chip-h);
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-polish:disabled {
  opacity: 0.55;
  cursor: wait;
}
.remark-alts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.name-style-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.remark-alts[hidden] {
  display: none !important;
}
.remark-alts button,
.name-style-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--tag-h);
  min-height: var(--tag-h);
  border: 1px solid #cfe8da;
  background: #f5faf7;
  color: var(--ink-soft);
  font-size: 0.75rem;
  padding: 0 9px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
  line-height: 1;
}

.name-style-chip.active {
  background: #e7f6ee;
  color: var(--teal-deep);
  border-color: #9fd5b8;
  font-weight: 600;
}

/* 必填：字段标题前红 *（随 [required] / .field-required 自动显示） */
.field:has(:is(input, select, textarea)[required]) > label:first-of-type::before,
.field.field-required > label:first-of-type::before,
.family-hero:has(input[required]) .family-hero-label::before,
.agree-row:has(> input[required]) > span::before {
  content: "*";
  color: #e5484d;
  margin-right: 0.2em;
  font-weight: 700;
  font-family: inherit;
  line-height: 1;
}

.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.agree-row input {
  margin-top: 1px;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  outline: none;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select {
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 14px;
  line-height: 1;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

input[type="checkbox"],
input[type="radio"] {
  width: var(--check-s);
  height: var(--check-s);
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--teal);
  vertical-align: middle;
}

/* 日期选择：yyyy-MM-dd，与其它 input 同宽 */
.field input.input-date {
  display: block;
  height: var(--control-h);
  min-height: var(--control-h);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='3' stroke='%231b9a68' stroke-width='1.6'/%3E%3Cpath stroke='%231b9a68' stroke-width='1.6' stroke-linecap='round' d='M8 3.5v3M16 3.5v3M3.5 10h17'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
  padding: 0 40px 0 14px;
}

.field input.input-date:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Flatpickr · 学记宝主题 */
.flatpickr-calendar.xjb-datepicker {
  z-index: 80;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  font-family: var(--font);
  width: 308px;
  padding: 8px 6px 10px;
  overflow: hidden;
}

.flatpickr-calendar.xjb-datepicker.arrowTop:before,
.flatpickr-calendar.xjb-datepicker.arrowTop:after,
.flatpickr-calendar.xjb-datepicker.arrowBottom:before,
.flatpickr-calendar.xjb-datepicker.arrowBottom:after {
  display: none;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-months {
  align-items: center;
  padding: 4px 4px 8px;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-month {
  height: 36px;
  color: var(--teal-deep);
  fill: var(--teal-deep);
}

.flatpickr-calendar.xjb-datepicker .flatpickr-current-month {
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--display);
  padding-top: 0;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-current-month .cur-month,
.flatpickr-calendar.xjb-datepicker .flatpickr-current-month input.cur-year {
  font-weight: 600;
  color: var(--teal-deep);
}

.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-prev-month,
.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-next-month {
  fill: var(--teal);
  color: var(--teal);
  border-radius: 10px;
  top: 6px;
  padding: 4px;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-next-month:hover {
  background: rgba(27, 154, 104, 0.08);
}

.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-calendar.xjb-datepicker .flatpickr-months .flatpickr-next-month:hover svg {
  fill: var(--teal-deep);
}

.flatpickr-calendar.xjb-datepicker .flatpickr-weekdays {
  height: 28px;
}

.flatpickr-calendar.xjb-datepicker span.flatpickr-weekday {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-days {
  width: 100%;
}

.flatpickr-calendar.xjb-datepicker .dayContainer {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-day {
  border-radius: var(--radius);
  max-width: 40px;
  height: 40px;
  line-height: 40px;
  color: var(--ink);
  border: none;
  margin-top: 2px;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-day:hover,
.flatpickr-calendar.xjb-datepicker .flatpickr-day:focus {
  background: rgba(27, 154, 104, 0.1);
  border-color: transparent;
  color: var(--teal-deep);
}

.flatpickr-calendar.xjb-datepicker .flatpickr-day.today {
  border: 1px solid rgba(27, 154, 104, 0.35);
  color: var(--teal-deep);
  font-weight: 600;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-day.selected,
.flatpickr-calendar.xjb-datepicker .flatpickr-day.selected:hover,
.flatpickr-calendar.xjb-datepicker .flatpickr-day.selected:focus {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 4px 12px rgba(27, 154, 104, 0.28);
}

.flatpickr-calendar.xjb-datepicker .flatpickr-day.flatpickr-disabled,
.flatpickr-calendar.xjb-datepicker .flatpickr-day.prevMonthDay,
.flatpickr-calendar.xjb-datepicker .flatpickr-day.nextMonthDay {
  color: #b7c7bf;
}

.flatpickr-calendar.xjb-datepicker .flatpickr-day.flatpickr-disabled {
  opacity: 0.4;
}

.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field select:focus,
.field textarea:focus,
.field label.exam-switch:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 154, 104, 0.12);
}

.field textarea {
  min-height: 88px;
  padding: 12px 14px;
  line-height: 1.45;
  resize: vertical;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-row input {
  flex: 1;
  min-width: 0;
  width: auto;
}

.captcha-img {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 120px;
  width: 120px;
  height: var(--control-h);
  min-height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg1);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  line-height: 0;
}

.captcha-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.amount-picks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.amount-picks button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: var(--control-h);
  min-height: var(--control-h);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 0 12px;
  font-weight: 700;
  line-height: 1;
}

.amount-picks button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  border: 0;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--teal-deep);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 10px;
}

/* Schedule */
.timeline {
  position: relative;
  padding-left: 18px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(var(--mint), rgba(27, 154, 104, 0.15));
}

.tl-item {
  position: relative;
  padding: 0 0 14px 14px;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 154, 104, 0.15);
}

.tl-item strong {
  display: block;
  font-size: 0.95rem;
}

.tl-item .time {
  color: var(--teal-deep);
  font-size: 0.8rem;
  font-weight: 700;
}

.tl-item small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Rules accordion */
.acc-item {
  border-bottom: 1px solid var(--line);
}

.acc-item:last-child {
  border-bottom: 0;
}

.acc-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.acc-btn span {
  color: var(--muted);
  font-weight: 400;
}

.acc-body {
  display: none;
  padding: 0 14px 14px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.65;
}

.acc-item.open .acc-body {
  display: block;
  animation: fade 0.25s ease;
}

.acc-body p {
  margin: 0 0 10px;
}

/* Settle summary */
.summary-box {
  border-radius: var(--radius-lg);
  padding: 16px;
  background: linear-gradient(160deg, #fffaf0, #ffffff);
  border: 1px solid #f0e0b8;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}

.summary-row:last-child {
  border-bottom: 0;
  font-weight: 800;
  font-size: 1.05rem;
  padding-top: 12px;
}

.bank-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  background:
    radial-gradient(circle at 90% 20%, rgba(255, 255, 255, 0.2), transparent 40%),
    linear-gradient(165deg, #1c9d6c 0%, #157a58 100%);
  color: #f4fff8;
  box-shadow: var(--shadow);
}

.bank-card .label {
  opacity: 0.85;
  font-size: 0.85rem;
}

.bank-card .balance {
  font-family: var(--display);
  font-size: 2.4rem;
  margin: 6px 0 0;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.sso-panel {
  padding: var(--space);
  display: grid;
  gap: var(--space-md);
}

.sso-error-msg {
  display: none;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  border: 1px solid rgba(194, 59, 34, 0.28);
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.sso-error-msg.is-visible {
  display: block;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: var(--tag-h);
  min-height: var(--tag-h);
  padding: 0 8px;
  border-radius: 999px;
  background: #e7f6ee;
  color: var(--teal-deep);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* Tabbar */
.tabbar-host,
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
}

.tabbar {
  width: min(480px, 100%);
  margin: 0 auto;
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 6px 8px calc(6px + var(--safe-b));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #ffffff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 var(--line);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--muted);
  border-radius: var(--radius);
}

.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-icon .svg-icon {
  width: 1.15em;
  height: 1.15em;
}

.q-icon .svg-icon {
  width: 1.1em;
  height: 1.1em;
}

.btn-icon .svg-icon {
  width: 1.05em;
  height: 1.05em;
}

.badge .svg-icon {
  width: 0.95em;
  height: 0.95em;
}

.tab.active {
  color: var(--teal-deep);
  font-weight: 700;
  background: var(--mint);
}

/* Pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 0 2px;
}

.pager[hidden] {
  display: none !important;
}

.pager .btn {
  flex: 0 0 auto;
  min-width: 88px;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 12px;
  font-size: 0.85rem;
}

.pager .btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pager-info {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted, #6b7c74);
}

/* Toast · 底部轻提示，避开底栏 */
.xjb-toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 80;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
  display: flex;
  justify-content: center;
}
body:has(.tabbar-host) .xjb-toast-host {
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
}
.toast {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: #fff;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 10px 28px rgba(10, 24, 18, 0.16);
  cursor: pointer;
  pointer-events: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast-success { border-left-color: var(--teal); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--gold); }
.toast-info { border-left-color: var(--sky); }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 18, 0.45);
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  box-sizing: border-box;
}

.modal-mask.show {
  display: flex;
}

.sheet,
.modal-dialog {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space);
  box-shadow: var(--shadow);
  animation: rise 0.2s ease;
  max-height: min(90vh, 640px);
  overflow: auto;
}

.modal-dialog {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#xjb-dialog-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(calc(90vh - 40px), 600px);
}

#xjb-dialog-inner > h3,
#xjb-dialog-inner > .dialog-sub {
  flex-shrink: 0;
}

#xjb-dialog-inner.has-foot {
  overflow: hidden;
}

#xjb-dialog-inner .modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

#xjb-dialog-inner.has-foot .modal-body {
  margin-bottom: 0;
}

#xjb-dialog-inner .modal-foot {
  flex: 0 0 auto;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.sheet h3,
.modal-dialog h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-dialog .dialog-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.confirm-mask {
  z-index: 70;
  align-items: flex-end;
  padding: 0;
}
.confirm-mask .confirm-dialog {
  width: min(480px, 100%);
  margin: 0 auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 0;
  padding: 24px 20px calc(18px + var(--safe-b));
  max-height: min(90vh, 640px);
  animation: rise 0.2s ease;
}
.confirm-dialog .confirm-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  margin: 20px 0 0;
  gap: 10px;
}
.confirm-dialog .confirm-dialog-actions .btn {
  width: 100%;
  margin: 0;
}
.confirm-dialog .btn-danger {
  box-shadow: 0 8px 18px rgba(194, 59, 34, 0.22);
}
body.xjb-confirm-open {
  overflow: hidden;
}

.gender-picks {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gender-picks label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1;
}

.gender-picks input {
  width: var(--check-s);
  height: var(--check-s);
  margin: 0;
  accent-color: var(--teal);
}

.gender-picks label:has(input:checked),
.gender-picks label.is-on {
  border-color: var(--teal);
  background: rgba(27, 154, 104, 0.08);
  box-shadow: 0 0 0 3px rgba(27, 154, 104, 0.1);
}

/* 家庭成员页 */
.family-hero {
  margin-top: 4px;
}

.family-hero-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.family-name-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.family-name-bar input,
.family-name-bar .btn {
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  border-radius: var(--radius);
}

.family-name-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 14px;
  outline: none;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
}

.family-name-bar input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 154, 104, 0.12);
}

.family-name-bar .btn {
  flex: 0 0 auto;
  align-self: center;
  padding: 0 16px;
  line-height: 1;
}

.family-hero-hint {
  margin: 10px 0 0;
}

.member-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 38, 31, 0.04);
  padding: 14px;
  margin-bottom: 10px;
}

.member-card:last-child {
  margin-bottom: 0;
}

.member-card.is-disabled {
  opacity: 0.72;
}

.member-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.member-card-top .main {
  flex: 1;
  min-width: 0;
}

.member-card-top .main strong {
  display: block;
  font-size: 1.05rem;
}

.member-card-top .main small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3px;
  line-height: 1.4;
}

.member-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  height: var(--tag-h);
  min-height: var(--tag-h);
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  background: #eef5f1;
  color: var(--ink-soft);
}

.meta-chip.off {
  background: #ffe5df;
  color: var(--coral);
}

.meta-chip.on {
  background: #dff3e8;
  color: var(--teal-deep);
}

.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.member-actions .act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--chip-h);
  min-height: var(--chip-h);
  border: 1px solid var(--line);
  background: #f7faf8;
  color: var(--teal-deep);
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.member-actions .act:active {
  transform: scale(0.97);
}

.member-actions .act.danger {
  color: var(--coral);
  background: #fff6f4;
  border-color: rgba(194, 59, 34, 0.22);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-2 > * {
  min-width: 0;
}

@media (max-width: 360px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* 管理端：家庭列表 */
.families-hero {
  margin-top: 4px;
}

.families-toolbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 38, 31, 0.04);
  padding: 14px;
}

.families-toolbar .field {
  margin: 0;
}

.families-toolbar .field label,
.logs-filters .field label {
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.families-toolbar .field input {
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
}

.families-toolbar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.families-toolbar-foot .hint {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.families-toolbar-foot .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.families-section {
  margin-top: 16px;
}

.families-list {
  display: grid;
  gap: 10px;
}

.families-list > .panel {
  margin: 0;
}

.families-section .pager {
  margin-top: 12px;
}

.family-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 38, 31, 0.04);
  padding: 14px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.family-card:active {
  transform: scale(0.99);
  border-color: rgba(27, 154, 104, 0.28);
  box-shadow: 0 6px 18px rgba(27, 154, 104, 0.1);
}

.family-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.family-card-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--teal-deep);
  background: linear-gradient(160deg, #dff5e9 0%, #c8ead6 100%);
  border: 1px solid rgba(27, 154, 104, 0.12);
}

.family-card-main .main {
  flex: 1;
  min-width: 0;
}

.family-card-main .main strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-card-main .main small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
  line-height: 1.35;
}

.family-card-arrow {
  flex: 0 0 auto;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.family-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.family-card-stats > div {
  text-align: center;
  min-width: 0;
  padding: 6px 4px;
  border-radius: var(--radius);
  background: #f4f9f6;
}

.family-card-stats b {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--teal-deep);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.family-card-stats span {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.3;
}

.danger-zone {
  padding: 14px;
  border: 1px dashed rgba(194, 59, 34, 0.35);
  border-radius: var(--radius);
  background: #fff8f6;
}

.logs-hero {
  margin-top: 4px;
}

.logs-hero .chips {
  padding-bottom: 12px;
}

.logs-filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 38, 31, 0.04);
  padding: 14px;
}

.logs-filters .field {
  margin: 0;
}

.logs-filters .field label {
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.logs-filters .field input,
.logs-filters .field select {
  height: var(--control-h);
  min-height: var(--control-h);
  font-size: 0.9rem;
  line-height: 1;
}

.logs-filter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.log-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 38, 31, 0.04);
  padding: 14px;
  margin-bottom: 10px;
}

.log-card:last-child {
  margin-bottom: 0;
}

.log-card.is-fail {
  border-color: rgba(194, 59, 34, 0.22);
  background: #fffaf8;
}

.log-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.log-card-top .main {
  flex: 1;
  min-width: 0;
}

.log-card-top .main strong {
  display: block;
  font-size: 1.05rem;
}

.log-card-top .main small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3px;
  line-height: 1.4;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.danger-text {
  color: var(--coral);
}

.ok-text {
  color: var(--teal);
}

.exam-opt {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--control-h);
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  margin: 0 0 8px;
  font: inherit;
  line-height: 1.45;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  box-sizing: border-box;
  gap: 8px;
}
.exam-opt:focus,
.exam-opt:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.exam-opt.active,
.exam-opt.is-selected,
.exam-opt.is-mine {
  border-color: var(--teal);
  background: rgba(27, 154, 104, 0.08);
}
.exam-opt-readonly {
  cursor: default;
}
.exam-opt.is-correct {
  border-color: var(--teal);
  background: rgba(27, 154, 104, 0.12);
}
.exam-opt.is-wrong {
  border-color: var(--danger);
  background: rgba(198, 40, 40, 0.08);
}
.exam-opt-tag {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--muted);
}
.exam-opt.is-correct .exam-opt-tag { color: var(--teal); }
.exam-opt.is-wrong .exam-opt-tag { color: var(--danger); }
.exam-result-choices {
  margin: 0 0 8px;
}
.exam-result-fill {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 0.95rem;
  line-height: 1.5;
}
.exam-result-fill .exam-opt-tag {
  margin: 0 8px 0 0;
}
.exam-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.exam-paper-title {
  margin: 0 0 10px;
  max-width: 100%;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "KaiTi_GB2312", "AR PL UKai CN", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.06em;
  color: var(--teal-deep);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exam-topbar .topbar h1 {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "KaiTi_GB2312", "AR PL UKai CN", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--teal-deep);
}
.exam-qmeta {
  margin: 0 0 8px;
}
.exam-stem {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.55;
  margin: 0 0 14px;
  white-space: pre-wrap;
  font-family: var(--font);
}
.exam-stem-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 10px;
}
.exam-stem-row .exam-stem {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.exam-read-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.exam-read-btn svg {
  width: 16px;
  height: 16px;
}
.exam-read-btn:hover,
.exam-read-btn:focus-visible {
  border-color: var(--teal);
  background: rgba(27, 154, 104, 0.08);
  outline: none;
}
.exam-read-btn.is-speaking {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}
.exam-read-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}
.exam-read-opts {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.exam-read-opts:hover,
.exam-read-opts:focus-visible {
  border-color: var(--teal);
  color: var(--teal);
  outline: none;
}
.exam-read-opts.is-speaking {
  border-color: var(--teal);
  background: rgba(27, 154, 104, 0.1);
  color: var(--teal);
}
.exam-fill {
  display: block;
  margin: 2px 0 4px;
}
.exam-fill-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.exam-fill-input {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.exam-fill-input::placeholder {
  color: var(--muted);
  font-weight: 500;
}
.exam-fill-input:hover {
  border-color: #c5d9ce;
}
.exam-fill-input:not(:placeholder-shown) {
  border-color: var(--teal);
  background: rgba(27, 154, 104, 0.08);
}
.exam-fill-input:focus,
.exam-fill-input:focus-visible {
  border-color: var(--teal);
  background: #fff;
  box-shadow: var(--focus);
}
.exam-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.exam-check:last-child { border-bottom: 0; }
.exam-check input[type="checkbox"] {
  width: var(--check-s);
  height: var(--check-s);
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--teal);
}
.field label.exam-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  height: var(--control-h);
  min-height: var(--control-h);
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}
.field label.exam-switch input[type="checkbox"] {
  width: var(--check-s);
  height: var(--check-s);
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--teal);
}
.exam-result-ok { color: var(--teal); }
.exam-result-bad { color: var(--danger); }

.exam-filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 38, 31, 0.04);
  padding: 14px 14px 16px;
  margin: 0 0 16px;
  display: grid;
  gap: 14px;
}
.exam-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.exam-filters .field label {
  margin-bottom: 6px;
}
.exam-filters + .panel {
  margin-top: 0;
}

.pick-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  padding-bottom: 4px;
}
.pick-filters {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
}
.pick-filters .field {
  margin: 0;
}
.pick-filters .field label {
  margin-bottom: 6px;
}
.pick-filters .exam-filter-row {
  gap: 8px;
}
.pick-toolbar > .hint {
  margin: 0 0 10px;
}
.modal-foot .pager {
  margin: 0 0 10px;
  padding: 0;
}
.modal-foot .pager .btn {
  min-width: 72px;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: var(--space-lg) var(--space) 40px;
}

.login-card {
  width: min(420px, 100%);
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 650;
  text-align: center;
}

.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.role-tag {
  display: block;
  text-align: center;
  margin-bottom: var(--space);
}

.login-card .form {
  margin-top: 4px;
}

.login-card .btn-block + .btn-block,
.login-card .btn-block + a.btn {
  margin-top: var(--space-md);
}
