/* ============================================================
   如山 · 数据管理后台
   移动端优先，兼容平板 / PC
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-soft: #eaf0fa;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef3fb;
  --border: #e1e8f3;
  --border-strong: #ccd8ea;
  --text: #1b2430;
  --text-soft: #3c4a5d;
  --muted: #5b6a7e;
  --faint: #5f6e82;
  --primary: #4d8dff;
  --primary-strong: #255fca;
  --primary-soft: #e8f0ff;
  --primary-ring: rgba(77, 141, 255, 0.28);
  --primary-button: #2f6fe0;
  --primary-button-hover: #255fca;
  --on-primary: #ffffff;
  --danger: #c92a2f;
  --danger-strong: #a91f24;
  --danger-soft: #ffecec;
  --success: #0f7a43;
  --success-soft: #e7f7ee;
  --warning: #9a5a00;
  --warning-soft: #fff5e0;
  --shadow-sm: 0 1px 2px rgba(23, 43, 77, 0.05);
  --shadow: 0 8px 24px rgba(23, 43, 77, 0.07);
  --shadow-lg: 0 24px 60px rgba(23, 43, 77, 0.16);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --sidebar-w: 248px;
  --topbar-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d131c;
  --bg-soft: #111a26;
  --surface: #151e2b;
  --surface-2: #1a2433;
  --surface-3: #202c3d;
  --border: #263346;
  --border-strong: #35455c;
  --text: #eaf0f8;
  --text-soft: #c6d2e2;
  --muted: #9aa9bd;
  --faint: #7f8fa5;
  --primary: #6ba0ff;
  --primary-strong: #8ab5ff;
  --primary-soft: rgba(77, 141, 255, 0.16);
  --primary-ring: rgba(107, 160, 255, 0.32);
  --primary-button: #2f6fe0;
  --primary-button-hover: #3d7cf0;
  --on-primary: #ffffff;
  --danger: #ff6b70;
  --danger-strong: #ff868a;
  --danger-soft: rgba(229, 72, 77, 0.16);
  --success: #4cd58b;
  --success-soft: rgba(24, 160, 88, 0.18);
  --warning: #f0b34c;
  --warning-soft: rgba(194, 118, 10, 0.2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.5);
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--primary);
}

h1, h2, h3, h4, p, dl, dd, dt {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
}

/* ---------------- 通用组件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    transform 0.08s ease, box-shadow 0.16s ease;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.tab-item:focus-visible,
.nav-item:focus-visible,
.link-btn:focus-visible,
.copy-btn:focus-visible,
.page-btn:focus-visible,
.eye-btn:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary-button);
  color: var(--on-primary);
  box-shadow: 0 6px 16px rgba(47, 111, 224, 0.22);
}

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

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-soft);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

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

.btn-danger:hover {
  background: var(--danger-strong);
}

.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
}

.link-btn:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin-top: 6px;
}

.req {
  color: var(--danger);
  font-weight: 700;
}

/* ---------------- 品牌 / 启动 / 登录 ---------------- */

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  background: linear-gradient(145deg, #6fa5ff, #4d8dff);
  color: #fff;
  font-size: 23px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(77, 141, 255, 0.28);
}

.brand-mark-lg {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  font-size: 30px;
}

.boot-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
}

.auth {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 8% -5%, rgba(77, 141, 255, 0.16), transparent 62%),
    radial-gradient(900px 600px at 100% 100%, rgba(255, 143, 171, 0.14), transparent 60%),
    var(--bg);
}

.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
}

.auth-glow-a {
  width: 300px;
  height: 300px;
  top: -110px;
  right: -90px;
  background: rgba(77, 141, 255, 0.28);
}

.auth-glow-b {
  width: 260px;
  height: 260px;
  bottom: -120px;
  left: -90px;
  background: rgba(255, 143, 171, 0.24);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 424px;
  padding: 26px 22px 22px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  animation: card-in 0.35s ease both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 26px;
}

.auth-brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.auth-brand p {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 1px;
}

.auth-card h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.auth-sub {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-links {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.auth-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.6;
  text-align: center;
}

.input-wrap {
  position: relative;
  display: flex;
}

.input-wrap input {
  padding-right: 48px;
}

.eye-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 17px;
  opacity: 0.65;
}

.eye-btn:hover {
  background: var(--surface-2);
  opacity: 1;
}

.config-box {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.config-box summary {
  padding: 12px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  user-select: none;
}

.config-box summary:hover {
  color: var(--text-soft);
}

.config-body {
  display: grid;
  gap: 10px;
  padding: 2px 14px 14px;
}

.config-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------- 表单 ---------------- */

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span:first-child {
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.1px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field textarea {
  resize: vertical;
  min-height: 84px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--faint);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--border-strong);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface);
}

