/* components.css — 卡片、汇总、导航、分段、抽屉、浮层
 * 只引用 tokens 变量；任何颜色都不得硬编码。
 */

/* ------------------------------- 基础卡片 ------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.card--flat {
  box-shadow: none;
}

.card__title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
}

.card__text {
  margin: 0;
  color: var(--text-2);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.muted {
  color: var(--text-2);
}

.tiny {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

/* ------------------------------- 汇总区 -------------------------------- */

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.stat__label {
  color: var(--text-2);
  font-size: var(--text-2xs);
  white-space: nowrap;
}

.stat__value {
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat__value--warn {
  color: var(--warn);
}

.stat__unit {
  font-size: var(--text-2xs);
  font-weight: 400;
  color: var(--text-2);
  margin-left: 2px;
}

/* ------------------------------- 筛选条 -------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

.filter-pill {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

.filter-pill.is-active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.filter-pill__count {
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* ------------------------------- 订阅卡片 ------------------------------- */

.sub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  color: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.sub-card:active {
  transform: scale(0.995);
}

.sub-card[data-due="true"] {
  border-color: var(--warn-line);
  background: linear-gradient(180deg, var(--warn-bg) 0%, var(--surface) 62%);
}

.sub-card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.sub-card__icon {
  flex: 0 0 auto;
}

.sub-card__titles {
  flex: 1 1 auto;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sub-card__name {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-card__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--text-2);
  font-size: var(--text-xs);
}

.sub-card__meta > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-card__price {
  flex: 0 1 auto;
  max-width: 54%;
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0 2px;
  padding-left: var(--space-2);
  text-align: right;
  white-space: nowrap;
}

.price__main {
  grid-column: 1;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.price__suffix {
  margin-left: 1px;
  color: var(--text-3);
  font-size: var(--text-xs);
  font-weight: 500;
}

.price__sub {
  grid-column: 1;
  max-width: 100%;
  color: var(--text-3);
  font-size: var(--text-2xs);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price__sep {
  margin: 0 3px;
}

.price__note {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price__chev {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  color: var(--text-3);
}

.price__chev svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sub-card__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.due-label {
  color: var(--text-3);
  font-size: var(--text-xs);
}

.due-date {
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- 胶囊与徽标 ------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pill--due {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge--warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge--soft {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 500;
}

/* -------------------------------- 图标 --------------------------------- */

.icon-tile {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 22%;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--cat-color, #9aa0a6) 14%, var(--surface));
  color: var(--cat-color, var(--text-2));
  overflow: hidden;
}

.icon-tile--sm {
  width: 32px;
  height: 32px;
}

.icon-tile--lg {
  width: 52px;
  height: 52px;
}

.icon-tile__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.icon-tile__svg {
  width: 21px;
  height: 21px;
  display: block;
}

.icon-tile--lg .icon-tile__svg {
  width: 26px;
  height: 26px;
}

.icon-tile__letter {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
}

/* -------------------------------- 按钮 --------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: 76px;
  padding: 0 var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  background: var(--surface-2);
}

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

.btn--primary:active {
  background: var(--accent-press);
}

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

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

.btn--block {
  width: 100%;
}

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

.btn--auto {
  min-width: 0;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  color: var(--text-2);
  font-size: var(--text-xs);
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  /* iOS Safari：小于 16px 会在聚焦时自动放大页面 */
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select.input,
textarea.input {
  font-size: 16px;
}

.input-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

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

/* ------------------------------ 分段控件 -------------------------------- */

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented__btn {
  flex: 1;
  min-height: 36px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
}

.segmented__btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ------------------------------- 侧栏导航 ------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
}

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

.nav__label {
  padding: 0 var(--space-2);
  margin-bottom: 6px;
  color: var(--text-3);
  font-size: var(--text-2xs);
  letter-spacing: 0.04em;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 38px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

.nav__item:hover {
  background: var(--surface-2);
}

.nav__item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav__icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav__count {
  margin-left: auto;
  color: var(--text-3);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
}

.nav__item.is-active .nav__count {
  color: var(--accent);
}

.nav__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: auto;
  background: var(--warn);
}

/* ------------------------------- 空状态 -------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.empty__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
}

.empty__text {
  margin: 0;
  max-width: 34em;
  color: var(--text-2);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.empty__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}

/* -------------------------------- 抽屉 --------------------------------- */

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.sheet-root.is-open {
  display: block;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  opacity: 0;
  transition: opacity 0.2s ease;
  overscroll-behavior: contain;
  touch-action: none;
}

.sheet-root.is-open .sheet__backdrop {
  opacity: 1;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-sheet);
  transform: translateY(14px);
  transition: transform 0.22s ease;
  overflow: hidden;
}

.sheet-root.is-open .sheet {
  transform: translateY(0);
}

.sheet__grabber {
  flex: 0 0 auto;
  width: 36px;
  height: 5px;
  margin: 8px auto 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.sheet__head {
  flex: 0 0 auto;
  padding: var(--space-2) var(--space-5) var(--space-3);
}

.sheet__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 650;
  line-height: 1.3;
}

.sheet__subtitle {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-5) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sheet__actions {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5) calc(var(--space-3) + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.sheet__actions .btn {
  flex: 1;
}

.sheet-note {
  margin: 0;
  color: var(--text-3);
  font-size: var(--text-2xs);
  line-height: 1.5;
}

/* 详情抽屉里的分组 */
.kv {
  display: flex;
  flex-direction: column;
  margin: 0;
  border-top: 1px solid var(--line);
}

.kv__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.kv__key {
  margin: 0;
  color: var(--text-2);
  font-size: var(--text-sm);
}

.kv__value {
  margin: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.section-label {
  margin: 0 0 var(--space-2);
  color: var(--text-3);
  font-size: var(--text-2xs);
  letter-spacing: 0.04em;
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.mini-item__note {
  color: var(--text-2);
  font-size: var(--text-xs);
}

/* --------------------------- 4 秒撤回浮层 ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--tab-h) + var(--space-3));
  z-index: 70;
  transform: translate(-50%, 8px);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast__text {
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast__action {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.toast__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: currentColor;
  opacity: 0.5;
  transform-origin: left center;
  animation: toast-countdown 4s linear forwards;
}

@keyframes toast-countdown {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (min-width: 680px) {
  .toast {
    bottom: calc(var(--safe-bottom) + var(--space-6));
  }

  .sheet {
    border-radius: var(--radius-lg);
    bottom: var(--space-4);
    max-height: 86vh;
    max-height: 86dvh;
  }

  .sheet__actions {
    padding-bottom: var(--space-3);
  }
}

@media (min-width: 1024px) {
  .summary {
    max-width: 560px;
  }
}

/* =========================== M2-B 新增组件 =========================== */

/* -------------------------------- 汇总卡 -------------------------------- */

.hero {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.hero__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.hero__label {
  color: var(--text-2);
  font-size: var(--text-xs);
}

.hero__value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero__currency {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-2);
}

.hero__hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.hero__switch {
  color: var(--accent);
  font-weight: 600;
}

.pill--soft {
  background: var(--surface-2);
  color: var(--text-2);
}

.pill--soon {
  background: var(--info-bg);
  color: var(--info);
}

/* -------------------------------- 搜索行 -------------------------------- */

.search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.search--inline {
  margin-bottom: 0;
}

.search__icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--text-3);
}

.search__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.search__input {
  flex: 1;
  min-width: 0;
}

.search__clear {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 var(--space-2);
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: var(--text-sm);
  cursor: pointer;
}

/* -------------------------------- 图标按钮 ------------------------------- */

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

.icon-btn svg {
  display: block;
  width: 21px;
  height: 21px;
}

.icon-btn:active,
.icon-btn.is-active {
  background: var(--surface-2);
  color: var(--accent);
}

.icon-btn--accent {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 16px rgba(47, 124, 246, 0.28);
}

.icon-btn--accent:active {
  background: var(--accent-press);
  color: var(--on-accent);
}

.icon-btn--tiny {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: var(--text-sm);
  color: var(--text-2);
}

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

.icon-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}

/* ------------------------------ 分类色点 ------------------------------- */

.cat-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cat-color, var(--text-3));
}

/* ---------------------------- 筛选导航 / 侧栏 --------------------------- */

.filter-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.nav__text {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__count--accent {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-2xs);
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.side-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: none;
}

.side-drawer-root.is-open {
  display: block;
}

.side-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.side-drawer-root.is-open .side-drawer__backdrop {
  opacity: 1;
}

.side-drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(322px, 86vw);
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: 24px 0 48px rgba(16, 24, 40, 0.18);
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
}

.side-drawer-root.is-open .side-drawer {
  transform: translateX(0);
}

.side-drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.side-drawer__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 650;
}

