:root,
[data-theme="day"] {
  --bg: #eaf2f6;
  --card: #ffffff;
  --card-alt: #f5f8fa;
  --hero: #ffffff;
  --ink: #24303a;
  --muted: #7b8793;
  --muted-2: #5a6572;
  --brand: #6e63b6;
  --brand-soft: #f0edfa;
  --brand-bright: #6e63b6;
  --expense: #f2221b;
  --income: #09bd5a;
  --tone-high: #09bd5a;
  --tone-mid: #e67e22;
  --tone-low: #f2221b;
  --line: #d7e0e7;
  --tabbar: #ffffff;
  --mask: rgba(20, 27, 36, 0.4);
  --shadow: 0 8px 24px rgba(36, 48, 58, 0.08);
  --donut-track: #edf3f6;
  --progress-track: #edf3f6;
  --progress-fill: #6e63b6;
  --hourglass-body: #e4f1f7;
  --icon-btn-bg: #ffffff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="night"] {
  --bg: #141b24;
  --card: #1e2833;
  --card-alt: #1a222c;
  --hero: #24303a;
  --ink: #e8eef4;
  --muted: #8b96a3;
  --muted-2: #a8b4be;
  --brand: #6e63b6;
  --brand-soft: #2a3150;
  --brand-bright: #a7a3d8;
  --expense: #ff4f4f;
  --income: #00ff9c;
  --tone-high: #00ff9c;
  --tone-mid: #ffb020;
  --tone-low: #ff4f4f;
  --line: #2a3542;
  --tabbar: #1a222c;
  --mask: rgba(10, 18, 28, 0.6);
  --shadow: 0 8px 28px rgba(10, 18, 28, 0.45);
  --donut-track: #2a3542;
  --progress-track: #3a4a56;
  --progress-fill: #8fd8b0;
  --hourglass-body: #2a3542;
  --icon-btn-bg: #1e2833;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input { font: inherit; }
.hidden { display: none !important; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(360px, 100%);
  background: var(--card);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 0 0 8px; font-size: 28px; font-weight: 800; }
.gate-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.gate-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg);
  color: var(--ink);
  margin-bottom: 12px;
}
.gate-card button, .primary {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}
.gate-card .err { color: var(--expense); min-height: 1.2em; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(88px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.icon {
  display: block;
  flex-shrink: 0;
}
.icon-btn, .collapse-btn, .back-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 20px;
  background: var(--icon-btn-bg);
  color: var(--brand-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  padding: 0;
}
[data-theme="night"] .icon-btn,
[data-theme="night"] .collapse-btn,
[data-theme="night"] .back-btn {
  border: 1px solid var(--line);
  box-shadow: none;
}
.collapse-btn { background: var(--brand-soft); }
.topbar-center { display: flex; justify-content: center; }
.year-chip {
  border: 0;
  background: var(--card);
  color: var(--brand-bright);
  border-radius: 18px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  box-shadow: var(--shadow);
  cursor: pointer;
}
[data-theme="night"] .year-chip {
  border: 1px solid var(--line);
  box-shadow: none;
}
.year-chip-cal, .year-chip-chev {
  display: inline-flex;
  color: var(--brand-bright);
}
.page-title { margin: 0; font-size: 18px; font-weight: 800; }

.main { padding: 8px 20px 24px; }

.period-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--card);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
[data-theme="night"] .period-seg {
  border: 1px solid var(--line);
  box-shadow: none;
}
.period-seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 11px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}
.period-seg button.active {
  background: var(--brand);
  color: #fff;
}

.card {
  background: var(--card);
  border-radius: 22px;
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
}
[data-theme="night"] .card { border-color: var(--line); }
.card.hero-card {
  background: var(--hero);
  border-radius: 24px;
}
[data-theme="night"] .card.hero-card {
  border-color: transparent;
}
[data-theme="night"] .hero-amount {
  color: #ffffff;
  text-shadow: 0 0 18px rgba(232, 238, 244, 0.25);
}