.field input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

.field input[type="color"] {
  padding: 5px;
  min-height: 44px;
  cursor: pointer;
}

.field span-2,
.span-2 {
  grid-column: 1 / -1;
}

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

@media (min-width: 560px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--primary);
  flex: none;
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.5;
}

/* ---------------- 应用骨架 ---------------- */

.app {
  min-height: 100dvh;
}

.shell {
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  background: var(--primary-soft);
  font-size: 20px;
}

.topbar-title div {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.topbar-title strong {
  font-size: 15.5px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-brand-sub,
.topbar-page-sub {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-page-name,
.topbar-page-sub {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions .icon-btn {
  width: 38px;
  height: 38px;
}

.main {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 14px calc(88px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 6px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--faint);
  font-size: 18px;
  transition: color 0.16s ease, background 0.16s ease;
}

.tab-item small {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.tab-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------------- 视图 / 页头 ---------------- */

.view {
  animation: view-in 0.2s ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.page-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------- 概览 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 15px 15px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent, var(--primary));
  opacity: 0.8;
}

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

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.stat-icon {
  font-size: 16px;
  opacity: 0.8;
}

.stat-value {
  margin-top: 6px;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.stat-hint {
  margin-top: 4px;
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: 14.5px;
  font-weight: 750;
}

.panel-head p {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 1px;
}

.panel-body {
  padding: 14px 16px;
}

.recent-list {
  display: grid;
  gap: 2px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}

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

.recent-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  background: var(--surface-2);
  font-size: 18px;
}

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

.recent-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 650;
}

.recent-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  text-align: left;
  font-size: 13px;
  font-weight: 650;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.08s ease;
}

.quick-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.quick-btn:active {
  transform: translateY(1px);
}

.quick-btn span:first-child {
  font-size: 19px;
}

/* ---------------- 工具栏 / 列表 ---------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14.5px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-wrap input::placeholder {
  color: var(--faint);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.search-ico {
  position: absolute;
  top: 50%;
  left: 13px;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 15px;
  pointer-events: none;
}

.toolbar-count {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.baby-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.baby-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.baby-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 16px;
  background: color-mix(in srgb, var(--avatar-color, #4d8dff) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--avatar-color, #4d8dff) 30%, transparent);
  font-size: 28px;
}

.baby-title {
  min-width: 0;
  flex: 1;
}

.baby-title h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 17px;
  font-weight: 750;
  line-height: 1.3;
}

.baby-title p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.baby-id {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  min-width: 0;
}

.baby-id > span {
  flex: none;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 650;
}

.baby-id code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
  font-size: 12px;
}

.copy-btn {
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.copy-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.baby-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.baby-meta div {
  min-width: 0;
}

.baby-meta dt {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
}

.baby-meta dd {
  margin-top: 1px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ---------------- 记录筛选 ---------------- */

.filter-panel {
  padding: 13px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.filter-grid .field > span:first-child {
  font-size: 11.5px;
}

.filter-grid .field input,
.filter-grid .field select {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13.5px;
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.filter-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 2px 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.filter-summary strong {
  color: var(--text);
}

.record-list {
  display: grid;
  gap: 9px;
}

.record-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 11px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, opacity 0.16s ease;
}

.record-item:hover {
  border-color: var(--border-strong);
}

.record-item.is-deleted {
  opacity: 0.58;
  background: var(--surface-2);
}

.record-item.is-deleted .record-title {
  text-decoration: line-through;
  text-decoration-color: var(--faint);
}

.record-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--type-color, #4d8dff) 15%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--type-color, #4d8dff) 26%, transparent);
  font-size: 21px;
}

.record-main {
  min-width: 0;
}

.record-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.record-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
}

.record-note {
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.55;
  word-break: break-word;
}

.record-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.record-actions .btn {
  min-height: 34px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-info {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 成员 ---------------- */

.callout {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.6;
}

.callout > span {
  flex: none;
  font-size: 16px;
}

.callout details {
  margin-top: 7px;
}

.callout summary {
  cursor: pointer;
  color: var(--primary-strong);
  font-weight: 650;
  font-size: 12px;
}

.callout pre {
  margin: 8px 0 0;
  padding: 10px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.55;
}

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

.member-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px;
}

.member-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.member-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 20px;
}

.member-info {
  min-width: 0;
  flex: 1;
}

.member-info h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 14.5px;
  font-weight: 700;
}

