/* ============================================================
   富豪工作台 · 设计系统 v4（Mercury 视觉语言）
   参考基准：Mercury Dashboard（深蓝黑 / 靛灰 Surface 分层 /
   Periwinkle 低饱和蓝紫强调 / 无金色 UI）
   金色仅存在于 Logo 品牌识别，不参与任何界面状态。
   Token 与组件规范：design-system/default/MASTER.md
   ============================================================ */

:root {
  /* ---- Surface：Page → Surface → Elevated 三层 ---- */
  --bg-page: #13141B;              /* 页面基底 · 靛蓝黑 */
  --bg-surface-1: #191A24;         /* 卡片 / 面板 */
  --bg-surface-2: #20212D;         /* 输入框 / 嵌套行 / 分段槽 */
  --bg-surface-3: #262735;         /* Elevated / 悬停 / 激活面 */
  --bg-raised: #1D1E29;            /* 弹窗 / 浮层 */

  /* ---- 边框（极弱） ---- */
  --border-weak: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* ---- 文字 ---- */
  --text-1: #F5F5F7;               /* 主文字 */
  --text-2: #A8A9B5;               /* 次文字 */
  --text-3: #86879A;               /* 标注（≥4.5:1 on surface-1/2） */

  /* ---- 强调色：Periwinkle（CTA / Active / 图表主系列） ---- */
  --accent: #747AF2;
  --accent-strong: #8187F5;
  --accent-soft: rgba(116, 122, 242, 0.14);
  --accent-border: rgba(129, 135, 245, 0.38);
  --on-accent: #FFFFFF;

  /* ---- 语义色 ---- */
  --positive: #3ECF8E;             /* 入账 / 收益 */
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.1);

  /* ---- 图表色（统一来自 Token） ---- */
  --chart-accent: #8187F5;         /* 主系列 */
  --chart-cyan: #5EC8E8;           /* 次系列 */
  --chart-grid: rgba(255, 255, 255, 0.045);

  --focus-ring: rgba(116, 122, 242, 0.3);

  /* ---- 间距 ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* 系统字体栈：数字用 tabular-nums，无外链字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;

  --transition: 180ms ease;
}

/* ============ 基础 ============ */

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-page);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent-strong); text-decoration: none; }

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }

.positive { color: var(--positive); }
.negative { color: var(--danger); }

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  vertical-align: -4px;
}

/* ============ 卡片（Solid Surface + 极弱顶光） ============ */

.card,
.table-card,
.login-card,
.modal {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

/* ============ 顶栏 ============ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(19, 20, 27, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-weak);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  height: 58px;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-1);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.brand small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  line-height: 1.2;
}

.topnav {
  display: none;
  gap: 2px;
  margin-left: var(--space-md);
}

.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}

.topnav a:hover {
  color: var(--text-1);
  background: var(--bg-surface-3);
}

.topnav a.active {
  color: var(--text-1);
  background: var(--bg-surface-3);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* 导航加载条 */
.nav-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

.nav-progress::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent-strong), transparent);
}

.nav-progress.on { opacity: 1; }

.nav-progress.on::after { animation: navSlide 900ms ease-in-out infinite; }

@keyframes navSlide {
  from { transform: translateX(-100%); }
  to { transform: translateX(350%); }
}

/* ============ 主区域 ============ */

.view {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) calc(84px + env(safe-area-inset-bottom));
}

.view > section + section { margin-top: var(--space-lg); }

@media (prefers-reduced-motion: no-preference) {
  /* 仅位移淡入：不用 opacity（动画时间线被暂停时内容必须保持可见） */
  .view > * { animation: viewIn 240ms ease backwards; }
  .view > *:nth-child(2) { animation-delay: 40ms; }
  .view > *:nth-child(3) { animation-delay: 80ms; }
  .view > *:nth-child(n+4) { animation-delay: 120ms; }
}

@keyframes viewIn {
  from { transform: translateY(6px); }
  to { transform: none; }
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  color: var(--text-1);
}

.section-title .icon { color: var(--text-3); }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-head .sub {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 2px;
}

/* ============ 富豪日报 · 头部 + Quick Actions ============ */

.daily-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.daily-head h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.daily-head .sub {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 3px;
}

.quick-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

.qa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.qa-btn .icon { width: 15px; height: 15px; color: var(--text-2); }

.qa-btn:hover { background: var(--bg-surface-3); border-color: var(--border-strong); }

.qa-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.qa-btn.primary .icon { color: var(--on-accent); }

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

/* ============ 富豪日报 · Dashboard Grid ============ */

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: var(--space-md);
  align-items: stretch;
}

@media (max-width: 899px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ---- 资产卡：Balance + Trend 融合 ---- */

.balance-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  padding: var(--space-md) var(--space-lg) var(--space-sm);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.balance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.balance-label { font-size: 13px; color: var(--text-2); }

.range-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface-2);
  border-radius: 8px;
  padding: 2px;
}