.hero-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.hero-amount {
  font-size: 36px;
  font-weight: 800;
  margin: 6px 0 10px;
  letter-spacing: -0.02em;
}
.hero-hint { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.progress {
  height: 8px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--progress-fill);
  border-radius: inherit;
}
.progress.over > i {
  background: var(--expense);
}
[data-theme="night"] .progress.over > i {
  box-shadow: 0 0 10px rgba(255, 79, 79, 0.65);
}
[data-theme="night"] .type-list .swatch,
[data-theme="night"] .donut-detail-head .swatch {
  box-shadow: 0 0 7px rgba(167, 163, 216, 0.55);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.metric {
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
}
[data-theme="night"] .metric { border-color: var(--line); }
.metric-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-icon { color: var(--brand-bright); }
.metric .label { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric .value {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 800;
}
.metric .value.high { color: var(--tone-high); }
.metric .value.mid { color: var(--tone-mid); }
.metric .value.low { color: var(--tone-low); }
.metric .value.income { color: var(--income); }
[data-theme="night"] .metric .value.high,
[data-theme="night"] .metric .value.income,
[data-theme="night"] .summary-card.income .value {
  text-shadow: 0 0 14px rgba(0, 255, 156, 0.72);
}
[data-theme="night"] .metric .value.mid {
  text-shadow: 0 0 14px rgba(255, 176, 32, 0.72);
}
[data-theme="night"] .metric .value.low,
[data-theme="night"] .summary-card.expense .value,
[data-theme="night"] .tx-amt.expense {
  text-shadow: 0 0 12px rgba(255, 79, 79, 0.55);
}
[data-theme="night"] .tx-amt.income {
  text-shadow: 0 0 12px rgba(0, 255, 156, 0.55);
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--ink);
}
[data-theme="night"] .section-title { color: var(--brand-bright); }

.donut-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 208px;
  padding: 4px 0 8px;
  transition: justify-content 0.2s ease;
}
.donut-stage.is-selected {
  justify-content: flex-start;
  gap: 2px;
  padding-left: 0;
  margin-left: -10px;
}
.donut-area {
  flex: 0 0 auto;
  width: 200px;
  height: 200px;
  transition: transform 0.2s ease, margin 0.2s ease;
}
.donut-stage.is-selected .donut-area {
  transform: translateX(-28px);
  margin-right: -20px;
}
.donut {
  display: block;
  width: 200px;
  height: 200px;
  overflow: visible;
}
.donut-slice {
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.donut-detail {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 4px 8px 8px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.donut-stage.is-selected .donut-detail {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  padding-right: 2px;
}
.donut-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}
.donut-detail-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.donut-detail-amt {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  word-break: break-all;
}
.donut-detail-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-bright);
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.donut-detail-head .swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.type-list-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0 8px;
}
.type-list { list-style: none; margin: 0; padding: 0; }
.type-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 7px 0;
  cursor: pointer;
}
.type-list li .left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.type-list .name {
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.type-list .right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.type-list .amt {
  color: var(--ink);
  font-weight: 700;
  min-width: 56px;
  text-align: right;
}
.type-list .pct {
  color: var(--muted);
  font-weight: 600;
  min-width: 42px;
  text-align: right;
}
.type-list li.active .name { font-weight: 800; }

.budget-row { margin-bottom: 14px; }
.budget-row .top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.budget-row .bar {
  height: 10px;
  background: var(--card-alt);
  border-radius: 999px;
  overflow: hidden;
}
.budget-row .bar > i {
  display: block;
  height: 100%;
  background: var(--brand);
}
.budget-row.over .bar > i { background: var(--expense); }
.budget-row .sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.summary-card .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}
.summary-card .value { margin-top: 6px; font-size: 22px; font-weight: 800; }
.summary-card.income .value { color: var(--income); }
.summary-card.expense .value { color: var(--expense); }