.member-info p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.member-info .mono {
  font-size: 11px;
}

/* ---------------- 空状态 / 加载 ---------------- */

.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  padding: 30px 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 220px;
  padding: 32px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

.empty-emoji {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 2px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.empty-state p {
  max-width: 420px;
  font-size: 12.5px;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: 8px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------- 模态框 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(12, 20, 33, 0.52);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease both;
}

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

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes sheet-up {
  from { transform: translateY(36px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 12px;
}

.modal-title {
  flex: 1;
  min-width: 0;
}

.modal-title h2 {
  font-size: 17.5px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.modal-title p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 17px;
}

.modal-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

.modal-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.modal-body {
  padding: 4px 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-foot {
  display: flex;
  gap: 9px;
  padding: 13px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.modal-foot .btn {
  flex: 1;
}

.modal-foot .btn-primary,
.modal-foot .btn-danger {
  flex: 1.4;
}

.modal-error {
  margin: 0 18px 12px;
}

.confirm-text {
  padding: 6px 0 8px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

/* ---------------- Toast ---------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.45;
  text-align: center;
  animation: toast-in 0.22s ease both;
  word-break: break-word;
}

.toast-success {
  border-color: color-mix(in srgb, var(--success) 34%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.toast-error {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   平板
   ============================================================ */
@media (min-width: 600px) {
  .main {
    padding: 20px 22px 40px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .baby-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid .span-2 {
    grid-column: 1 / -1;
  }

  .record-item {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: start;
    padding: 14px 15px;
  }

  .record-emoji {
    width: 46px;
    height: 46px;
  }

  .record-actions {
    grid-column: auto;
    border-top: 0;
    padding-top: 0;
    align-self: center;
  }

  .member-card {
    flex-direction: row;
    align-items: center;
  }

  .member-card .card-actions {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
    flex: none;
  }

  .dash-grid {
    grid-template-columns: 1.35fr 1fr;
  }

  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }

  .modal {
    max-width: 600px;
    max-height: 88dvh;
    border-radius: 20px;
    animation: modal-pop 0.2s ease both;
  }

  @keyframes modal-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: none; }
  }

  .modal-foot {
    padding-bottom: 14px;
  }

  .toast-root {
    left: auto;
    right: 22px;
    bottom: 22px;
    transform: none;
    align-items: flex-end;
  }

  .toast {
    text-align: left;
  }
}

/* ============================================================
   桌面：侧边栏
   ============================================================ */
@media (min-width: 960px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    padding: 22px 14px 18px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 8px 22px;
  }

  .sidebar-brand > div:last-child {
    display: grid;
    line-height: 1.3;
  }

  .sidebar-brand strong {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.1px;
  }

  .sidebar-brand span {
    color: var(--muted);
    font-size: 11px;
  }

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

  .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 46px;
    padding: 0 12px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    transition: background 0.16s ease, color 0.16s ease;
  }

  .nav-item:hover {
    background: var(--surface-2);
    color: var(--text-soft);
  }

  .nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-weight: 700;
  }

  .nav-ico {
    width: 22px;
    text-align: center;
    font-size: 16px;
  }

  .sidebar-foot {
    display: grid;
    gap: 10px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }

  .user-card {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    padding: 8px;
    border-radius: 11px;
    background: var(--surface-2);
  }

  .user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 15px;
    font-weight: 700;
  }

  .user-meta {
    display: grid;
    min-width: 0;
    line-height: 1.3;
  }

  .user-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 650;
  }

  .user-meta span {
    color: var(--faint);
    font-size: 10.5px;
  }

  .shell {
    margin-left: var(--sidebar-w);
  }

  .topbar {
    padding: 10px 28px;
  }

  .topbar-mark {
    display: none;
  }

  .topbar-brand-name,
  .topbar-brand-sub {
    display: none;
  }

  .topbar-page-name,
  .topbar-page-sub {
    display: block;
  }

  .topbar-title strong {
    font-size: 18px;
  }

  .page-head h1 {
    display: none;
  }

  .page-head p {
    margin-top: 0;
    font-size: 13.5px;
  }

  .main {
    padding: 26px 30px 52px;
  }

  .tabbar {
    display: none;
  }

  .toast-root {
    bottom: 26px;
  }

  .page-head h1 {
    font-size: 25px;
  }

  .baby-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filter-grid .span-2 {
    grid-column: span 2;
  }

  .record-actions .btn {
    min-height: 36px;
  }
}

@media (min-width: 1240px) {
  .baby-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (hover: none) {
  .record-item:hover,
  .baby-card:hover {
    border-color: var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
