:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --surface-tint: #edf3ff;
  --ink: #172331;
  --ink-soft: #596676;
  --muted: #8a96a6;
  --line: #e7ebf1;
  --line-strong: #d8dee8;
  --primary: #3268e8;
  --primary-dark: #214fc2;
  --primary-soft: #e9efff;
  --green: #0f9f7f;
  --green-soft: #e7f8f2;
  --orange: #e99026;
  --orange-soft: #fff4e5;
  --red: #df5360;
  --red-soft: #fff0f2;
  --purple: #7558d8;
  --purple-soft: #f0ecff;
  --navy: #162b46;
  --shadow: 0 12px 32px rgba(24, 40, 72, .08);
  --shadow-soft: 0 7px 20px rgba(24, 40, 72, .06);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

/* 保证 hidden 属性始终生效：部分组件类声明了 display，会覆盖浏览器默认的 [hidden] 规则 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html.ledger-handoff body::before {
  content: "正在进入账本…";
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  background: #f4f6fa;
  color: var(--navy);
  font-size: 16px;
  font-weight: 800;
}

html.ledger-handoff .auth-gate {
  visibility: hidden;
}

html,
body {
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.desktop-stage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(50, 104, 232, .12), transparent 30%),
    radial-gradient(circle at 85% 90%, rgba(15, 159, 127, .10), transparent 28%),
    #e9edf4;
}

.prototype-note {
  width: 280px;
  color: var(--navy);
}

.prototype-note .eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--primary);
}

.prototype-note h1 {
  margin: 12px 0 14px;
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: -.05em;
}

.prototype-note p {
  margin: 0;
  color: #617083;
  line-height: 1.75;
}

.note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.note-list span {
  padding: 7px 11px;
  border: 1px solid rgba(33, 79, 194, .15);
  border-radius: 999px;
  background: rgba(255, 255, 255, .68);
  color: #315278;
  font-size: 12px;
  font-weight: 700;
}

.app-shell {
  position: relative;
  width: min(440px, 100%);
  height: min(900px, calc(100vh - 48px));
  min-height: 650px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(24, 40, 72, .08);
  border-radius: 34px;
  background: var(--bg);
  box-shadow: 0 28px 80px rgba(20, 34, 62, .22);
}

.app-header {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding: 18px 18px 12px;
  background: rgba(243, 245, 249, .94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(231, 235, 241, .78);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #376fec, #214fc2);
  color: white;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(50, 104, 232, .28);
}

.brand-copy {
  min-width: 0;
  display: grid;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: -.01em;
}

.brand-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

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

.icon-button {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .82);
  color: #47576a;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--red);
}

.space-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 14px;
  padding: 4px;
  border-radius: 15px;
  background: #e8ecf3;
}

.space-option {
  min-height: 34px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #667386;
  font-size: 13px;
  font-weight: 700;
}

.space-option.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 5px 12px rgba(27, 51, 88, .08);
}

.app-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px calc(100px + var(--safe-bottom));
  scroll-behavior: smooth;
}

.page {
  animation: page-in .24s ease both;
}

@keyframes page-in {
  from { opacity: .2; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 3px 2px 14px;
}

.page-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.page-heading h1,
.section-heading h2,
.sheet-header h2 {
  margin: 0;
  letter-spacing: -.035em;
}

.page-heading h1 {
  font-size: 25px;
  line-height: 1.2;
}

.page-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 3px 10px;
}

.section-heading h2 {
  font-size: 17px;
}

.section-heading small {
  color: var(--muted);
  font-size: 11px;
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, #1a2e4d, #274b7d 72%, #3268e8);
  color: white;
  box-shadow: 0 18px 34px rgba(22, 43, 70, .24);
}

.hero-card::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  top: -115px;
  right: -80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  right: 32px;
  bottom: -100px;
  border-radius: 50%;
  background: rgba(53, 138, 255, .26);
}

.hero-top,
.hero-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-label {
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
}

.hero-value {
  display: block;
  margin-top: 5px;
  font-size: 31px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.04em;
}

.hero-badge {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .9);
  font-size: 11px;
  font-weight: 700;
}

.hero-bottom {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, .14);
}

.hero-metric {
  display: grid;
  gap: 3px;
}

.hero-metric small {
  color: rgba(255, 255, 255, .62);
  font-size: 10px;
}

.hero-metric strong {
  font-size: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.metric-label .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.metric-value {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-foot {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

.alert-stack {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border: 1px solid rgba(233, 144, 38, .2);
  border-radius: 17px;
  background: linear-gradient(135deg, #fff9ef, #fff);
}

.alert-card.danger {
  border-color: rgba(223, 83, 96, .2);
  background: linear-gradient(135deg, #fff4f5, #fff);
}

.alert-card.success {
  border-color: rgba(15, 159, 127, .18);
  background: linear-gradient(135deg, #effaf6, #fff);
}

.alert-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 15px;
  font-weight: 900;
}

.alert-card.danger .alert-icon {
  background: var(--red-soft);
  color: var(--red);
}

.alert-card.success .alert-icon {
  background: var(--green-soft);
  color: var(--green);
}

.alert-copy {
  min-width: 0;
  flex: 1;
}

.alert-copy strong {
  display: block;
  font-size: 13px;
}

.alert-copy p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.small-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
}

.small-button {
  border: 1px solid var(--line-strong);
  background: white;
}

.small-button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 18px rgba(50, 104, 232, .22);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: white;
}

.ghost-button {
  border: 1px solid transparent;
  background: var(--surface-soft);
  color: var(--ink-soft);
}

.full-button {
  width: 100%;
}

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.chart-card {
  margin-top: 12px;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chart-head h3 {
  margin: 0;
  font-size: 15px;
}

.chart-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.chart-badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.chart-wrap {
  width: 100%;
  margin-top: 11px;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid-line {
  stroke: #edf0f4;
  stroke-width: 1;
}

.chart-axis-label {
  fill: #919baa;
  font-size: 9px;
  stroke: none;
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.4;
}

.chart-area {
  fill: url(#lineArea);
  stroke: none;
}

.chart-point {
  fill: white;
  stroke: var(--primary);
  stroke-width: 2;
}

.chart-bar {
  fill: #4679ee;
}

.chart-bar.soft {
  fill: #dbe5ff;
}

.chart-note {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--primary);
}

.donut-layout {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.donut-chart {
  width: 132px;
  height: 132px;
}

.donut-center-value {
  font-size: 16px;
  font-weight: 800;
  text-anchor: middle;
  fill: var(--ink);
  stroke: none;
}

.donut-center-label {
  font-size: 9px;
  text-anchor: middle;
  fill: var(--muted);
  stroke: none;
}

.legend-list {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.legend-row span:nth-child(2) {
  color: var(--ink-soft);
}

.legend-row strong {
  font-size: 11px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f5;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f7df0, #3268e8);
}

.progress-fill.green { background: linear-gradient(90deg, #4cc8a8, #0f9f7f); }
.progress-fill.orange { background: linear-gradient(90deg, #f6b456, #e99026); }
.progress-fill.red { background: linear-gradient(90deg, #ef7c87, #df5360); }

.due-list,
.transaction-list,
.account-list,
.action-list {
  display: grid;
  gap: 9px;
}

.due-item,
.transaction-item,
.account-card,
.action-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: white;
}

.due-date {
  width: 46px;
  flex: 0 0 auto;
  padding: 7px 5px;
  border-radius: 12px;
  background: var(--surface-soft);
  text-align: center;
}

.due-date strong {
  display: block;
  font-size: 15px;
}

.due-date small {
  display: block;
  margin-top: -2px;
  color: var(--muted);
  font-size: 9px;
}

.due-content,
.transaction-main,
.account-main,
.action-copy {
  min-width: 0;
  flex: 1;
}

.due-content strong,
.transaction-main strong,
.account-main strong,
.action-copy strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.due-content span,
.transaction-main span,
.account-main span,
.action-copy span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount {
  flex: 0 0 auto;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.amount.expense { color: var(--ink); }
.amount.income { color: var(--green); }
.amount.debt { color: var(--red); }

.transaction-icon,
.account-icon,
.action-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 900;
}

.account-icon.card { background: var(--primary-soft); color: var(--primary); }
.account-icon.loan { background: var(--red-soft); color: var(--red); }
.account-icon.cash { background: var(--green-soft); color: var(--green); }
.account-icon.company { background: var(--purple-soft); color: var(--purple); }

.account-card {
  cursor: pointer;
}

.account-card:hover,
.due-item:hover,
.transaction-item:hover,
.action-item:hover {
  border-color: #d8e1f1;
  transform: translateY(-1px);
}

.account-card,
.due-item,
.transaction-item,
.action-item {
  transition: border-color .18s ease, transform .18s ease;
}

.summary-split {
  display: grid;
  gap: 12px;
}

.summary-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 9px;
}

.summary-row > span {
  color: var(--ink-soft);
  font-size: 12px;
}

.summary-row > strong {
  text-align: right;
  font-size: 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
}

.status-chip.green { background: var(--green-soft); color: var(--green); }
.status-chip.orange { background: var(--orange-soft); color: #b86c0d; }
.status-chip.red { background: var(--red-soft); color: var(--red); }
.status-chip.blue { background: var(--primary-soft); color: var(--primary); }
.status-chip.purple { background: var(--purple-soft); color: var(--purple); }

.filter-row,
.segmented-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 1px 5px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar,
.segmented-row::-webkit-scrollbar {
  display: none;
}

.filter-chip,
.segment-chip {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.filter-chip.active,
.segment-chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

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

.mini-insight {
  padding: 12px;
  border-radius: 15px;
  background: var(--surface-soft);
}

.mini-insight small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.mini-insight strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.plan-score-card {
  display: grid;
  grid-template-columns: 118px 1fr;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-xl);
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.score-ring {
  position: relative;
  width: 112px;
  height: 112px;
}

.score-ring svg {
  width: 112px;
  height: 112px;
  transform: rotate(-90deg);
}

.score-ring .track {
  stroke: #edf0f5;
  stroke-width: 10;
}

.score-ring .value {
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 284;
  stroke-dashoffset: 62;
}

.score-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.score-center strong {
  font-size: 27px;
  line-height: 1;
}

.score-center span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.score-copy h2 {
  margin: 0;
  font-size: 18px;
}

.score-copy p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.score-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(76px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid rgba(220, 226, 235, .9);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(18px);
}

.nav-item {
  height: 52px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: #8b96a6;
  font-size: 9px;
  font-weight: 800;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-add {
  align-self: start;
  justify-self: center;
  width: 62px;
  height: 62px;
  margin-top: -25px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 5px solid var(--bg);
  border-radius: 22px;
  background: linear-gradient(145deg, #4075ec, #2455c9);
  color: white;
  box-shadow: 0 12px 24px rgba(50, 104, 232, .34);
}

.nav-add span {
  font-size: 25px;
  line-height: 1;
  font-weight: 300;
}

.nav-add small {
  margin-top: -2px;
  font-size: 8px;
  font-weight: 800;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(15, 26, 43, .45);
  backdrop-filter: blur(3px);
}

.sheet {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88%;
  overflow: hidden;
  border-radius: 28px 28px 0 0;
  background: #f8f9fc;
  box-shadow: 0 -18px 46px rgba(19, 33, 58, .20);
  animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1) both;
}

.sheet.full {
  top: 0;
  max-height: none;
  border-radius: 0;
}

@keyframes sheet-up {
  from { transform: translateY(24%); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: 999px;
  background: #d3d8e1;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-header h2 {
  font-size: 18px;
}

.sheet-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.sheet-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink-soft);
  font-size: 20px;
}

.sheet-content {
  max-height: calc(88vh - 72px);
  overflow-y: auto;
  padding: 16px 18px calc(28px + var(--safe-bottom));
}

.sheet.full .sheet-content {
  max-height: calc(100vh - 68px);
}

.record-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: #e9edf3;
}

.record-tab {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #677488;
  font-size: 11px;
  font-weight: 800;
}

.record-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 4px 10px rgba(26, 48, 85, .08);
}

.amount-panel {
  margin-top: 14px;
  padding: 17px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--line);
}

.amount-label {
  color: var(--muted);
  font-size: 10px;
}

.amount-input-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 3px;
}

.amount-input-row span {
  color: var(--ink-soft);
  font-size: 23px;
}

.amount-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
}

.input-list {
  display: grid;
  gap: 1px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 17px;
  background: var(--line);
  border: 1px solid var(--line);
}

.input-row {
  min-height: 50px;
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  background: white;
}

.input-row label {
  color: var(--muted);
  font-size: 11px;
}

.input-row select,
.input-row input,
.input-row textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  text-align: right;
  font-size: 12px;
  font-weight: 700;
}

.input-row textarea {
  min-height: 50px;
  resize: none;
  text-align: left;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 11px;
}

.category-option {
  min-height: 64px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
}

.category-option .category-emoji {
  font-size: 20px;
}

.category-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 9px;
  margin-top: 16px;
}

.receipt-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #b8c7e8;
  border-radius: 16px;
  background: #f5f8ff;
}

.receipt-strip-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: white;
  color: var(--primary);
  font-size: 17px;
}

.receipt-strip div {
  min-width: 0;
  flex: 1;
}

.receipt-strip strong {
  display: block;
  font-size: 12px;
}

.receipt-strip small {
  color: var(--muted);
  font-size: 10px;
}

.ocr-box {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(15, 159, 127, .22);
  border-radius: 16px;
  background: var(--green-soft);
}

.ocr-box .ocr-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #087b61;
  font-size: 12px;
  font-weight: 800;
}

.ocr-box p {
  margin: 7px 0 0;
  color: #3f6e63;
  font-size: 11px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.import-stat {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  text-align: center;
}

.import-stat strong {
  display: block;
  font-size: 18px;
}

.import-stat small {
  color: var(--muted);
  font-size: 9px;
}

.import-list {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.import-row {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

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

.import-row-head strong {
  font-size: 13px;
}

.import-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.import-reason {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 10px;
}

.detail-hero {
  padding: 19px;
  border-radius: var(--radius-xl);
  color: white;
  background: linear-gradient(145deg, #24518b, #172b48);
  box-shadow: 0 14px 28px rgba(23, 43, 72, .2);
}

.detail-hero.company {
  background: linear-gradient(145deg, #6047bd, #33256f);
}

.detail-hero.loan {
  background: linear-gradient(145deg, #a84a58, #632e38);
}

.detail-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.detail-hero small {
  color: rgba(255, 255, 255, .66);
  font-size: 10px;
}

.detail-hero h2 {
  margin: 5px 0 0;
  font-size: 22px;
}

.detail-balance {
  display: block;
  margin-top: 17px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.04em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 15px;
}

.detail-grid div {
  padding: 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .1);
}

.detail-grid small {
  display: block;
}

.detail-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.utilization-ring {
  position: relative;
  width: 112px;
  height: 112px;
  flex: 0 0 auto;
}

.utilization-ring svg {
  width: 112px;
  height: 112px;
  transform: rotate(-90deg);
}

.utilization-ring .track {
  stroke: rgba(255, 255, 255, .18);
  stroke-width: 10;
}

.utilization-ring .value {
  stroke: #7ce4c7;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 283;
}

.utilization-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.utilization-center strong {
  font-size: 20px;
}

.utilization-center small {
  font-size: 8px;
}

.kv-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  background: white;
}

.kv-row span {
  color: var(--ink-soft);
  font-size: 11px;
}

.kv-row strong {
  text-align: right;
  font-size: 12px;
}

.toast {
  position: absolute;
  z-index: 100;
  left: 50%;
  bottom: calc(94px + var(--safe-bottom));
  max-width: calc(100% - 36px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(20, 33, 52, .94);
  color: white;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty-state {
  padding: 28px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: white;
  text-align: center;
}

.empty-state strong {
  display: block;
  font-size: 14px;
}

.empty-state p {
  margin: 5px 0 13px;
  color: var(--muted);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  body {
    background: var(--bg);
  }

  .desktop-stage {
    display: block;
    min-height: 100dvh;
    padding: 0;
    background: var(--bg);
  }

  .prototype-note {
    display: none;
  }

  .app-shell {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 360px) {
  .app-view {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-header {
    padding-left: 13px;
    padding-right: 13px;
  }

  .metric-grid,
  .chart-pair {
    gap: 8px;
  }

  .metric-card {
    padding: 12px;
  }

  .metric-value {
    font-size: 18px;
  }

  .donut-layout {
    grid-template-columns: 112px 1fr;
  }

  .donut-chart {
    width: 112px;
    height: 112px;
  }

  .plan-score-card {
    grid-template-columns: 100px 1fr;
  }

  .score-ring,
  .score-ring svg {
    width: 96px;
    height: 96px;
  }
}

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

/* Narrow-screen safety overrides */
body,
.app-shell {
  overflow-x: hidden;
}