.list-card { padding: 0; overflow: hidden; }
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.list-toolbar .count {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}
.filter-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.filter-clear-btn,
.filter-text-btn,
.filter-clear-panel {
  border: 0;
  background: transparent;
  color: var(--brand-bright);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.chip-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.chip-tools button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.filter-footer {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.filter-clear-panel {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  background: var(--card-alt);
  font-size: 14px;
}
.filter-btn.is-active {
  background: var(--brand);
  color: #fff;
}
.filter-btn {
  border: 0;
  background: var(--brand-soft);
  color: var(--brand-bright);
  width: 36px;
  height: 36px;
  border-radius: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tx-row {
  padding: 14px 14px;
  min-height: 72px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}
.tx-row *,
.tx-row *::before,
.tx-row *::after {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}
.tx-row.is-pressing {
  background: var(--brand-soft) !important;
}
.tx-row:nth-child(odd) { background: var(--card); }
.tx-row:nth-child(even) { background: var(--card-alt); }
.tx-top, .tx-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.tx-cat {
  font-size: 14px;
  font-weight: 800;
  max-width: 176px;
}
.tx-amt { font-size: 16px; font-weight: 800; }
.tx-amt.expense { color: var(--expense); }
.tx-amt.income { color: var(--income); }
.tx-bottom { margin-top: 6px; }
.tx-time {
  font-size: 11px;
  color: var(--muted);
  min-width: 78px;
}
.tx-note {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  flex: 1;
  word-break: break-word;
}
.tx-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-bright);
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 20px calc(10px + var(--safe-bottom));
  background: var(--tabbar);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.tabbar .tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
}
.tabbar .tab .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: inherit;
}
.tabbar .tab .tab-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}
.tab-icon-dash .dash-fan { fill: #a8b4be; }
.tab-icon-dash .dash-body { fill: #7b8793; }
.tabbar .tab.active .tab-icon-dash .dash-fan { fill: #a7a3d8; }
.tabbar .tab.active .tab-icon-dash .dash-body { fill: #6e63b6; }
[data-theme="night"] .tab-icon-dash .dash-fan,
[data-theme="night"] .tab-icon-dash .dash-body { fill: #8b96a3; }
[data-theme="night"] .tabbar .tab.active .tab-icon-dash .dash-fan { fill: #a7a3d8; }
[data-theme="night"] .tabbar .tab.active .tab-icon-dash .dash-body { fill: #a7a3d8; }
.tab-icon-ledger { color: #7b8793; }
.tabbar .tab.active .tab-icon-ledger { color: #6e63b6; }
[data-theme="night"] .tab-icon-ledger { color: #8b96a3; }
[data-theme="night"] .tabbar .tab.active .tab-icon-ledger { color: #a7a3d8; }
.tabbar .tab.active {
  background: var(--brand-soft);
  color: var(--brand-bright);
}

.mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 88vw);
  z-index: 50;
  transform: translateX(-105%);
  transition: transform 280ms ease-out;
  background: var(--card);
  box-shadow: var(--shadow);
  border-right: 1px solid var(--line);
}
.drawer.open { transform: translateX(0); }
.drawer-stack {
  position: relative;
  height: 100%;
  overflow: hidden;
}
.drawer-panel {
  position: absolute;
  inset: 0;
  padding: 18px 16px 32px;
  overflow: auto;
  background: var(--card);
  transition: transform 260ms ease-out, opacity 260ms ease-out;
}
.drawer-panel.sub {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(18px + var(--safe-bottom));
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}
.drawer-panel.sub .drawer-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding-bottom: 8px;
}
.drawer-panel.sub .toggle-list,
.drawer-panel.sub .budget-list,
.drawer-panel.sub .fixed-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding-bottom: 8px;
}
.drawer-panel.sub .drawer-scroll .toggle-list,
.drawer-panel.sub .drawer-scroll .budget-list {
  flex: none;
  overflow: visible;
  padding-bottom: 0;
}
.fixed-total {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--brand-bright);
}
.fixed-list .fixed-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.fixed-list .fixed-fields {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
}
.fixed-list input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.fixed-list .fixed-note {
  grid-column: 1 / -1;
}
.fixed-row-actions {
  display: flex;
  justify-content: flex-end;
}
.fixed-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
}
.fixed-add {
  width: 100%;
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  background: transparent;
  color: var(--brand-bright);
  font-weight: 800;
  cursor: pointer;
}
.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.drawer-actions button {
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink);
}
.drawer-actions .primary {
  background: var(--brand);
  color: #fff;
}
.drawer-panel.sub.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.drawer-home.dim {
  transform: translateX(-18%);
  opacity: 0.45;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.drawer-head h2 { margin: 0; font-size: 26px; font-weight: 800; }
.section-label {
  margin: 18px 0 8px;
  color: var(--brand-bright);
  font-size: 15px;
  font-weight: 800;
}
.section-hint {
  margin: -2px 0 10px;
}
.nav-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  cursor: pointer;
}
.nav-chev {
  display: inline-flex;
  color: var(--brand-bright);
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}
.seg button.active { background: var(--brand); color: #fff; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; }

.toggle-list .row, .budget-list .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-list .name, .budget-list .name { font-weight: 700; }
.switch {
  width: 46px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: var(--line);
  position: relative;
  cursor: pointer;
}
.switch.on { background: var(--brand); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease-out;
}
.switch.on::after { transform: translateX(18px); }
.amount-chip {
  border: 0;
  background: var(--brand-soft);
  color: var(--brand-bright);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.amount-chip.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  z-index: 60;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow);
}
.sheet h3 { margin: 0 0 10px; }
.sheet-line { color: var(--muted); font-size: 13px; }
.sheet input {
  width: 100%;
  margin: 14px 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions button {
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink);
}
.sheet-actions .primary { background: var(--brand); color: #fff; }
.sheet-actions .primary:disabled,
.sheet-actions .primary.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.sheet-actions .danger-btn {
  background: var(--expense);
  color: #fff;
}

.tx-sheet {
  z-index: 62;
  max-height: 88vh;
  overflow: auto;
}
.tx-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.tx-sheet-head h3 { margin: 0; font-size: 16px; }
.tx-sheet-head button {
  border: 0;
  background: transparent;
  color: var(--brand-bright);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  min-width: 36px;
}
.tx-summary {
  padding: 12px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 12px;
  word-break: break-word;
}
.tx-summary strong {
  font-weight: 800;
  color: var(--ink);
}
.tx-action-list button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 16px 4px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}
.tx-action-list button:last-child { border-bottom: 0; }
.tx-action-list button.danger { color: var(--expense); }
.tx-action-list button .sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.tx-field { margin-bottom: 12px; }
.tx-field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 6px;
}
.tx-field input,
.tx-field select,
.tx-field textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
.tx-field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 10px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
.tx-field textarea {
  resize: vertical;
  min-height: 72px;
}
.tx-field.locked input,
.tx-field.locked select {
  opacity: 0.55;
  cursor: not-allowed;
}
.tx-lock-hint { margin-top: 6px; }

.tx-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 48px));
  z-index: 65;
  background: var(--card);
  border-radius: 18px;
  padding: 20px 18px 16px;
  box-shadow: var(--shadow);
}
[data-theme="night"] .tx-dialog {
  border: 1px solid var(--line);
}
.tx-dialog h3 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.tx-dialog > p {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.45;
}