.range-tabs button {
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.range-tabs button:hover { color: var(--text-1); }

.range-tabs button.active {
  background: var(--bg-surface-3);
  color: var(--text-1);
}

.balance-value .amt-dec {
  font-size: 0.55em;
  opacity: 0.55;
  font-weight: 600;
  letter-spacing: 0;
}

.balance-value {
  font-size: clamp(28px, 3.6vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-top: 4px;
  color: var(--text-1);
}

.balance-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.balance-stats {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-3);
}

.balance-stats .bs { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }

.balance-stats .v {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

.balance-stats .v.positive { color: var(--positive); }
.balance-stats .v.negative { color: var(--danger); }

.balance-chart {
  position: relative;
  height: 190px;
  margin: var(--space-sm) calc(var(--space-md) * -1) 0;
}

/* ---- 门店卡：Accounts 式列表 ---- */

.stores-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  padding: var(--space-md) 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.stores-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg) 10px;
  font-size: 13px;
  color: var(--text-2);
}

.store-rows { flex: 1; }

.store-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 11px var(--space-lg);
  border-top: 1px solid var(--border-weak);
  transition: background var(--transition);
}

.store-row:hover { background: rgba(255, 255, 255, 0.02); }

.store-row-info { min-width: 0; }

.store-row .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.store-row .name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.store-row .sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

.store-row .figures { text-align: right; flex-shrink: 0; }

.store-row .roi {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

.store-row .roi.positive { color: var(--positive); }

.store-row .io {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid var(--border-weak);
  font-size: 13px;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}

.card-foot:hover { background: var(--bg-surface-2); color: var(--text-1); }

/* ============ 富豪日报 · 本月（紧凑单卡三栏） ============ */

.month-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-surface-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.month-cell {
  padding: 13px var(--space-lg);
  min-width: 0;
}

.month-cell + .month-cell { border-left: 1px solid var(--border-weak); }

.month-cell .k { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.month-cell .v {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  white-space: nowrap;
}

.month-cell .delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  margin-top: 3px;
  color: var(--text-3);
}

.month-cell .delta.up { color: var(--positive); }
.month-cell .delta.down { color: var(--danger); }

@media (max-width: 599px) {
  .balance-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px var(--space-md); }
  .month-row { grid-template-columns: 1fr; }
  .month-cell + .month-cell { border-left: none; border-top: 1px solid var(--border-weak); }
}

/* ============ 富豪日报 · 最近动态 ============ */

.activity {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  padding: 2px 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.act-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 11px var(--space-lg);
  border-bottom: 1px solid var(--border-weak);
}

.act-item:last-child { border-bottom: none; }

.act-date {
  width: 44px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.act-date .y { display: block; font-size: 10px; color: var(--text-3); opacity: 0.85; }

.act-body { flex: 1; min-width: 0; }

.act-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-amt {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.act-amt .sign { font-weight: 600; }

/* ============ 表格 ============ */

.rwd {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.rwd th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.rwd td {
  padding: 12px;
  border-bottom: 1px solid var(--border-weak);
  vertical-align: middle;
}

.rwd tbody tr:last-child td { border-bottom: none; }

.rwd tbody tr { transition: background var(--transition); }

.rwd tbody tr:hover { background: rgba(255, 255, 255, 0.022); }

.rwd .num, .rwd th.num { text-align: right; }

.rwd td strong { font-weight: 600; }

.rwd tfoot td {
  font-weight: 600;
  border-bottom: none;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.table-card {
  padding: 2px var(--space-sm);
  overflow-x: auto;
}

.table-card .rwd td:last-child,
.table-card .rwd th:last-child { padding-right: var(--space-md); }

.actions-cell { text-align: right; white-space: nowrap; }

@media (min-width: 768px) {
  .actions-cell .icon-btn { opacity: 0.45; transition: opacity var(--transition), background var(--transition), color var(--transition); }
  .actions-cell .icon-btn:hover,
  .rwd tr:hover .actions-cell .icon-btn { opacity: 1; }
}

.th-sub {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-3);
}

.cell-trio { display: grid; gap: 2px; }

.cell-trio .ct-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.cell-trio .ct-k { font-size: 11px; color: var(--text-3); }

@media (max-width: 639px) {
  .rwd thead { display: none; }
  .rwd, .rwd tbody, .rwd tr, .rwd td { display: block; }
  .rwd tr {
    border-bottom: 1px solid var(--border-weak);
    padding: var(--space-sm) 0;
  }
  .rwd tr:last-child { border-bottom: none; }
  .rwd td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-md);
    padding: 5px 12px;
    border-bottom: none;
    text-align: right;
  }
  .rwd td::before {
    content: attr(data-label);
    color: var(--text-3);
    font-size: 12px;
    text-align: left;
    flex-shrink: 0;
  }
  .rwd td.no-label::before { content: none; }
  .rwd tfoot td { background: none; border-top: 1px solid var(--border); }
  /* 移动列表：大金额/长 token 允许断行，防止撑破视口 */
  .rwd td { min-width: 0; }
  .rwd td * { overflow-wrap: anywhere; }
}

/* 日期/人员等关键字段不折行（仅桌面表格；移动列表允许换行防溢出） */
@media (min-width: 640px) {
  .rwd .nowrap { white-space: nowrap; }
}

/* 中等宽度：隐藏低价值备注列，保住日期与人员的单行可读性 */
@media (min-width: 640px) and (max-width: 1023px) {
  .rwd .col-note { display: none; }
}

/* ============ 按钮 ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn .icon { width: 16px; height: 16px; }

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover { transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

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

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-1);
  border-color: var(--border);
}

.btn-secondary:hover { background: var(--bg-surface-3); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.28);
}

.btn-danger:hover { background: rgba(248, 113, 113, 0.18); }

.btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover { background: var(--bg-surface-3); color: var(--text-1); }

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

.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ 表单 ============ */

.field { margin-bottom: var(--space-md); }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-1);
}