.app-view {
  overflow-x: hidden;
}

.hero-top > div:first-child {
  min-width: 0;
}

.hero-value {
  white-space: nowrap;
}

.hero-badge {
  flex: 0 0 auto;
  white-space: nowrap;
}

.bottom-nav {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.nav-item {
  min-width: 0;
}

@media (max-width: 820px) {
  .app-header {
    padding-right: 28px;
  }
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

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

.manage-action {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: white;
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.manage-action-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 15px;
  font-weight: 900;
}

.manage-action strong {
  display: block;
  font-size: 12px;
}

.manage-action span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

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

.manager-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

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

.manager-row-main strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manager-row-main span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.manager-row-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: white;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
}

.mini-button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.form-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 10px;
}

.receipt-primary {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 13px;
  padding: 15px;
  border: 1px solid rgba(50, 104, 232, .22);
  border-radius: 19px;
  background: linear-gradient(135deg, #edf3ff, #f8faff);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 24px rgba(50, 104, 232, .1);
}

.receipt-primary-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #4b7df0, #2c5dcd);
  color: white;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(50, 104, 232, .25);
}

.receipt-primary-copy {
  min-width: 0;
  flex: 1;
}

.receipt-primary-copy strong {
  display: block;
  font-size: 14px;
}

.receipt-primary-copy small {
  display: block;
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 10px;
}