.syncing {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: var(--mask);
}
.sync-card {
  background: var(--card);
  color: var(--ink);
  padding: 22px 28px;
  border-radius: 16px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.filter-panel {
  position: fixed;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  width: min(400px, calc(100% - 24px));
  z-index: 55;
  background: var(--card);
  border-radius: 20px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
  max-height: 82vh;
  overflow: auto;
}
[data-theme="night"] .filter-panel {
  border: 1px solid var(--line);
}
.filter-summary {
  margin-top: 14px;
  padding: 12px 12px 10px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.filter-summary-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 10px;
}
.filter-summary.has-active .filter-summary-title {
  color: var(--ink);
}
.filter-summary-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 15px;
}
.filter-summary-row:last-child { margin-bottom: 0; }
.filter-summary-row .k {
  flex: 0 0 40px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.filter-summary-row .v {
  flex: 1;
  min-width: 0;
  color: var(--muted-2);
  font-weight: 700;
  font-size: 15px;
  word-break: break-word;
}
.filter-summary-row .v.on {
  color: var(--brand-bright);
  font-weight: 800;
}
.chips .chip-all.on {
  background: var(--brand-soft);
  border-color: var(--brand-bright);
  color: var(--brand-bright);
}
.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.filter-head h3 { margin: 0; font-size: 16px; }
.filter-head button {
  border: 0;
  background: transparent;
  color: var(--brand-bright);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
}
.filter-cols button, .chips button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  margin: 0 8px 8px 0;
  font-weight: 700;
  cursor: pointer;
}
.chips button.on, .filter-cols button.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.block { width: 100%; margin-top: 0; }
.filter-footer .block { margin-top: 0; }
.filter-panel input[type="text"] {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.filter-amount-row {
  display: grid;
  grid-template-columns: minmax(108px, 0.9fr) 1.1fr;
  gap: 10px;
  align-items: stretch;
}
.filter-amount-row select,
.filter-amount-row input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
.filter-amount-row select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 10px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
#filter-apply.is-disabled,
#filter-apply:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.filter-time-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.filter-time-seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 4px;
  font-weight: 700;
  cursor: pointer;
}
.filter-time-seg button.active {
  background: var(--brand);
  color: #fff;
}
.chips-years {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.chips-years button {
  margin: 0;
  width: 100%;
  border-radius: 12px;
  text-align: center;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.month-grid button {
  margin: 0;
  width: 100%;
  border-radius: 12px;
  text-align: center;
  padding: 10px 4px;
}
.chips-years button:disabled,
.chips-years button.is-disabled,
.month-grid button:disabled,
.month-grid button.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--bg);
  border-color: var(--line);
  color: var(--muted);
}
.range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.range-row .sep {
  color: var(--muted);
  font-weight: 800;
}
.range-row button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 8px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.range-row button.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pop {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  width: min(220px, calc(100% - 40px));
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.pop button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
}
.pop button.active { color: var(--brand-bright); background: var(--brand-soft); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

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