.field .req { color: var(--accent-strong); }

.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-1);
  font-size: 16px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

textarea.input { min-height: 72px; resize: vertical; }

.input::placeholder { color: rgba(128, 129, 144, 0.7); }

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

.input[aria-invalid='true'] { border-color: var(--danger); }

select.input {
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A8A9B5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

/* 原生下拉弹层：Windows/Chrome 不继承页面主题，需显式深色配色 */
select.input option {
  background: var(--bg-raised);
  color: var(--text-1);
}

select.input option:checked,
select.input option:hover {
  background: var(--accent);
  color: var(--on-accent);
}

input[type='date'].input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.field-error {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger);
}

.field-error.show { display: block; }

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}

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

@media (max-width: 539px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
}

.filter-bar {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.filter-bar .input {
  min-height: 40px;
  font-size: 14px;
  width: auto;
  min-width: 0; /* flex 项可收缩到容器内（超长门店名的 option 不撑破布局） */
  flex: 0 1 180px;
}

/* ============ 列表行 ============ */

.row-list { display: flex; flex-direction: column; gap: var(--space-md); }

.row-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 13px var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-weak);
  transition: border-color var(--transition), background-color var(--transition);
}

.row-item:hover {
  background: var(--bg-surface-3);
  border-color: var(--border);
}

.row-item .grow { flex: 1; min-width: 0; }

.row-item .title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-item .desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-weak);
}

/* 分红明细 */

.split-list { display: grid; gap: 6px; margin-top: 10px; }

.split-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.split-item .ratio { color: var(--text-3); font-size: 12px; }

.split-item .badge { white-space: nowrap; }

.split-item .amt {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-1);
}

/* 分红记录卡头部 */
.div-card { padding: var(--space-md) var(--space-lg); }

.div-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.div-info { flex: 1; min-width: 200px; }

.div-info .name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 15px;
}

.div-info .meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }

.div-total { flex-shrink: 0; text-align: right; }

.div-total .k { font-size: 11px; color: var(--text-3); }

.div-total .v .amt-dec {
  font-size: 0.7em;
  opacity: 0.55;
}

.div-total .v {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.div-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* chips */

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--space-md); }

.chip {
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.chip:hover { color: var(--text-1); background: var(--bg-surface-2); }

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

/* ============ 登录页 ============ */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-md);
}

.login-card {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.login-card .logo-mark {
  width: 54px;
  height: 54px;
  font-size: 25px;
  border-radius: 14px;
  margin: 0 0 var(--space-md);
}

.login-card h1 { font-size: 22px; font-weight: 700; }

.login-card .sub {
  color: var(--text-3);
  font-size: 13px;
  margin: 6px 0 var(--space-lg);
}

.login-card .btn-primary { width: 100%; margin-top: var(--space-sm); }

.install-hint {
  margin: var(--space-md) 0 0;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.form-error {
  display: none;
  margin-top: var(--space-md);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  font-size: 13px;
  text-align: left;
}

.form-error.show { display: flex; align-items: center; gap: 8px; }

/* ============ 底部标签栏 ============ */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(15, 16, 22, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-weak);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  min-height: 44px;
  justify-content: center;
}

.tabbar a .icon { width: 21px; height: 21px; }

.tabbar a.active { color: var(--text-1); }

@media (min-width: 768px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .view { padding-top: var(--space-xl); }
  .topbar-actions .mobile-only { display: none; }
}

.mobile-only { display: inline-grid; }

/* ============ 弹窗 ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 9, 14, 0.65);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  animation: fadeIn 160ms ease;
}

.modal {
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  animation: modalIn 180ms ease;
}

.modal.wide { max-width: 640px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-weak);
}

.modal-head h2 { font-size: 16px; font-weight: 700; }

.modal-body { padding: var(--space-lg); overflow-y: auto; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-weak);
}

.modal-foot .btn { min-width: 96px; }

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

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ 提示条 ============ */

#toast-root {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  animation: toastIn 200ms ease;
}