.side-drawer__subtitle {
  margin: 2px 0 0;
  color: var(--text-3);
  font-size: var(--text-xs);
}

.side-drawer__close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
}

.side-drawer__close svg {
  width: 18px;
  height: 18px;
}

.side-drawer__body {
  flex: 1;
  min-height: 0;
  padding: var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------ 模板选择 ------------------------------- */

.template-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 58px;
  padding: var(--space-2) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.template-row:active {
  background: var(--surface-2);
}

.template-row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-row__name {
  font-size: var(--text-base);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-row__meta {
  color: var(--text-3);
  font-size: var(--text-2xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-row__arrow {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.template-row__arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

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

.card--form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

.editor__identity {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.editor__identity-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.editor__icon {
  flex: 0 0 auto;
}

.editor__pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-3);
}

.field__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.field__label--spaced {
  display: block;
  margin: var(--space-4) 0 var(--space-2);
}

.field__counter {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.input--price {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.textarea {
  min-height: 84px;
  padding: var(--space-3);
  line-height: 1.5;
  resize: vertical;
}

.cycle-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cycle-row .segmented {
  flex: 1;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.chip:active {
  background: var(--surface-2);
}

.chip--accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.chip--soft {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text-2);
}

.chip--danger {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.chip[disabled] {
  opacity: 0.45;
  cursor: default;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.stepper__btn {
  width: 38px;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.stepper__btn:active {
  background: var(--surface-3);
}

.stepper__value {
  min-width: 34px;
  text-align: center;
  font-size: var(--text-base);
  font-weight: 600;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: 50px;
  height: 40px;
  cursor: pointer;
}

.switch__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  font-size: var(--input-font);
  cursor: pointer;
}

.switch__track {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background 0.16s ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.16s ease;
}

.switch__input:checked + .switch__track {
  background: var(--accent);
}

.switch__input:checked + .switch__track::after {
  transform: translateX(18px);
}

.switch__input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.is-disabled {
  opacity: 0.45;
}

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

.promo-head .card__title {
  margin-bottom: 2px;
}

.promo-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-1);
}

.promo-preview {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.promo-preview__main {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.promo-preview__sub {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.link-danger {
  align-self: center;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: var(--text-sm);
  cursor: pointer;
}

/* ------------------------------- 分析页 -------------------------------- */

.analysis-head {
  margin-bottom: var(--space-4);
}

.analysis-head__row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.analysis-head__title {
  margin: 0 var(--space-1);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.analysis-head__spacer {
  flex: 1;
}

.analysis-head__sub {
  margin: var(--space-1) 0 0;
  padding-left: 2px;
  color: var(--text-3);
  font-size: var(--text-xs);
}

.segmented--compact {
  padding: 2px;
  width: auto;
}

.segmented--compact .segmented__btn {
  min-width: 44px;
  min-height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.segmented--ink {
  background: transparent;
  padding: 0;
  gap: var(--space-1);
}

.segmented--ink .segmented__btn {
  min-height: 34px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
}

.segmented--ink .segmented__btn.is-active {
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 600;
}

.analysis-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.analysis-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi__label {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.kpi__value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi__unit {
  color: var(--text-3);
  font-size: var(--text-2xs);
  font-weight: 500;
}

.kpi--accent .kpi__value {
  color: var(--accent);
  font-size: var(--text-xl);
}

.chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-2);
  height: 176px;
  padding-top: var(--space-3);
}

.chart__col {
  display: grid;
  grid-template-rows: 16px minmax(0, 1fr) 18px;
  align-items: end;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.chart__value {
  color: var(--text-3);
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
}

.chart__col.is-active .chart__value {
  color: var(--accent);
  font-weight: 700;
}

.chart__track {
  justify-self: center;
  display: flex;
  align-items: flex-end;
  width: 100%;
  max-width: 26px;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.chart__bar {
  width: 100%;
  height: var(--h, 0%);
  min-height: 3px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  transition: height 0.22s ease, background 0.16s ease;
}

.chart__col.is-active .chart__bar {
  background: var(--accent);
}

.chart__label {
  color: var(--text-3);
  font-size: var(--text-2xs);
  text-align: center;
  white-space: nowrap;
}

.chart__col.is-active .chart__label {
  color: var(--text);
  font-weight: 600;
}

.category-body {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.donut {
  flex: 0 0 auto;
  width: 144px;
  height: 144px;
}

.donut__value {
  font-size: 20px;
  font-weight: 700;
  fill: var(--text);
}

.donut__label {
  font-size: 10px;
  fill: var(--text-3);
}

.legend {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend__row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}

.legend__row.is-zero {
  opacity: 0.45;
}

.legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--cat-color, var(--text-3));
}

.legend__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend__amount {
  font-weight: 600;
  white-space: nowrap;
}

.legend__percent {
  min-width: 42px;
  color: var(--text-3);
  text-align: right;
  white-space: nowrap;
}

/* 明细列表 */

.spend-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spend-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  min-height: 58px;
  padding: var(--space-2) var(--space-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.spend-row:last-child {
  border-bottom: 0;
}

.spend-row:active {
  background: var(--surface-2);
}

.spend-row__main {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.spend-row__name {
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spend-row__amount {
  margin-left: auto;
  font-size: var(--text-sm);
  font-weight: 650;
  white-space: nowrap;
}

.spend-row__sub .tag {
  margin-left: auto;
}

.spend-row__sub {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 20px;
  color: var(--text-3);
  font-size: var(--text-2xs);
  white-space: nowrap;
}

/* -------------------------------- 标签 --------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: var(--text-2xs);
  font-weight: 600;
  white-space: nowrap;
}

.tag--cat {
  background: color-mix(in srgb, var(--cat-color, #64748b) 14%, var(--surface));
  color: var(--cat-color, var(--text-2));
  font-weight: 500;
}

.tag--promo {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag--info {
  background: var(--info-bg);
  color: var(--info);
}

.tag--warn {
  background: var(--warn-bg);
  color: var(--warn);
}

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

.tag--muted {
  background: var(--surface-2);
  color: var(--text-3);
  font-weight: 500;
}

.tag--soft {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 500;
}

/* ------------------------------- 站内提醒 ------------------------------- */

.reminder-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.reminder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.reminder-head__count {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.reminder-head__num {
  font-size: var(--text-xl);
  font-weight: 700;
}

.reminder-head__label {
  color: var(--text-2);
  font-size: var(--text-sm);
}

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

.reminder-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.reminder-row.is-read {
  opacity: 0.62;
}

.reminder-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.reminder-row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reminder-row__name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reminder-row__meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.reminder-row__summary {
  color: var(--text-2);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reminder-row__foot {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

/* ------------------------------ 类别管理 ------------------------------- */

.category-manager {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

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

.category-head__count {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 650;
}

.category-head__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.category-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.category-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.category-row:last-child {
  border-bottom: 0;
}

.category-row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.category-row__dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 5px;
  background: var(--cat-color, var(--text-3));
}

.category-row__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.category-row__name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.category-row__meta {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.category-row__ops {
  display: flex;
  align-items: center;
  gap: 2px;
}

.category-row__chev {
  width: 14px;
  color: var(--text-3);
  text-align: center;
}

.category-hint {
  text-align: center;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.swatch {
  width: 30px;
  height: 30px;
  border: 2px solid transparent;
  border-radius: 9px;
  background: var(--swatch);
  cursor: pointer;
}

.swatch.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface);
}

/* ------------------------------ 设置页的行 ------------------------------ */

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card__head .card__title {
  margin-bottom: 0;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 52px;
  padding: var(--space-2) 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row__title {
  font-size: var(--text-sm);
  font-weight: 600;
}

.row__subtitle {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.row__chevron {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.row__chevron svg {
  display: block;
  width: 100%;
  height: 100%;
}

.rate-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.rate-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.rate-row__code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 66px;
  font-size: var(--text-sm);
  font-weight: 600;
}

.rate-row__symbol {
  color: var(--text-2);
  font-weight: 500;
}

.rate-row__eq {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.rate-row__input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.rate-row__input .input {
  min-height: 36px;
  padding: 0 var(--space-2);
  text-align: right;
  background: var(--surface);
}

.rate-row__base {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.version-footer {
  padding: var(--space-6) 0 var(--space-2);
  text-align: center;
}

.version-footer__app {
  margin: 0;
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.version-footer__num {
  margin: 2px 0 0;
  color: var(--text-3);
  font-size: var(--text-2xs);
}

/* ------------------------------ 更新横幅 ------------------------------- */

.update-banner {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--tab-h) + var(--space-2));
  z-index: 75;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: calc(100% - 32px);
  max-width: 520px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
  transform: translateX(-50%);
}

.update-banner__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.update-banner__text {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-banner__action {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}

.update-banner__close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.update-banner__close svg {
  width: 15px;
  height: 15px;
}

/* ------------------------------ 轻提示变体 ------------------------------ */

.toast--plain {
  padding: 10px 16px;
}

/* --------------------------- 图标尺寸与品牌徽章 -------------------------- */

.icon-tile--xl {
  width: 60px;
  height: 60px;
  border-radius: 20%;
}

.icon-tile--brand {
  background: var(--cat-color, var(--surface-2));
  color: #fff;
}

.icon-tile__badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #fff;
}

.icon-tile--lg .icon-tile__badge {
  font-size: 14px;
}

.icon-tile--xl .icon-tile__badge {
  font-size: 18px;
}

/* ------------------------------- 宽屏适配 ------------------------------- */

@media (min-width: 680px) {
  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .analysis-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .update-banner {
    bottom: calc(var(--safe-bottom) + var(--space-6));
  }
}

@media (min-width: 1024px) {
  .analysis-pair {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }
}

/* ---------------------------- 编辑器图标预设 ---------------------------- */

.field__stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.icon-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-preset {
  padding: 2px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.icon-preset.is-active {
  border-color: var(--accent);
}

.icon-preset .icon-tile {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.stepper-with-unit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stepper-unit {
  color: var(--text-3);
  font-size: var(--text-xs);
}

/* ======================= M2-C：图标 / 导入 App / 模板库 ======================= */

/* 共用图标操作区 */
.icon-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.icon-field__preview {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 20%;
  background: transparent;
  cursor: pointer;
}

.icon-field__tile {
  display: block;
}

.icon-field__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.icon-field__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.icon-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* App 候选列表 */
.app-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 58px;
  padding: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.app-row.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.app-row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-row__name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-row__meta {
  color: var(--text-3);
  font-size: var(--text-2xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 导入 App 指引 */
.import-guide {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.import-guide__art {
  color: var(--text-2);
}

.import-guide__art svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72px;
}

.import-guide__steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--space-2);
}

.import-guide__step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.import-guide__index {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
}

.import-guide__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.import-guide__title {
  font-size: var(--text-xs);
  font-weight: 600;
}

.import-guide__hint {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.import-actions {
  display: flex;
  justify-content: flex-end;
}

/* 模板库管理 */
.template-manager {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.template-manager__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.template-manager__title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 650;
}

.template-manager__meta {
  margin: 2px 0 0;
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.template-manager__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.template-manager__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.template-manager__row:last-child {
  border-bottom: 0;
}

.template-manager__main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.template-manager__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.template-manager__name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-manager__meta {
  color: var(--text-3);
  font-size: var(--text-2xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 模板行里的「自定义」标签 */
.template-row__name {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-row__name > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ M3：云同步 ============================ */

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-2xs);
  font-weight: 600;
  white-space: nowrap;
}

.sync-state__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.sync-state--ok {
  background: var(--success-bg);
  color: var(--success);
}

.sync-state--info {
  background: var(--info-bg);
  color: var(--info);
}

.sync-state--warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.sync-state--muted {
  background: var(--surface-2);
  color: var(--text-3);
}

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

.sync-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sync-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sync-history__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sync-history__row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-3);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.sync-history__row:last-child {
  border-bottom: 0;
}

.sync-history__row:active {
  background: var(--surface-2);
}

.sync-history__rev {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--accent);
}

.sync-history__meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  font-size: var(--text-2xs);
  color: var(--text-2);
  overflow: hidden;
}

.sync-history__meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-history__count {
  color: var(--text-3);
  font-size: var(--text-2xs);
  white-space: nowrap;
}

.merge-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.merge-option--primary {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.merge-option__title {
  font-size: var(--text-sm);
  font-weight: 650;
}

.merge-option--primary .merge-option__title {
  color: var(--accent);
}

.merge-option__desc {
  color: var(--text-2);
  font-size: var(--text-2xs);
  line-height: 1.5;
}

/* ============================ M4：推送与日历 ============================ */

.push-section,
.calendar-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.push-section__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.push-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.push-status__devices {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.push-devices {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.push-device {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.push-device:last-child {
  border-bottom: 0;
}

.push-device__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.push-device__name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.push-device__meta {
  color: var(--text-3);
  font-size: var(--text-2xs);
}

.push-guide {
  margin-bottom: var(--space-1);
}

.calendar-url {
  display: block;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-2xs);
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.card__actions .btn[disabled] {
  opacity: 0.4;
  cursor: default;
}