.receipt-primary-arrow {
  color: var(--primary);
  font-size: 24px;
}

/* Mobile readability and touch-target overrides */
html {
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  touch-action: manipulation;
}

@media (max-width: 820px) {
  body {
    font-size: 16px;
  }

  .app-header {
    padding-top: 16px;
    padding-bottom: 13px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 20px;
  }

  .brand-copy strong {
    font-size: 18px;
  }

  .brand-copy small {
    font-size: 12px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
    border-radius: 15px;
  }

  .icon-button svg {
    width: 21px;
    height: 21px;
  }

  .space-switch {
    margin-top: 13px;
  }

  .space-option {
    min-height: 40px;
    font-size: 14px;
  }

  .page-heading h1 {
    font-size: 28px;
  }

  .page-kicker {
    font-size: 12px;
  }

  .page-heading p {
    font-size: 14px;
  }

  .section-heading h2 {
    font-size: 19px;
  }

  .section-heading small,
  .text-button {
    font-size: 13px;
  }

  .hero-card {
    padding: 21px;
  }

  .hero-label {
    font-size: 13px;
  }

  .hero-value {
    font-size: 34px;
  }

  .hero-badge {
    padding: 8px 11px;
    font-size: 12px;
  }

  .hero-metric small {
    font-size: 12px;
  }

  .hero-metric strong {
    font-size: 16px;
  }

  .metric-card,
  .card {
    padding: 17px;
  }

  .metric-label,
  .metric-foot {
    font-size: 12px;
  }

  .metric-value {
    font-size: 22px;
  }

  .alert-card {
    padding: 15px;
  }

  .alert-icon {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .alert-copy strong {
    font-size: 15px;
  }

  .alert-copy p {
    font-size: 13px;
    line-height: 1.55;
  }

  .small-button,
  .primary-button,
  .secondary-button,
  .ghost-button {
    min-height: 44px;
    padding: 0 15px;
    font-size: 14px;
    border-radius: 13px;
  }

  .chart-head h3 {
    font-size: 17px;
  }

  .chart-head p,
  .chart-badge,
  .chart-note,
  .legend-item {
    font-size: 12px;
  }

  .chart-axis-label {
    font-size: 10px;
  }

  .due-item,
  .transaction-item,
  .account-card,
  .action-item {
    min-height: 64px;
    padding: 14px;
  }

  .due-date {
    width: 50px;
    padding: 8px 5px;
  }

  .due-date strong {
    font-size: 17px;
  }

  .due-date small {
    font-size: 11px;
  }

  .due-content strong,
  .transaction-main strong,
  .account-main strong,
  .action-copy strong {
    font-size: 15px;
  }

  .due-content span,
  .transaction-main span,
  .account-main span,
  .action-copy span {
    font-size: 12px;
  }

  .amount {
    font-size: 14px;
  }

  .status-chip,
  .badge {
    padding: 5px 8px;
    font-size: 11px;
  }

  .transaction-icon,
  .account-icon,
  .action-icon {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .filter-chip,
  .segment-chip {
    min-height: 40px;
    padding: 0 14px;
    font-size: 13px;
  }

  .bottom-nav {
    height: calc(84px + var(--safe-bottom));
    padding-top: 9px;
  }

  .nav-item {
    height: 60px;
    gap: 4px;
    font-size: 11px;
  }

  .nav-item svg {
    width: 22px;
    height: 22px;
  }

  .nav-add {
    width: 66px;
    height: 66px;
  }

  .nav-add span {
    font-size: 27px;
  }

  .nav-add small {
    font-size: 10px;
  }

  .sheet-header h2 {
    font-size: 20px;
  }

  .sheet-header p {
    font-size: 12px;
  }

  .sheet-close {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }

  .record-tab {
    min-height: 42px;
    font-size: 14px;
  }

  .amount-label {
    font-size: 12px;
  }

  .amount-input-row span {
    font-size: 25px;
  }

  .amount-input {
    font-size: 44px;
  }

  .input-row {
    min-height: 56px;
    grid-template-columns: 86px 1fr auto;
    padding: 0 14px;
  }

  .input-row label {
    font-size: 13px;
  }

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

  .category-option {
    min-height: 70px;
    font-size: 12px;
  }

  .category-option .category-emoji {
    font-size: 22px;
  }

  .receipt-primary {
    padding: 16px;
  }

  .receipt-primary-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .receipt-primary-copy strong {
    font-size: 16px;
  }

  .receipt-primary-copy small {
    font-size: 12px;
  }

  .ocr-title {
    font-size: 14px;
  }

  .ocr-box p,
  .import-row p,
  .import-reason,
  .chart-note {
    font-size: 12px;
  }

  .import-row-head strong {
    font-size: 15px;
  }

  .import-stat strong {
    font-size: 21px;
  }

  .import-stat small {
    font-size: 11px;
  }

  .kv-row span,
  .kv-row strong {
    font-size: 13px;
  }

  .score-copy h2 {
    font-size: 20px;
  }

  .score-copy p {
    font-size: 13px;
  }
}

.auth-gate {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(160deg, #eef3ff, #f8f9fc 55%, #edf8f5);
}

.auth-card {
  width: 100%;
  padding: 24px;
  border: 1px solid rgba(50, 104, 232, .14);
  border-radius: 26px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 24px 60px rgba(24, 40, 72, .16);
}

.auth-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: linear-gradient(145deg, #4075ec, #2455c9);
  color: white;
  font-size: 21px;
  font-weight: 900;
}

.auth-card h2 {
  margin: 18px 0 0;
  font-size: 25px;
  letter-spacing: -.04em;
}

.auth-card > p {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.auth-field {
  display: grid;
  gap: 7px;
  margin-top: 13px;
}

.auth-field > span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.auth-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: 0;
  background: white;
  color: var(--ink);
  font-size: 15px;
}

.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 8px;
}

.auth-code-row button {
  border: 1px solid var(--primary);
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.auth-card .full-button {
  margin-top: 12px;
}

.auth-card > small {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.auth-register-toggle {
  width: 100%;
  margin-top: 12px;
  text-align: center;
}

.auth-register-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.auth-register-panel .full-button {
  margin-top: 13px;
}

.auth-register-panel:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  overflow-y: auto;
  margin: 0;
  padding: 22px;
  border: 0;
  background: rgba(15, 26, 43, .46);
  backdrop-filter: blur(5px);
}

.auth-register-card {
  width: min(390px, 100%);
  padding: 22px;
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 70px rgba(15, 26, 43, .24);
}

.auth-register-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.auth-register-header h3 {
  margin: 0;
  font-size: 21px;
}

.auth-register-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-register-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 9px;
  margin-top: 16px;
}

.auth-message {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

.auth-message.success {
  background: var(--green-soft);
  color: var(--green);
}

.auth-message.info {
  background: var(--primary-soft);
  color: var(--primary);
}

.toast {
  z-index: 400;
}

/* Focused mobile layout */
.mobile-entry-grid {
  display: none;
}

.receipt-file-button {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
}

@media (max-width: 820px) {
  .app-header {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  }

  .header-row {
    gap: 8px;
  }

  .brand-mark,
  .icon-button {
    width: 42px;
    height: 42px;
  }

  .brand-copy small {
    display: none;
  }

  .space-switch {
    margin-top: 8px;
    padding: 3px;
  }

  .space-option {
    min-height: 36px;
    font-size: 13px;
  }

  .app-view {
    padding: 10px 12px calc(92px + var(--safe-bottom));
  }

  .page-heading {
    margin: 0 2px 10px;
  }

  .page-heading h1 {
    font-size: 24px;
  }

  .page-heading p,
  .page-kicker {
    display: none;
  }

  .hero-card {
    padding: 16px;
    border-radius: 22px;
  }

  .hero-value {
    margin-top: 3px;
    font-size: 29px;
  }

  .hero-bottom {
    margin-top: 12px;
    padding-top: 10px;
  }

  .mobile-entry-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 9px;
  }

  .mobile-entry-grid button {
    min-height: 68px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--navy);
    box-shadow: var(--shadow-soft);
  }

  .mobile-entry-grid button > span {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-entry-grid button:nth-child(2) > span { background: #e9f8f2; color: var(--green); }
  .mobile-entry-grid button:nth-child(3) > span { background: #fff3e2; color: var(--orange); }
  .mobile-entry-grid button:nth-child(4) > span { background: #f0edff; color: var(--purple); }

  .mobile-entry-grid strong {
    font-size: 12px;
  }

  .metric-grid {
    gap: 8px;
    margin-top: 8px;
  }

  .metric-card {
    padding: 12px;
    border-radius: 16px;
  }

  .metric-value {
    margin-top: 5px;
    font-size: 19px;
  }

  .metric-foot {
    margin-top: 2px;
  }

  .alert-stack {
    gap: 7px;
    margin-top: 8px;
  }

  .alert-card {
    padding: 11px;
    border-radius: 15px;
  }

  .alert-copy p {
    margin-top: 2px;
  }

  .alert-actions {
    margin-top: 6px;
  }

  .section-heading {
    margin: 14px 2px 7px;
  }

  .section-heading h2 {
    font-size: 17px;
  }

  .card {
    padding: 13px;
    border-radius: 17px;
  }

  .chart-card {
    margin-top: 8px;
  }

  .home-trend-chart {
    display: none;
  }

  .home-due-list .due-item:nth-child(n+3),
  .home-transaction-list .transaction-item:nth-child(n+4) {
    display: none;
  }

  .due-item,
  .transaction-item,
  .account-card,
  .action-item {
    min-height: 58px;
    padding: 11px;
  }

  .bottom-nav {
    height: calc(76px + var(--safe-bottom));
    padding-top: 7px;
  }

  .nav-item {
    height: 54px;
  }

  .nav-add {
    width: 60px;
    height: 60px;
  }
}

/* Mobile data-focus layout: compact vertical rhythm, horizontal focus strips */
@media (max-width: 820px) {
  .app-header {
    padding: 8px 12px 7px;
  }

  .header-row {
    gap: 8px;
  }

  .brand-mark,
  .icon-button {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .brand-copy strong {
    font-size: 17px;
  }

  .space-switch {
    margin-top: 6px;
    padding: 3px;
  }

  .space-option {
    min-height: 32px;
    font-size: 13px;
  }

  .app-view {
    padding: 8px 10px calc(84px + var(--safe-bottom));
  }

  .page-heading {
    min-height: 30px;
    align-items: center;
    margin: 0 2px 7px;
  }

  .page-heading h1 {
    font-size: 19px;
  }

  .page-heading p,
  .page-kicker {
    display: none;
  }

  .page-heading .text-button {
    min-height: 34px;
  }

  .hero-card {
    padding: 13px 14px;
    border-radius: 18px;
  }

  .hero-label {
    font-size: 12px;
  }

  .hero-value {
    margin-top: 2px;
    font-size: 27px;
  }

  .hero-badge {
    padding: 6px 9px;
    font-size: 11px;
  }

  .hero-bottom {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
  }

  .hero-metric {
    min-width: 0;
    gap: 1px;
  }

  .hero-metric small {
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero-metric strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page > .alert-stack,
  .metric-grid,
  .home-due-list,
  .home-transaction-list,
  .chart-pair {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 78%);
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1px 1px 6px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .page > .alert-stack::-webkit-scrollbar,
  .metric-grid::-webkit-scrollbar,
  .home-due-list::-webkit-scrollbar,
  .home-transaction-list::-webkit-scrollbar,
  .chart-pair::-webkit-scrollbar {
    display: none;
  }

  .metric-grid {
    grid-auto-columns: minmax(146px, 48%);
    margin-top: 7px;
  }

  .metric-card,
  .alert-card,
  .due-item,
  .transaction-item,
  .account-card,
  .action-item {
    scroll-snap-align: start;
  }

  .metric-card {
    padding: 10px 11px;
    border-radius: 14px;
  }

  .metric-label {
    font-size: 11px;
  }

  .metric-value {
    margin-top: 4px;
    font-size: 17px;
  }

  .metric-foot {
    margin-top: 1px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page > .alert-stack {
    grid-auto-columns: minmax(270px, 88%);
    margin-top: 7px;
  }

  .alert-card {
    min-height: 74px;
    padding: 10px;
    border-radius: 14px;
  }

  .alert-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 15px;
  }

  .alert-copy strong {
    font-size: 13px;
  }

  .alert-copy p {
    display: -webkit-box;
    margin-top: 2px;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .alert-actions {
    margin-top: 5px;
    gap: 6px;
  }

  .alert-actions .small-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .section-heading {
    margin: 10px 2px 5px;
  }

  .section-heading h2 {
    font-size: 16px;
  }

  .section-heading small,
  .section-heading .text-button {
    font-size: 12px;
  }

  .home-due-list,
  .home-transaction-list {
    grid-auto-columns: minmax(224px, 78%);
  }

  .due-item,
  .transaction-item,
  .account-card,
  .action-item {
    min-height: 54px;
    padding: 9px 10px;
    border-radius: 14px;
  }

  .due-date {
    width: 44px;
    padding: 6px 4px;
    border-radius: 10px;
  }

  .due-date strong {
    font-size: 15px;
  }

  .due-date small {
    font-size: 9px;
  }

  .due-content strong,
  .transaction-main strong,
  .account-main strong,
  .action-copy strong {
    font-size: 13px;
  }

  .due-content span,
  .transaction-main span,
  .account-main span,
  .action-copy span {
    margin-top: 1px;
    font-size: 10px;
  }

  .amount {
    font-size: 13px;
  }

  .transaction-icon,
  .account-icon,
  .action-icon {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    font-size: 14px;
  }

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

  .account-list .account-card {
    min-height: 86px;
    align-items: flex-start;
    gap: 7px;
  }

  .account-list .account-main span {
    white-space: normal;
  }

  .account-list .amount {
    font-size: 12px;
  }

  .card {
    padding: 11px;
    border-radius: 15px;
  }

  .chart-card {
    margin-top: 7px;
  }

  .chart-head h3 {
    font-size: 15px;
  }

  .chart-head p,
  .chart-badge,
  .chart-note,
  .legend-item {
    font-size: 11px;
  }

  .donut-layout {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 10px;
  }

  .donut-chart {
    width: 108px;
    height: 108px;
  }

  .plan-score-card {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 11px;
    padding: 12px;
    border-radius: 18px;
  }

  .score-ring,
  .score-ring svg {
    width: 78px;
    height: 78px;
  }

  .score-center strong {
    font-size: 21px;
  }

  .score-copy h2 {
    font-size: 17px;
  }

  .score-copy p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .summary-split {
    gap: 9px;
  }

  .summary-row {
    grid-template-columns: 66px minmax(0, 1fr) auto;
    gap: 7px;
  }

  .summary-row > span,
  .summary-row > strong {
    font-size: 11px;
  }

  .sheet {
    max-height: 94%;
  }

  .sheet-header {
    padding: 10px 14px 9px;
  }

  .sheet-header h2 {
    font-size: 18px;
  }

  .sheet-header p {
    margin-top: 1px;
    font-size: 10px;
  }

  .sheet-close {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 20px;
  }

  .sheet-content {
    max-height: calc(94vh - 60px);
    padding: 10px 12px calc(18px + var(--safe-bottom));
  }

  .receipt-primary {
    margin-top: 8px;
    padding: 10px 11px;
    border-radius: 15px;
  }

  .receipt-primary-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 17px;
  }

  .receipt-primary-copy strong {
    font-size: 14px;
  }

  .receipt-primary-copy small {
    margin-top: 1px;
    font-size: 10px;
  }

  .amount-panel {
    margin-top: 9px;
    padding: 11px 12px;
    border-radius: 16px;
  }

  .amount-input {
    font-size: 38px;
  }

  .input-list {
    margin-top: 9px;
  }

  .input-row {
    min-height: 46px;
    grid-template-columns: 76px 1fr auto;
    padding: 0 11px;
  }

  .input-row label,
  .input-row > span {
    font-size: 13px;
  }

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

  .category-grid {
    grid-auto-flow: column;
    grid-auto-columns: 72px;
    grid-template-columns: none;
    gap: 7px;
    overflow-x: auto;
    padding: 1px 1px 6px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .category-grid::-webkit-scrollbar {
    display: none;
  }

  .category-option {
    min-height: 58px;
    scroll-snap-align: start;
    border-radius: 13px;
  }

  .sheet-actions {
    margin-top: 10px;
  }

  .bottom-nav {
    height: calc(70px + var(--safe-bottom));
    padding-top: 5px;
  }

  .nav-item {
    height: 50px;
    font-size: 10px;
  }

  .nav-add {
    width: 56px;
    height: 56px;
  }

  .app-view {
    scroll-padding-top: 8px;
  }
}

@media (max-width: 380px) {
  .home-due-list,
  .home-transaction-list {
    grid-auto-columns: 88%;
  }

  .account-list {
    grid-template-columns: 1fr;
  }

  .hero-bottom {
    gap: 4px;
  }

  .hero-metric strong {
    font-size: 11px;
  }
}
/* Ensure mobile focus strips override desktop grid templates and legacy limits */
@media (max-width: 820px) {
  .metric-grid,
  .chart-pair,
  .home-due-list,
  .home-transaction-list {
    grid-template-columns: none;
  }

  .home-due-list .due-item:nth-child(n+3),
  .home-transaction-list .transaction-item:nth-child(n+4) {
    display: flex;
  }
}
/* Receipt upload preview and extracted fields */
.ocr-preview {
  width: 100%;
  max-height: 220px;
  display: block;
  margin-top: 10px;
  border: 1px solid rgba(15, 159, 127, .18);
  border-radius: 13px;
  object-fit: contain;
  background: #fff;
}

.ocr-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.ocr-field-grid > span {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .72);
  color: #4d7167;
  font-size: 10px;
}

.ocr-field-grid strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .ocr-preview {
    max-height: 170px;
  }
}
/* Import account and template selectors */
.import-config {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.import-config label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.import-config select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font-size: 12px;
}

@media (max-width: 420px) {
  .import-config {
    grid-template-columns: 1fr;
  }
}
.import-category {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.import-category select {
  min-height: 36px;
  flex: 1;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-size: 12px;
}
.import-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
}

.import-select input {
  width: 18px;
  height: 18px;
}
.import-category input {
  min-height: 36px;
  flex: 1;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-size: 12px;
}
.import-amount-batch {
  width: 100%;
  min-height: 96px;
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font-size: 13px;
  resize: vertical;
}
.app-shell.auth-locked > .app-header,
.app-shell.auth-locked > .app-view,
.app-shell.auth-locked > .bottom-nav {
  visibility: hidden;
  pointer-events: none;
}