.toast.success .icon { color: var(--positive); }
.toast.error .icon { color: var(--danger); }

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

/* ============ 空状态 ============ */

.empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--text-3);
}

.empty-sm { padding: var(--space-xl); }
.empty-tall { padding: 40px 0; }

.empty .icon { width: 40px; height: 40px; opacity: 0.45; }

.empty p { margin: 10px 0 16px; font-size: 14px; color: var(--text-2); }

/* ============ 加载骨架 ============ */

.skeleton { padding: var(--space-2xl); text-align: center; color: var(--text-3); font-size: 14px; }

.sk-block {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.sk-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-3) 45%, var(--bg-surface-2) 65%);
  background-size: 240% 100%;
  animation: shimmer 1.4s ease infinite;
  margin-bottom: 12px;
}

.sk-line:last-child { margin-bottom: 0; }

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

/* ============ 杂项 ============ */

.inline-note {
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.inline-note .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }

.preview-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  padding: var(--space-md);
  margin-top: var(--space-sm);
}

/* 分红分配预览表 */
.alloc-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.alloc-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.alloc-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-weak);
  vertical-align: middle;
}

.alloc-table tr:last-child td { border-bottom: none; }

.alloc-table .num, .alloc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.alloc-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.alloc-total .k { font-size: 12px; color: var(--text-3); }

.alloc-total .v {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.alloc-check {
  width: 100%;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.alloc-check .icon { width: 14px; height: 14px; color: var(--positive); }

.alloc-check.error { color: var(--danger); }
.alloc-check.error .icon { color: var(--danger); }

.preview-box .p-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  padding: 6px 0;
  font-size: 14px;
}

.preview-box .p-row + .p-row { border-top: 1px solid var(--border-weak); }

/* 历史快照提示（编辑分红时） */
.snapshot-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: var(--space-md);
}

.snapshot-note .icon { width: 14px; height: 14px; margin-top: 2px; color: var(--accent-strong); flex-shrink: 0; }

.export-row { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* ============ 设置页 ============ */

.settings-block .card { padding: var(--space-lg); }

.settings-grid .section-title { justify-content: flex-start; gap: 8px; }

.settings-grid .section-title .icon {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  flex-shrink: 0;
}

.settings-grid { display: grid; gap: var(--space-lg); }

.settings-grid .settings-block + .settings-block { margin-top: 0; }

.settings-block { display: flex; flex-direction: column; }

.settings-block .settings-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#pwd-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-weak);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}

.card-note .icon {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  color: var(--text-3);
}

.pwd-wrap { position: relative; }

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

.pwd-wrap .pwd-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
}

.pwd-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  margin-bottom: var(--space-md);
}

.add-person-row .input { flex: 1; min-width: 0; }

.backup-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.backup-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-weak);
  color: var(--text-2);
}

.backup-note { flex: 1; min-width: 220px; font-size: 13px; color: var(--text-2); }

.backup-card .btn { flex-shrink: 0; }

@media (min-width: 900px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-xl);
  }
  .settings-block--wide { grid-column: 1 / -1; }
}

/* ============ 头像（人员序列，与图表 PERSON_COLORS 一致） ============ */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--bg-surface-2);
  color: var(--text-1);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.avatar.c0 { background: rgba(129, 135, 245, 0.14); color: #A5AAFF; border-color: rgba(129, 135, 245, 0.32); }
.avatar.c1 { background: rgba(94, 200, 232, 0.12); color: #7DD8F2; border-color: rgba(94, 200, 232, 0.3); }
.avatar.c2 { background: rgba(62, 207, 142, 0.12); color: #5FDCA4; border-color: rgba(62, 207, 142, 0.3); }
.avatar.c3 { background: rgba(240, 171, 252, 0.12); color: #F0ABFC; border-color: rgba(240, 171, 252, 0.28); }
.avatar.c4 { background: rgba(147, 197, 253, 0.12); color: #93C5FD; border-color: rgba(147, 197, 253, 0.28); }
.avatar.c5 { background: rgba(253, 164, 175, 0.12); color: #FDA4AF; border-color: rgba(253, 164, 175, 0.28); }

.split-item .avatar { width: 26px; height: 26px; font-size: 12px; }

/* 设置页人员行仍在用 */
.row-item .avatar { width: 32px; height: 32px; font-size: 13px; }

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